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

Remove scheduler automate serviceaccount token #44173

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
Diff view
2 changes: 2 additions & 0 deletions chart/templates/scheduler/scheduler-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
{{- if and .Values.scheduler.enabled .Values.scheduler.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
{{- if eq .Values.executor "CeleryExecutor" }}
romsharon98 marked this conversation as resolved.
Show resolved Hide resolved
automountServiceAccountToken: {{ .Values.scheduler.serviceAccount.automountServiceAccountToken }}
eladkal marked this conversation as resolved.
Show resolved Hide resolved
amoghrajesh marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
metadata:
name: {{ include "scheduler.serviceAccountName" . }}
labels:
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ scheduler:

# Create ServiceAccount
serviceAccount:
# default value is true
# only affect CeleryExecutor, default value is true
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
automountServiceAccountToken: true
# Specifies whether a ServiceAccount should be created
Expand Down
37 changes: 32 additions & 5 deletions helm_tests/airflow_core/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,27 +988,54 @@ def test_should_add_component_specific_labels(self):
assert "test_label" in jmespath.search("metadata.labels", docs[0])
assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"

def test_default_automount_service_account_token(self):
@pytest.mark.parametrize(
"executor, default_automount_service_account",
[
("LocalExecutor", None),
("CeleryExecutor", True),
("CeleryKubernetesExecutor", None),
("KubernetesExecutor", None),
("LocalKubernetesExecutor", None),
],
)
def test_default_automount_service_account_token(self, executor, default_automount_service_account):
docs = render_chart(
values={
"scheduler": {
"serviceAccount": {"create": True},
},
"executor": executor,
},
show_only=["templates/scheduler/scheduler-serviceaccount.yaml"],
)
assert jmespath.search("automountServiceAccountToken", docs[0]) is True
assert jmespath.search("automountServiceAccountToken", docs[0]) is default_automount_service_account

def test_overridden_automount_service_account_token(self):
@pytest.mark.parametrize(
"executor, automount_service_account, should_automount_service_account",
[
("LocalExecutor", True, None),
("CeleryExecutor", False, False),
("CeleryKubernetesExecutor", False, None),
("KubernetesExecutor", False, None),
("LocalKubernetesExecutor", False, None),
],
)
def test_overridden_automount_service_account_token(
self, executor, automount_service_account, should_automount_service_account
):
docs = render_chart(
values={
"scheduler": {
"serviceAccount": {"create": True, "automountServiceAccountToken": False},
"serviceAccount": {
"create": True,
"automountServiceAccountToken": automount_service_account,
},
},
"executor": executor,
},
show_only=["templates/scheduler/scheduler-serviceaccount.yaml"],
)
assert jmespath.search("automountServiceAccountToken", docs[0]) is False
assert jmespath.search("automountServiceAccountToken", docs[0]) is should_automount_service_account


class TestSchedulerCreation:
Expand Down