Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly set for configmap owner #49

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions kbatch-proxy/kbatch_proxy/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import escapism
from kubernetes.client.models import (
V1Job,
V1CronJob,
V1JobTemplateSpec,
V1ConfigMap,
V1Container,
Expand Down Expand Up @@ -198,16 +199,14 @@ def add_submitted_configmap_name(
job.spec.template.spec.volumes[-2].config_map.name = config_map.metadata.name


def patch_configmap_owner(
job: Union[V1Job, V1JobTemplateSpec], config_map: V1ConfigMap
):
def patch_configmap_owner(job: Union[V1Job, V1CronJob], config_map: V1ConfigMap):
if job.metadata.name is None:
raise ValueError("job must have a name before it can be set as an owner")
assert job.metadata.name is not None

if issubclass(type(job), V1Job):
kind = "Job"
elif issubclass(type(job), V1JobTemplateSpec):
else:
kind = "CronJob"

config_map.metadata.owner_references = [
Expand Down