8000 kubernetes: labels are applied to pod by dav009 · Pull Request #3007 · spotify/luigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kubernetes: labels are applied to pod #3007

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

Merged
merged 1 commit into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
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
8000
Diff view
5 changes: 4 additions & 1 deletion luigi/contrib/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ def run(self):
"backoffLimit": self.backoff_limit,
"template": {
"metadata": {
"name": self.uu_name
"name": self.uu_name,
"labels": {}
},
"spec": self.spec_schema
}
Expand All @@ -376,6 +377,8 @@ def run(self):
self.active_deadline_seconds
# Update user labels
job_json['metadata']['labels'].update(self.labels)
job_json['spec']['template']['metadata']['labels'].update(self.labels)

# Add default restartPolicy if not specified
if "restartPolicy" not in self.spec_schema:
job_json["spec"]["template"]["spec"]["restartPolicy"] = "Never"
Expand Down
5 changes: 5 additions & 0 deletions test/contrib/kubernetes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class FailJob(KubernetesJobTask):
}]
}

@property
def labels(self):
return {"dummy_label": "dummy_value"}


@attr('contrib')
class TestK8STask(unittest.TestCase):
Expand All @@ -90,6 +94,7 @@ def test_fail_job(self):
job = Job(kube_api, jobs.response["items"][0])
self.assertTrue("failed" in job.obj["status"])
self.assertTrue(job.obj["status"]["failed"] > fail.max_retrials)
self.assertTrue(job.obj['spec']['template']['metadata']['labels'] == fail.labels())

@mock.patch.object(KubernetesJobTask, "_KubernetesJobTask__get_job_status")
@mock.patch.object(KubernetesJobTask, "signal_complete")
Expand Down
0