Skip to content

Commit 79d0279

Browse files
authored
Secret errors to be terminal code (#131)
For now secret errors would be terminal code to be consistent with ACK behavior. ``` Conditions: Message: kubernetes secret not found Status: True Type: ACK.Terminal ``` Runtime PR - aws-controllers-k8s/runtime#33 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c876663 commit 79d0279

File tree

7 files changed

+27
-18
lines changed

7 files changed

+27
-18
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ GO111MODULE=on
66
AWS_SERVICE=$(shell echo $(SERVICE) | tr '[:upper:]' '[:lower:]')
77

88
# Build ldflags
9-
VERSION ?= "v0.6.0"
9+
VERSION ?= "v0.7.0"
1010
GITCOMMIT=$(shell git rev-parse HEAD)
1111
BUILDDATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
1212
IMPORT_PATH=github.com/aws-controllers-k8s/code-generator

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/aws-controllers-k8s/code-generator
33
go 1.14
44

55
require (
6-
github.com/aws-controllers-k8s/runtime v0.6.0
6+
github.com/aws-controllers-k8s/runtime v0.7.0
77
github.com/aws/aws-sdk-go v1.37.4
88
github.com/dlclark/regexp2 v1.4.0
99
// pin to v0.1.1 due to release problem with v0.1.2

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
6767
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
6868
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
6969
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
70-
github.com/aws-controllers-k8s/runtime v0.6.0 h1:Up9pn9FfItYiItiSdT+FOfHQNKO8oSb5GU8pKH9JF8E=
71-
github.com/aws-controllers-k8s/runtime v0.6.0/go.mod h1:xA2F18PJerBHaqrS4de1lpP7skeSMeStkmh+3x5sWvw=
70+
github.com/aws-controllers-k8s/runtime v0.7.0 h1:A+55gZVCXiO9EUlCz8MCcquMrcyPYzMLUXdpfOiOUDc=
71+
github.com/aws-controllers-k8s/runtime v0.7.0/go.mod h1:xA2F18PJerBHaqrS4de1lpP7skeSMeStkmh+3x5sWvw=
7272
github.com/aws/aws-sdk-go v1.37.4 h1:tWxrpMK/oRSXVnjUzhGeCWLR00fW0WF4V4sycYPPrJ8=
7373
github.com/aws/aws-sdk-go v1.37.4/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
7474
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=

pkg/generate/ack/runtime_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
2828
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
2929
ackcfg "github.com/aws-controllers-k8s/runtime/pkg/config"
30+
ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors"
3031
ackmetrics "github.com/aws-controllers-k8s/runtime/pkg/metrics"
3132
ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log"
3233
acktypes "github.com/aws-controllers-k8s/runtime/pkg/types"
@@ -155,4 +156,7 @@ func TestRuntimeDependency(t *testing.T) {
155156

156157
// ACK runtime 0.6.0 modified pkg/types/AWSResourceManager.Delete signature.
157158
require.Implements((*acktypes.AWSResourceManager)(nil), new(fakeRM))
159+
160+
// ACK runtime 0.7.0 introduced SecretNotFound error.
161+
require.NotNil(ackerr.SecretNotFound)
158162
}

pkg/generate/code/set_sdk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ func setSDKForSlice(
10091009
sourceAttributePath := sourceFieldPath
10101010
if targetShape.MemberRef.Shape.Type == "structure" {
10111011
containerFieldName = targetFieldName
1012-
sourceAttributePath = sourceFieldPath+"."
1012+
sourceAttributePath = sourceFieldPath + "."
10131013
}
10141014
out += setSDKForContainer(
10151015
cfg, r,

pkg/generate/config/resource.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,16 @@ type PrintConfig struct {
281281
// ReconcileConfig describes options for controlling the reconciliation
282282
// logic for a particular resource.
283283
type ReconcileConfig struct {
284-
// RequeueOnSuccessSeconds indicates the number of seconds after which to requeue a
285-
// resource that has been successfully reconciled (i.e. ConditionTypeResourceSynced=true)
286-
// This is useful for resources that are long-lived and may have observable status fields
287-
// change over time that would be useful to refresh those field values for users.
288-
// This field is optional and the default behaviour of the ACK runtime is to not requeue
289-
// resources that have been successfully reconciled. Note that all ACK controllers will
290-
// *flush and resync their watch caches* every 10 hours by default, which will end up
291-
// causing ACK controllers to refresh the status views of all watched resources, but this
292-
// behaviour is expensive and may be turned off in future ACK runtime options.
293-
RequeueOnSuccessSeconds int `json:"requeue_on_success_seconds,omitempty"`
284+
// RequeueOnSuccessSeconds indicates the number of seconds after which to requeue a
285+
// resource that has been successfully reconciled (i.e. ConditionTypeResourceSynced=true)
286+
// This is useful for resources that are long-lived and may have observable status fields
287+
// change over time that would be useful to refresh those field values for users.
288+
// This field is optional and the default behaviour of the ACK runtime is to not requeue
289+
// resources that have been successfully reconciled. Note that all ACK controllers will
290+
// *flush and resync their watch caches* every 10 hours by default, which will end up
291+
// causing ACK controllers to refresh the status views of all watched resources, but this
292+
// behaviour is expensive and may be turned off in future ACK runtime options.
293+
RequeueOnSuccessSeconds int `json:"requeue_on_success_seconds,omitempty"`
294294
}
295295

296296
// ResourceConfig returns the ResourceConfig for a given named resource

templates/pkg/resource/sdk.go.tpl

+8-3
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,21 @@ func (rm *resourceManager) updateConditions (
212212
}
213213
}
214214

215-
if rm.terminalAWSError(err) {
215+
if rm.terminalAWSError(err) || err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound {
216216
if terminalCondition == nil {
217217
terminalCondition = &ackv1alpha1.Condition{
218218
Type: ackv1alpha1.ConditionTypeTerminal,
219219
}
220220
ko.Status.Conditions = append(ko.Status.Conditions, terminalCondition)
221221
}
222+
var errorMessage = ""
223+
if err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound {
224+
errorMessage = err.Error()
225+
} else {
226+
awsErr, _ := ackerr.AWSError(err)
227+
errorMessage = awsErr.Message()
228+
}
222229
terminalCondition.Status = corev1.ConditionTrue
223-
awsErr, _ := ackerr.AWSError(err)
224-
errorMessage := awsErr.Message()
225230
terminalCondition.Message = &errorMessage
226231
} else {
227232
// Clear the terminal condition if no longer present

0 commit comments

Comments
 (0)