Skip to content

Commit

Permalink
config-syncer job enhancement (#2074)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgvishnuram committed Dec 5, 2023
1 parent 976d8ed commit 0ea0eb3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# 1. Do not create any resource if rbacEnabled is disabled
# 2. Create a Cluster Role if namespacePools is disabled
# 3. Create roles for each namespaces in the namespacePool (+ astronomer namespace) if enabled.
{{- if .Values.configSyncer.enabled }}
{{- $useClusterRoles := and .Values.global.rbacEnabled (not .Values.global.features.namespacePools.enabled)}}
{{- $namespaces := .Values.global.features.namespacePools.namespaces.names }}
{{- if $useClusterRoles }}
Expand Down Expand Up @@ -41,3 +42,4 @@ rules:
verbs: ["get", "list"]
{{ end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# 1. Do not create anything is rbacEnabled is disabled
# 2. Create ClusterRoleBinding if namespacePools disabled
# 3. Create RoleBinding for each namespace in the namespacePool (+ astronomer namespace) if enabled
{{- if .Values.configSyncer.enabled }}
{{- $useClusterRoles := and .Values.global.rbacEnabled (not .Values.global.features.namespacePools.enabled)}}
{{- $namespaces := .Values.global.features.namespacePools.namespaces.names }}
{{- if $useClusterRoles }}
Expand Down Expand Up @@ -37,3 +38,4 @@ subjects:
namespace: {{ $.Release.Namespace }}
{{ end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################################
## Astronomer ServiceAccount
#################################
{{- if .Values.global.rbacEnabled }}
{{- if and .Values.global.rbacEnabled .Values.configSyncer.enabled }}
kind: ServiceAccount
apiVersion: v1
metadata:
Expand Down
19 changes: 19 additions & 0 deletions tests/chart_tests/test_astronomer_config_syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,22 @@ def test_astronomer_config_syncer_cronjob_default_schedule(
cron_schedule = doc["spec"]["schedule"].split(" ")
assert int(cron_schedule[0]) == test_data[1]
assert int(cron_schedule[1]) == test_data[2]

def test_astronomer_config_syncer_disabled(self, kube_version):
"""Test that config syncer is disabled."""

# First rbacEnabled set to true and namespacePools disabled, should create a ClusterRole and ClusterRoleBinding
docs = render_chart(
kube_version=kube_version,
values={
"astronomer": {"configSyncer": {"enabled": False}},
},
show_only=[
"charts/astronomer/templates/config-syncer/config-syncer-cronjob.yaml",
"charts/astronomer/templates/config-syncer/config-syncer-role.yaml",
"charts/astronomer/templates/config-syncer/config-syncer-rolebinding.yaml",
"charts/astronomer/templates/config-syncer/config-syncer-serviceaccount.yaml",
],
)

assert len(docs) == 0

0 comments on commit 0ea0eb3

Please sign in to comment.