aaron-y-chen commented on code in PR #72511:
URL: https://github.com/apache/airflow/pull/72511#discussion_r3940086320


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -1270,3 +1283,63 @@ def _emit_container_logs(self, logs: list[str], now: 
DateTime, container_name: s
                 else:
                     level = _parse_log_level(message_to_log)
                     self.log.log(level, "[%s] %s", container_name, 
message_to_log)
+
+    def get_init_container_names(self, pod: V1Pod) -> list[str]:
+        """
+        Return init container names from the pod spec.
+
+        :meta private:
+        """
+        return [container_spec.name for container_spec in 
pod.spec.init_containers]

Review Comment:
   If users create a pod without init_containers, it might raise an error.
   
   ```python
   pod = V1Pod(metadata=V1ObjectMeta(name="no-init-pod", namespace="default"),
               spec=V1PodSpec(containers=[V1Container(name="base")]))
   AsyncPodManager(async_hook=..., callbacks=[]).get_init_container_names(pod)
   # TypeError: 'NoneType' object is not iterable
   ```
   
   I think we can handle this case here:
   
   ```suggestion
           return [container_spec.name for container_spec in 
pod.spec.init_containers or []]
   ```



-- 
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