Skip to content

Commit c9e9b16

Browse files
Remove 404s from terminal codes (#84)
Fixes aws-controllers-k8s/community#1228 Description of changes: 404 error codes should not be included as terminal errors, as they prevent proper resource referencing. The better behaviour is for the controller to fall off exponentially while attempting to retry until the resource becomes available. This produces more noise in the controller logs, but properly updates the resources with the conditions until the resource can finally be created. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent f17d71a commit c9e9b16

File tree

10 files changed

+86
-43
lines changed

10 files changed

+86
-43
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-03-02T19:01:08Z"
3-
build_hash: ade2429bb444ab635916395ea5773d141ba135e1
4-
go_version: go1.17.5
2+
build_date: "2022-03-16T20:57:08Z"
3+
build_hash: 7052f6808b237f97a2000e4c4f296b9ed2a0d7c0
4+
go_version: go1.17.8
55
version: v0.17.2
66
api_directory_checksum: 246af92291668493e03954b4e4117c21f5b62790
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.42.0
99
generator_config_info:
10-
file_checksum: 23f444fb86eaa5c1acb4d4f51430e606e7ee554a
10+
file_checksum: 4fd6f317804ecb5192bfb88c569ae335d418248b
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ resources:
2525
- InvalidParameterValue
2626
- InvalidParameterCombination
2727
- InsufficientCacheClusterCapacity
28-
- CacheSecurityGroupNotFound
29-
- CacheSubnetGroupNotFoundFault
3028
- ClusterQuotaForCustomerExceeded
3129
- NodeQuotaForClusterExceeded
3230
- NodeQuotaForCustomerExceeded
3331
- InvalidVPCNetworkStateFault
3432
- TagQuotaPerResourceExceeded
3533
- NodeGroupsPerReplicationGroupQuotaExceeded
3634
- InvalidCacheSecurityGroupState
37-
- CacheParameterGroupNotFound
3835
- InvalidKMSKeyFault
39-
- CacheClusterNotFound
4036
fields:
4137
AllowedScaleUpModifications:
4238
is_read_only: true
@@ -94,8 +90,6 @@ resources:
9490
- InvalidParameterValue
9591
- InvalidParameterCombination
9692
- SnapshotAlreadyExistsFault
97-
- CacheClusterNotFound
98-
- ReplicationGroupNotFoundFault
9993
- SnapshotQuotaExceededFault
10094
- SnapshotFeatureNotSupportedFault
10195
fields:
@@ -133,14 +127,16 @@ resources:
133127
custom_method_name: customUpdateCacheParameterGroup
134128
User:
135129
exceptions:
130+
errors:
131+
404:
132+
code: UserNotFound
136133
terminal_codes:
137134
- UserAlreadyExists
138135
- UserQuotaExceeded
139136
- DuplicateUserName
140137
- InvalidParameterValue
141138
- InvalidParameterCombination
142139
- InvalidUserState
143-
- UserNotFound
144140
- DefaultUserAssociatedToUserGroup
145141
fields:
146142
LastRequestedAccessString:
@@ -178,7 +174,6 @@ resources:
178174
- DefaultUserRequired
179175
- UserGroupQuotaExceededFault
180176
- TagQuotaPerResourceExceeded
181-
- UserNotFoundFault
182177
update_operation:
183178
custom_method_name: customUpdateUserGroup
184179
operations:

generator.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ resources:
2525
- InvalidParameterValue
2626
- InvalidParameterCombination
2727
- InsufficientCacheClusterCapacity
28-
- CacheSecurityGroupNotFound
29-
- CacheSubnetGroupNotFoundFault
3028
- ClusterQuotaForCustomerExceeded
3129
- NodeQuotaForClusterExceeded
3230
- NodeQuotaForCustomerExceeded
3331
- InvalidVPCNetworkStateFault
3432
- TagQuotaPerResourceExceeded
3533
- NodeGroupsPerReplicationGroupQuotaExceeded
3634
- InvalidCacheSecurityGroupState
37-
- CacheParameterGroupNotFound
3835
- InvalidKMSKeyFault
39-
- CacheClusterNotFound
4036
fields:
4137
AllowedScaleUpModifications:
4238
is_read_only: true
@@ -94,8 +90,6 @@ resources:
9490
- InvalidParameterValue
9591
- InvalidParameterCombination
9692
- SnapshotAlreadyExistsFault
97-
- CacheClusterNotFound
98-
- ReplicationGroupNotFoundFault
9993
- SnapshotQuotaExceededFault
10094
- SnapshotFeatureNotSupportedFault
10195
fields:
@@ -133,14 +127,16 @@ resources:
133127
custom_method_name: customUpdateCacheParameterGroup
134128
User:
135129
exceptions:
130+
errors:
131+
404:
132+
code: UserNotFound
136133
terminal_codes:
137134
- UserAlreadyExists
138135
- UserQuotaExceeded
139136
- DuplicateUserName
140137
- InvalidParameterValue
141138
- InvalidParameterCombination
142139
- InvalidUserState
143-
- UserNotFound
144140
- DefaultUserAssociatedToUserGroup
145141
fields:
146142
LastRequestedAccessString:
@@ -178,7 +174,6 @@ resources:
178174
- DefaultUserRequired
179175
- UserGroupQuotaExceededFault
180176
- TagQuotaPerResourceExceeded
181-
- UserNotFoundFault
182177
update_operation:
183178
custom_method_name: customUpdateUserGroup
184179
operations:

go.local.mod

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,72 @@
11
module github.com/aws-controllers-k8s/elasticache-controller
22

3-
go 1.14
3+
go 1.17
44

55
replace github.com/aws-controllers-k8s/runtime => ../runtime
66

77
require (
88
github.com/aws-controllers-k8s/runtime v0.0.0-20210204203051-91a6bd53a48c
9-
github.com/aws/aws-sdk-go v1.37.4
10-
github.com/go-logr/logr v0.1.0
11-
github.com/google/go-cmp v0.3.1
9+
github.com/aws/aws-sdk-go v1.42.0
10+
github.com/ghodss/yaml v1.0.0
11+
github.com/go-logr/logr v1.2.0
12+
github.com/google/go-cmp v0.5.5
1213
github.com/pkg/errors v0.9.1
1314
github.com/spf13/pflag v1.0.5
14-
github.com/stretchr/testify v1.5.1
15-
go.uber.org/zap v1.10.0
16-
k8s.io/api v0.18.2
17-
k8s.io/apimachinery v0.18.6
18-
k8s.io/client-go v0.18.2
19-
sigs.k8s.io/controller-runtime v0.6.0
15+
github.com/stretchr/testify v1.7.0
16+
go.uber.org/zap v1.19.1
17+
k8s.io/api v0.23.0
18+
k8s.io/apimachinery v0.23.0
19+
k8s.io/client-go v0.23.0
20+
sigs.k8s.io/controller-runtime v0.11.0
21+
)
22+
23+
require (
24+
github.com/beorn7/perks v1.0.1 // indirect
25+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
26+
github.com/davecgh/go-spew v1.1.1 // indirect
27+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
28+
github.com/fsnotify/fsnotify v1.5.1 // indirect
29+
github.com/go-logr/zapr v1.2.0 // indirect
30+
github.com/gogo/protobuf v1.3.2 // indirect
31+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
32+
github.com/golang/protobuf v1.5.2 // indirect
33+
github.com/google/gofuzz v1.1.0 // indirect
34+
github.com/google/uuid v1.1.2 // indirect
35+
github.com/googleapis/gnostic v0.5.5 // indirect
36+
github.com/imdario/mergo v0.3.12 // indirect
37+
github.com/jaypipes/envutil v1.0.0 // indirect
38+
github.com/jmespath/go-jmespath v0.4.0 // indirect
39+
github.com/json-iterator/go v1.1.12 // indirect
40+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
41+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
42+
github.com/modern-go/reflect2 v1.0.2 // indirect
43+
github.com/pmezard/go-difflib v1.0.0 // indirect
44+
github.com/prometheus/client_golang v1.11.0 // indirect
45+
github.com/prometheus/client_model v0.2.0 // indirect
46+
github.com/prometheus/common v0.28.0 // indirect
47+
github.com/prometheus/procfs v0.6.0 // indirect
48+
github.com/stretchr/objx v0.2.0 // indirect
49+
go.uber.org/atomic v1.7.0 // indirect
50+
go.uber.org/multierr v1.6.0 // indirect
51+
golang.org/x/net v0.0.0-20210825183410-e898025ed96a // indirect
52+
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
53+
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
54+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
55+
golang.org/x/text v0.3.7 // indirect
56+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
57+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
58+
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
59+
google.golang.org/appengine v1.6.7 // indirect
60+
google.golang.org/protobuf v1.27.1 // indirect
61+
gopkg.in/inf.v0 v0.9.1 // indirect
62+
gopkg.in/yaml.v2 v2.4.0 // indirect
63+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
64+
k8s.io/apiextensions-apiserver v0.23.0 // indirect
65+
k8s.io/component-base v0.23.0 // indirect
66+
k8s.io/klog/v2 v2.30.0 // indirect
67+
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
68+
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect
69+
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
70+
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
71+
sigs.k8s.io/yaml v1.3.0 // indirect
2072
)

pkg/resource/replication_group/sdk.go

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/snapshot/sdk.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/user/sdk.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/user_group/sdk.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/tests/test_replicationgroup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_elasticache_resource
2525
from e2e.bootstrap_resources import get_bootstrap_resources
2626
from e2e.util import retrieve_cache_cluster, assert_even_shards_replica_count, retrieve_replication_group, \
27-
assert_terminal_condition_set
27+
assert_recoverable_condition_set
2828

2929
RESOURCE_PLURAL = "replicationgroups"
3030
DEFAULT_WAIT_SECS = 30
@@ -401,13 +401,13 @@ def test_rg_cmd_fromsnapshot(self, rg_cmd_fromsnapshot):
401401
(reference, _) = rg_cmd_fromsnapshot
402402
assert k8s.wait_on_condition(reference, "ACK.ResourceSynced", "True", wait_periods=90)
403403

404-
# if primaryClusterID is a nonexistent node, the terminal condition should be set
404+
# if primaryClusterID is a nonexistent node, the recoverable condition should be set
405405
def test_rg_invalid_primary(self, rg_invalid_primary):
406406
(reference, _) = rg_invalid_primary
407407
sleep(DEFAULT_WAIT_SECS)
408408

409409
resource = k8s.get_resource(reference)
410-
assert_terminal_condition_set(resource)
410+
assert_recoverable_condition_set(resource)
411411

412412
# increase and decrease replica counts per-shard in a CME RG
413413
@pytest.mark.blocked # TODO: remove when passing

test/e2e/util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ def assert_terminal_condition_set(resource):
112112
assert terminal is not None
113113
assert terminal['status'] == "True"
114114

115+
# given the latest state of the resource, assert that the recoverable condition is set
116+
def assert_recoverable_condition_set(resource):
117+
recoverable = None
118+
for cond in resource['status']['conditions']:
119+
if cond['type'] == "ACK.Recoverable":
120+
recoverable = cond
121+
122+
assert recoverable is not None
123+
assert recoverable['status'] == "True"
115124

116125
# provide a basic nodeGroupConfiguration object of desired size
117126
def provide_node_group_configuration(size: int):

0 commit comments

Comments
 (0)