Skip to content

Commit edcfbb7

Browse files
authored
Set default cluster UpgradePolicy is not provided (#138)
Description of changes: Currently, when a cluster has been created with an older eks controller, and tries to reconcile with a new one, UpgradePolicy is set to nil, and panics with nulll pointer exception during updateClusterUpgradePolicy operation. As a fix, I am considering setting the upgradePolicy to the value that is retured from AWS to ensure user's preset option is maintained. This change will not change the customer's spec, until the users deside to define/add the field themselves. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 28660a7 commit edcfbb7

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2024-10-17T18:27:35Z"
2+
build_date: "2024-10-21T22:52:48Z"
33
build_hash: ab15f9206796e9660c51695fab0ff07a09ea28e2
44
go_version: go1.23.2
55
version: v0.39.1-2-gab15f92
66
api_directory_checksum: 4cfe0b6ec81b65719c1f165983b84116135f5e40
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.55.5
99
generator_config_info:
10-
file_checksum: 5b5c72cb103e99a0dd19beffb8863f16e4fd163e
10+
file_checksum: 6c1343508adb97d2a4ff6f8328b2668356317b3b
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ resources:
195195
- MissingParameter
196196
- ValidationError
197197
hooks:
198+
delta_pre_compare:
199+
code: customPreCompare(a, b)
198200
sdk_create_post_set_output:
199201
template_path: hooks/cluster/sdk_create_post_set_output.go.tpl
200202
sdk_read_one_post_set_output:

generator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ resources:
195195
- MissingParameter
196196
- ValidationError
197197
hooks:
198+
delta_pre_compare:
199+
code: customPreCompare(a, b)
198200
sdk_create_post_set_output:
199201
template_path: hooks/cluster/sdk_create_post_set_output.go.tpl
200202
sdk_read_one_post_set_output:

pkg/resource/cluster/delta.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/cluster/hook.go

+9
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ func (rm *resourceManager) clusterInUse(ctx context.Context, r *resource) (bool,
160160
return (nodes != nil && len(nodes.Nodegroups) > 0), nil
161161
}
162162

163+
func customPreCompare(
164+
a *resource,
165+
b *resource,
166+
) {
167+
if a.ko.Spec.UpgradePolicy == nil && b.ko.Spec.UpgradePolicy != nil {
168+
a.ko.Spec.UpgradePolicy = b.ko.Spec.UpgradePolicy.DeepCopy()
169+
}
170+
}
171+
163172
func (rm *resourceManager) customUpdate(
164173
ctx context.Context,
165174
desired *resource,

0 commit comments

Comments
 (0)