fix(k8s): include job volumes in PVC/ConfigMap/PV creation

For jobs-only stacks, named_volumes_from_pod_files() returned empty
because it only scanned parsed_pod_yaml_map. This caused ConfigMaps
and PVCs declared in the spec to be silently skipped.

- Add _all_named_volumes() helper that scans both pod and job maps
- Guard update() against empty parsed_pod_yaml_map (uncaught 404)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
test-ci
Prathamesh Musale 2026-03-03 14:13:46 +00:00
parent b5528b9a38
commit 50fd116ead
2 changed files with 13 additions and 3 deletions

View File

@ -101,6 +101,12 @@ class ClusterInfo:
if opts.o.debug: if opts.o.debug:
print(f"Parsed job yaml map: {self.parsed_job_yaml_map}") print(f"Parsed job yaml map: {self.parsed_job_yaml_map}")
def _all_named_volumes(self) -> list:
"""Return named volumes from both pod and job compose files."""
volumes = named_volumes_from_pod_files(self.parsed_pod_yaml_map)
volumes.extend(named_volumes_from_pod_files(self.parsed_job_yaml_map))
return volumes
def get_nodeports(self): def get_nodeports(self):
nodeports = [] nodeports = []
for pod_name in self.parsed_pod_yaml_map: for pod_name in self.parsed_pod_yaml_map:
@ -264,7 +270,7 @@ class ClusterInfo:
def get_pvcs(self): def get_pvcs(self):
result = [] result = []
spec_volumes = self.spec.get_volumes() spec_volumes = self.spec.get_volumes()
named_volumes = named_volumes_from_pod_files(self.parsed_pod_yaml_map) named_volumes = self._all_named_volumes()
resources = self.spec.get_volume_resources() resources = self.spec.get_volume_resources()
if not resources: if not resources:
resources = DEFAULT_VOLUME_RESOURCES resources = DEFAULT_VOLUME_RESOURCES
@ -308,7 +314,7 @@ class ClusterInfo:
def get_configmaps(self): def get_configmaps(self):
result = [] result = []
spec_configmaps = self.spec.get_configmaps() spec_configmaps = self.spec.get_configmaps()
named_volumes = named_volumes_from_pod_files(self.parsed_pod_yaml_map) named_volumes = self._all_named_volumes()
for cfg_map_name, cfg_map_path in spec_configmaps.items(): for cfg_map_name, cfg_map_path in spec_configmaps.items():
if cfg_map_name not in named_volumes: if cfg_map_name not in named_volumes:
if opts.o.debug: if opts.o.debug:
@ -344,7 +350,7 @@ class ClusterInfo:
def get_pvs(self): def get_pvs(self):
result = [] result = []
spec_volumes = self.spec.get_volumes() spec_volumes = self.spec.get_volumes()
named_volumes = named_volumes_from_pod_files(self.parsed_pod_yaml_map) named_volumes = self._all_named_volumes()
resources = self.spec.get_volume_resources() resources = self.spec.get_volume_resources()
if not resources: if not resources:
resources = DEFAULT_VOLUME_RESOURCES resources = DEFAULT_VOLUME_RESOURCES

View File

@ -632,6 +632,10 @@ class K8sDeployer(Deployer):
return log_stream_from_string(log_data) return log_stream_from_string(log_data)
def update(self): def update(self):
if not self.cluster_info.parsed_pod_yaml_map:
if opts.o.debug:
print("No pods defined, skipping update")
return
self.connect_api() self.connect_api()
ref_deployment = self.cluster_info.get_deployment() ref_deployment = self.cluster_info.get_deployment()
if not ref_deployment or not ref_deployment.metadata: if not ref_deployment or not ref_deployment.metadata: