calrissian icon indicating copy to clipboard operation
calrissian copied to clipboard

Allow setting the container when the pod has more than one container

Open fabricebrito opened this issue 2 years ago • 2 comments

The env variable CALRISSIAN_POD_NAME allow discovering the volumes to mount on the spawned pods.

This is implemented in class KubernetesPodVolumeInspector on the assumption that there's a single container in that pod

python

def get_first_container(self):
        return self.pod.spec.containers[0]

When having more containers in the calrissian pod, this implementation breaks.

The proposed evolution in this issue is to allow defining the container name via env variable and get the container by name if that variable is set

fabricebrito avatar May 17 '23 11:05 fabricebrito

@fabricebrito I'm trying to understand the underlying use case here, since it seems obvious that CALRISSIAN_POD_NAME should always be the pod name as defined in the pod metadata, and never the name of a container in the spec.

The suggestion is that the env variable CALRISSIAN_POD_NAME (chosen by Python constant POD_NAME_ENV_VARIABLE) is used to retrieve mounted volume information, but I can't find any use of that variable, so I'm guessing that there are some workflows somewhere else that use this information. I'm guessing it's not for specifying a pod directory for use with kubectl, since that wouldn't use the container name but the pod name.

I am asking because we are considering whether to retrieve the pod name for inclusion in result provenance, and if CALRISSIAN_POD_NAME is not the pod name then we couldn't count on it.

davidjsherman avatar Jan 03 '24 14:01 davidjsherman

It seems that we aren't looking for a general mechanism for inspecting volumes, but for finding the specific volumes that play specific roles in Calrissian's pods. If that is true, wouldn't it be better to name the env variables by those roles, rather than making it necessary to infer the volumes from implicit rules in pod and container names?

For example, in our own templates for Calrissian job submission, we use specific parameters for CALRISSION_INPUT_VOLUME, CALRISSION_TEMP_VOLUME, and CALRISSION_OUTPUT_VOLUME.

davidjsherman avatar Jan 03 '24 14:01 davidjsherman