diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index a35ada1..53fa427 100644 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,8 +1,8 @@ ack_generate_info: - build_date: "2024-07-19T23:00:12Z" - build_hash: f0a0f42d507c550c2b063a192b3b43e4522bdd9c + build_date: "2024-08-06T02:53:27Z" + build_hash: 587b90dc860e91ee9a763e9e3bc4d3f1b2fbddb7 go_version: go1.22.5 - version: v0.35.0 + version: v0.36.0 api_directory_checksum: 8c038bde341a2f28283e47ad34e7fd7e1e5c64ba api_version: v1alpha1 aws_sdk_go_version: v1.44.93 diff --git a/config/controller/kustomization.yaml b/config/controller/kustomization.yaml index d98e575..b5a69c1 100644 --- a/config/controller/kustomization.yaml +++ b/config/controller/kustomization.yaml @@ -6,4 +6,4 @@ kind: Kustomization images: - name: controller newName: public.ecr.aws/aws-controllers-k8s/emrcontainers-controller - newTag: 1.0.11 + newTag: 1.0.12 diff --git a/config/crd/bases/emrcontainers.services.k8s.aws_jobruns.yaml b/config/crd/bases/emrcontainers.services.k8s.aws_jobruns.yaml index 1f6cd6c..993f98c 100644 --- a/config/crd/bases/emrcontainers.services.k8s.aws_jobruns.yaml +++ b/config/crd/bases/emrcontainers.services.k8s.aws_jobruns.yaml @@ -101,6 +101,8 @@ spec: properties: name: type: string + namespace: + type: string type: object type: object required: diff --git a/go.mod b/go.mod index 1114aa1..b25fdcb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.0 toolchain go1.22.5 require ( - github.com/aws-controllers-k8s/runtime v0.35.0 + github.com/aws-controllers-k8s/runtime v0.36.0 github.com/aws/aws-sdk-go v1.49.0 github.com/ghodss/yaml v1.0.0 github.com/go-logr/logr v1.4.1 diff --git a/go.sum b/go.sum index 1e915a1..422dea1 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws-controllers-k8s/runtime v0.35.0 h1:kLRLFOAcaFJRv/aEiWtb0qhlxFpwvmx6shCWNc1Tuas= -github.com/aws-controllers-k8s/runtime v0.35.0/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew= +github.com/aws-controllers-k8s/runtime v0.36.0 h1:XEMVGfUwsT9QMShihuCLHlape+daJWyYtXj45s/iJiU= +github.com/aws-controllers-k8s/runtime v0.36.0/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew= github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY= github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/helm/Chart.yaml b/helm/Chart.yaml index d241f56..80c5d37 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 name: emrcontainers-chart description: A Helm chart for the ACK service controller for Amazon EMR on EKS (EMRContainers) -version: 1.0.11 -appVersion: 1.0.11 +version: 1.0.12 +appVersion: 1.0.12 home: https://github.com/aws-controllers-k8s/emrcontainers-controller icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png sources: diff --git a/helm/crds/emrcontainers.services.k8s.aws_jobruns.yaml b/helm/crds/emrcontainers.services.k8s.aws_jobruns.yaml index 1f6cd6c..993f98c 100644 --- a/helm/crds/emrcontainers.services.k8s.aws_jobruns.yaml +++ b/helm/crds/emrcontainers.services.k8s.aws_jobruns.yaml @@ -101,6 +101,8 @@ spec: properties: name: type: string + namespace: + type: string type: object type: object required: diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index 336ec86..f410d50 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -1,5 +1,5 @@ {{ .Chart.Name }} has been installed. -This chart deploys "public.ecr.aws/aws-controllers-k8s/emrcontainers-controller:1.0.11". +This chart deploys "public.ecr.aws/aws-controllers-k8s/emrcontainers-controller:1.0.12". Check its status by running: kubectl --namespace {{ .Release.Namespace }} get pods -l "app.kubernetes.io/instance={{ .Release.Name }}" diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index c7a13b9..22715cc 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -157,4 +157,13 @@ rules: - get - patch - update -{{- end }} \ No newline at end of file +{{- end }} + +{{/* Convert k/v map to string like: "key1=value1,key2=value2,..." */}} +{{- define "ack-emrcontainers-controller.feature-gates" -}} +{{- $list := list -}} +{{- range $k, $v := .Values.featureGates -}} +{{- $list = append $list (printf "%s=%s" $k ( $v | toString)) -}} +{{- end -}} +{{ join "," $list }} +{{- end -}} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index a4a1409..b50620e 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -79,6 +79,10 @@ spec: {{- range $key, $value := .Values.reconcile.resourceMaxConcurrentSyncs }} - --reconcile-resource-max-concurrent-syncs - "$(RECONCILE_RESOURCE_MAX_CONCURRENT_SYNCS_{{ $key | upper }})" +{{- end }} +{{- if .Values.featureGates}} + - --feature-gates + - "$(FEATURE_GATES)" {{- end }} image: {{ .Values.image.repository }}:{{ .Values.image.tag }} imagePullPolicy: {{ .Values.image.pullPolicy }} @@ -122,6 +126,10 @@ spec: {{- range $key, $value := .Values.reconcile.resourceMaxConcurrentSyncs }} - name: RECONCILE_RESOURCE_MAX_CONCURRENT_SYNCS_{{ $key | upper }} value: {{ $key }}={{ $value }} +{{- end }} +{{- if .Values.featureGates}} + - name: FEATURE_GATES + value: {{ include "ack-emrcontainers-controller.feature-gates" . }} {{- end }} {{- if .Values.aws.credentials.secretName }} - name: AWS_SHARED_CREDENTIALS_FILE diff --git a/helm/values.schema.json b/helm/values.schema.json index 742163e..7ccb485 100644 --- a/helm/values.schema.json +++ b/helm/values.schema.json @@ -268,6 +268,13 @@ "type": "object" } }, + "featureGates": { + "description": "Feature gates settings", + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, "required": [ "image", "deployment", diff --git a/helm/values.yaml b/helm/values.yaml index da1dd8d..a529bb9 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -4,7 +4,7 @@ image: repository: public.ecr.aws/aws-controllers-k8s/emrcontainers-controller - tag: 1.0.11 + tag: 1.0.12 pullPolicy: IfNotPresent pullSecrets: [] @@ -153,3 +153,10 @@ leaderElection: # will attempt to use the namespace of the service account mounted to the Controller # pod. namespace: "" + +# Configuration for feature gates. These are optional controller features that +# can be individually enabled ("true") or disabled ("false") by adding key/value +# pairs below. +featureGates: {} + # featureGate1: true + # featureGate2: false diff --git a/pkg/resource/job_run/references.go b/pkg/resource/job_run/references.go index 259e877..d39dc1d 100644 --- a/pkg/resource/job_run/references.go +++ b/pkg/resource/job_run/references.go @@ -56,12 +56,11 @@ func (rm *resourceManager) ResolveReferences( apiReader client.Reader, res acktypes.AWSResource, ) (acktypes.AWSResource, bool, error) { - namespace := res.MetaObject().GetNamespace() ko := rm.concreteResource(res).ko resourceHasReferences := false err := validateReferenceFields(ko) - if fieldHasReferences, err := rm.resolveReferenceForVirtualClusterID(ctx, apiReader, namespace, ko); err != nil { + if fieldHasReferences, err := rm.resolveReferenceForVirtualClusterID(ctx, apiReader, ko); err != nil { return &resource{ko}, (resourceHasReferences || fieldHasReferences), err } else { resourceHasReferences = resourceHasReferences || fieldHasReferences @@ -90,7 +89,6 @@ func validateReferenceFields(ko *svcapitypes.JobRun) error { func (rm *resourceManager) resolveReferenceForVirtualClusterID( ctx context.Context, apiReader client.Reader, - namespace string, ko *svcapitypes.JobRun, ) (hasReferences bool, err error) { if ko.Spec.VirtualClusterRef != nil && ko.Spec.VirtualClusterRef.From != nil { @@ -99,6 +97,10 @@ func (rm *resourceManager) resolveReferenceForVirtualClusterID( if arr.Name == nil || *arr.Name == "" { return hasReferences, fmt.Errorf("provided resource reference is nil or empty: VirtualClusterRef") } + namespace := ko.ObjectMeta.GetNamespace() + if arr.Namespace != nil && *arr.Namespace != "" { + namespace = *arr.Namespace + } obj := &svcapitypes.VirtualCluster{} if err := getReferencedResourceState_VirtualCluster(ctx, apiReader, obj, *arr.Name, namespace); err != nil { return hasReferences, err