Grypse commented on PR #20516:
URL: https://github.com/apache/flink/pull/20516#issuecomment-1211500213

   > Could we fix this issue in the `KubernetesUtils#loadPodFromTemplateFile`? 
Set an empty spec if not specified.
   
   This PR fixes the issue in KubernetesUtils#loadPodFromTemplateFile. When no 
spec field is specified, set an empty one.
   
   Code:
   `    public static FlinkPod loadPodFromTemplateFile(
               FlinkKubeClient kubeClient, File podTemplateFile, String 
mainContainerName) {
           final KubernetesPod pod = 
kubeClient.loadPodFromTemplateFile(podTemplateFile);
           final List<Container> otherContainers = new ArrayList<>();
           Container mainContainer = null;
   
           if (null != pod.getInternalResource().getSpec()) {
               for (Container container : 
pod.getInternalResource().getSpec().getContainers()) {
                   if (mainContainerName.equals(container.getName())) {
                       mainContainer = container;
                   } else {
                       otherContainers.add(container);
                   }
               }
               
pod.getInternalResource().getSpec().setContainers(otherContainers);
           } else {
               // Set empty spec for taskmanager pod template
               pod.getInternalResource().setSpec(new PodSpecBuilder().build());
           }
   
           if (mainContainer == null) {
               LOG.info(
                       "Could not find main container {} in pod template, using 
empty one to initialize.",
                       mainContainerName);
               mainContainer = new ContainerBuilder().build();
           }
   
           return new FlinkPod(pod.getInternalResource(), mainContainer);
       }`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to