From 50c00c83a30db6b18204290885162d9ef3486f5f Mon Sep 17 00:00:00 2001 From: AWS Controllers for Kubernetes Bot <82905295+ack-bot@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:59:45 -0700 Subject: [PATCH] Update to ACK runtime `v0.36.0`, code-generator `v0.36.0` (#55) ### Update to ACK runtime `v0.36.0`, code-generator `v0.36.0` ---------- * ACK code-generator `v0.36.0` [release notes](https://github.com/aws-controllers-k8s/code-generator/releases/tag/v0.36.0) * ACK runtime `v0.36.0` [release notes](https://github.com/aws-controllers-k8s/runtime/releases/tag/v0.36.0) ---------- NOTE: This PR increments the release version of service controller from `v1.0.14` to `v1.0.15` Once this PR is merged, release `v1.0.15` will be automatically created for `sqs-controller` **Please close this PR, if you do not want the new patch release for `sqs-controller`** ---------- #### stdout for `make build-controller`: ``` building ack-generate ... ok. ==== building sqs-controller ==== Copying common custom resource definitions into sqs Building Kubernetes API objects for sqs Generating deepcopy code for sqs Generating custom resource definitions for sqs Building service controller for sqs Generating RBAC manifests for sqs Running gofmt against generated code for sqs Updating additional GitHub repository maintenance files ==== building sqs-controller release artifacts ==== Building release artifacts for sqs-v1.0.15 Generating common custom resource definitions Generating custom resource definitions for sqs Generating RBAC manifests for sqs ``` ---------- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --- apis/v1alpha1/ack-generate-metadata.yaml | 6 +++--- config/controller/kustomization.yaml | 2 +- config/crd/bases/sqs.services.k8s.aws_queues.yaml | 4 ++++ go.mod | 2 +- go.sum | 4 ++-- helm/Chart.yaml | 4 ++-- helm/crds/sqs.services.k8s.aws_queues.yaml | 4 ++++ helm/templates/NOTES.txt | 2 +- helm/templates/_helpers.tpl | 11 ++++++++++- helm/templates/deployment.yaml | 8 ++++++++ helm/values.schema.json | 7 +++++++ helm/values.yaml | 9 ++++++++- pkg/resource/queue/references.go | 15 ++++++++++----- 13 files changed, 61 insertions(+), 17 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index ef9382c..06fc5cc 100755 --- 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:05:29Z" - build_hash: f0a0f42d507c550c2b063a192b3b43e4522bdd9c + build_date: "2024-08-06T02:44:18Z" + build_hash: 587b90dc860e91ee9a763e9e3bc4d3f1b2fbddb7 go_version: go1.22.5 - version: v0.35.0 + version: v0.36.0 api_directory_checksum: f74a20965e9cd60cc5b02f43349da4f6cf29c865 api_version: v1alpha1 aws_sdk_go_version: v1.49.0 diff --git a/config/controller/kustomization.yaml b/config/controller/kustomization.yaml index 38a8c3a..a9c2207 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/sqs-controller - newTag: 1.0.14 + newTag: 1.0.15 diff --git a/config/crd/bases/sqs.services.k8s.aws_queues.yaml b/config/crd/bases/sqs.services.k8s.aws_queues.yaml index 27fa17c..d8f492b 100644 --- a/config/crd/bases/sqs.services.k8s.aws_queues.yaml +++ b/config/crd/bases/sqs.services.k8s.aws_queues.yaml @@ -62,6 +62,8 @@ spec: properties: name: type: string + namespace: + type: string type: object type: object maximumMessageSize: @@ -83,6 +85,8 @@ spec: properties: name: type: string + namespace: + type: string type: object type: object queueName: diff --git a/go.mod b/go.mod index ddd71e4..3b2c42f 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.5 require ( github.com/aws-controllers-k8s/iam-controller v1.1.1 github.com/aws-controllers-k8s/kms-controller v1.0.2 - 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/go-logr/logr v1.4.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 6974066..2673dd6 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/aws-controllers-k8s/iam-controller v1.1.1 h1:O6arh7DNlQF26MEKzgA2/kBE github.com/aws-controllers-k8s/iam-controller v1.1.1/go.mod h1:2+ARwRpazTq5MErjMz0MpXHhtAzRfNtY56Uj0gvu9vE= github.com/aws-controllers-k8s/kms-controller v1.0.2 h1:v8nh/oaX/U6spCwBDaWyem7XXpzoP/MnkJyEjNOZN9s= github.com/aws-controllers-k8s/kms-controller v1.0.2/go.mod h1:BeoijsyGjJ9G5VcDjpFdxBW0IxaeKXYX497XmUJiPSQ= -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 2292ab3..930c677 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 name: sqs-chart description: A Helm chart for the ACK service controller for Amazon Simple Queue Service (SQS) -version: 1.0.14 -appVersion: 1.0.14 +version: 1.0.15 +appVersion: 1.0.15 home: https://github.com/aws-controllers-k8s/sqs-controller icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png sources: diff --git a/helm/crds/sqs.services.k8s.aws_queues.yaml b/helm/crds/sqs.services.k8s.aws_queues.yaml index dfdf8b6..69e10b3 100644 --- a/helm/crds/sqs.services.k8s.aws_queues.yaml +++ b/helm/crds/sqs.services.k8s.aws_queues.yaml @@ -62,6 +62,8 @@ spec: properties: name: type: string + namespace: + type: string type: object type: object maximumMessageSize: @@ -83,6 +85,8 @@ spec: properties: name: type: string + namespace: + type: string type: object type: object queueName: diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index a0ac191..7c4a487 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/sqs-controller:1.0.14". +This chart deploys "public.ecr.aws/aws-controllers-k8s/sqs-controller:1.0.15". 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 e3a531c..093cc80 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -165,4 +165,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-sqs-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 74bfbdc..45a0b16 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-sqs-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 8fddd22..20dbb54 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -4,7 +4,7 @@ image: repository: public.ecr.aws/aws-controllers-k8s/sqs-controller - tag: 1.0.14 + tag: 1.0.15 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/queue/references.go b/pkg/resource/queue/references.go index 6206bed..9312c64 100644 --- a/pkg/resource/queue/references.go +++ b/pkg/resource/queue/references.go @@ -68,18 +68,17 @@ 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.resolveReferenceForKMSMasterKeyID(ctx, apiReader, namespace, ko); err != nil { + if fieldHasReferences, err := rm.resolveReferenceForKMSMasterKeyID(ctx, apiReader, ko); err != nil { return &resource{ko}, (resourceHasReferences || fieldHasReferences), err } else { resourceHasReferences = resourceHasReferences || fieldHasReferences } - if fieldHasReferences, err := rm.resolveReferenceForPolicy(ctx, apiReader, namespace, ko); err != nil { + if fieldHasReferences, err := rm.resolveReferenceForPolicy(ctx, apiReader, ko); err != nil { return &resource{ko}, (resourceHasReferences || fieldHasReferences), err } else { resourceHasReferences = resourceHasReferences || fieldHasReferences @@ -109,7 +108,6 @@ func validateReferenceFields(ko *svcapitypes.Queue) error { func (rm *resourceManager) resolveReferenceForKMSMasterKeyID( ctx context.Context, apiReader client.Reader, - namespace string, ko *svcapitypes.Queue, ) (hasReferences bool, err error) { if ko.Spec.KMSMasterKeyRef != nil && ko.Spec.KMSMasterKeyRef.From != nil { @@ -118,6 +116,10 @@ func (rm *resourceManager) resolveReferenceForKMSMasterKeyID( if arr.Name == nil || *arr.Name == "" { return hasReferences, fmt.Errorf("provided resource reference is nil or empty: KMSMasterKeyRef") } + namespace := ko.ObjectMeta.GetNamespace() + if arr.Namespace != nil && *arr.Namespace != "" { + namespace = *arr.Namespace + } obj := &kmsapitypes.Key{} if err := getReferencedResourceState_Key(ctx, apiReader, obj, *arr.Name, namespace); err != nil { return hasReferences, err @@ -186,7 +188,6 @@ func getReferencedResourceState_Key( func (rm *resourceManager) resolveReferenceForPolicy( ctx context.Context, apiReader client.Reader, - namespace string, ko *svcapitypes.Queue, ) (hasReferences bool, err error) { if ko.Spec.PolicyRef != nil && ko.Spec.PolicyRef.From != nil { @@ -195,6 +196,10 @@ func (rm *resourceManager) resolveReferenceForPolicy( if arr.Name == nil || *arr.Name == "" { return hasReferences, fmt.Errorf("provided resource reference is nil or empty: PolicyRef") } + namespace := ko.ObjectMeta.GetNamespace() + if arr.Namespace != nil && *arr.Namespace != "" { + namespace = *arr.Namespace + } obj := &iamapitypes.Policy{} if err := getReferencedResourceState_Policy(ctx, apiReader, obj, *arr.Name, namespace); err != nil { return hasReferences, err