public static List<ContainerStatus> findDriverMainContainerStatus(
      final ApplicationSpec appSpec, final List<ContainerStatus> containerStatusList) {
    if (appSpec == null) {
      return containerStatusList;
    }
    Map<String, String> sparkConf = appSpec.getSparkConf();
    String key = sparkConf.get(DRIVER_SPARK_CONTAINER_PROP_KEY);
    if (key == null || key.isEmpty()) {
      return containerStatusList;
    }
    String mainContainerName = sparkConf.get(DRIVER_SPARK_CONTAINER_PROP_KEY);
    return containerStatusList.stream()
        .filter(c -> mainContainerName.equalsIgnoreCase(c.getName()))
        .collect(Collectors.toList());
  }
@Test
  void testFindDriverMainContainerStatus() {
    ContainerStatus containerStatus1 =
        new ContainerStatusBuilder().withName("foo-container-1").build();
    ContainerStatus containerStatus2 =
        new ContainerStatusBuilder().withName("foo-container-2").build();
    ApplicationSpec specWithoutSparkContainerNameProp = new ApplicationSpec();
    List<ContainerStatus> sparkContainerStatusList =
        ModelUtils.findDriverMainContainerStatus(
            specWithoutSparkContainerNameProp, List.of(containerStatus1, containerStatus2));
    Assertions.assertEquals(List.of(containerStatus1, containerStatus2), sparkContainerStatusList);

    ApplicationSpec specWithSparkContainerNameProp = new ApplicationSpec();
    Map<String, String> sparkProps = new HashMap<>();
    sparkProps.put("spark.kubernetes.driver.podTemplateContainerName", "foo-container-2");
    specWithSparkContainerNameProp.setSparkConf(sparkProps);
    sparkContainerStatusList =
        ModelUtils.findDriverMainContainerStatus(
            specWithSparkContainerNameProp, List.of(containerStatus1, containerStatus2));
    Assertions.assertEquals(List.of(containerStatus2), sparkContainerStatusList);
  }