Skip to content

Commit c26c934

Browse files
committed
mitigate runtime panic when adopting cluster
1 parent a9fe5b9 commit c26c934

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ack_generate_info:
2-
build_date: "2024-09-19T16:42:31Z"
2+
build_date: "2024-09-30T17:24:49Z"
33
build_hash: f8f98563404066ac3340db0a049d2e530e5c51cc
44
go_version: go1.23.0
55
version: v0.38.1

pkg/resource/cluster/hook.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ func (rm *resourceManager) customUpdate(
192192
return updatedRes, requeueWaitUntilCanModify(latest)
193193
}
194194

195-
if delta.DifferentAt("Spec.Tags") {
195+
// Ensure ACKResourceMetadata and ARN are not nil before derefrencing
196+
// This can occur when adopting a resource
197+
if delta.DifferentAt("Spec.Tags") && desired.ko.Status.ACKResourceMetadata != nil && desired.ko.Status.ACKResourceMetadata.ARN != nil {
196198
if err := tags.SyncTags(
197199
ctx, rm.sdkapi, rm.metrics,
198200
string(*desired.ko.Status.ACKResourceMetadata.ARN),

pkg/resource/cluster/sdk.go

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

templates/hooks/cluster/sdk_read_one_post_set_output.go.tpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
if r.ko.Spec.ResourcesVPCConfig.SubnetRefs != nil {
1+
if r.ko.Spec.ResourcesVPCConfig != nil && r.ko.Spec.ResourcesVPCConfig.SubnetRefs != nil {
22
ko.Spec.ResourcesVPCConfig.SubnetRefs = r.ko.Spec.ResourcesVPCConfig.SubnetRefs
33
}
44

5-
if r.ko.Spec.ResourcesVPCConfig.SecurityGroupRefs != nil {
5+
if r.ko.Spec.ResourcesVPCConfig != nil && r.ko.Spec.ResourcesVPCConfig.SecurityGroupRefs != nil {
66
ko.Spec.ResourcesVPCConfig.SecurityGroupRefs = r.ko.Spec.ResourcesVPCConfig.SecurityGroupRefs
77
}
88

0 commit comments

Comments
 (0)