Skip to content

Commit 570bbaa

Browse files
authored
Make FileSystem's field Backup a No-Op (#29)
Issue [#2182](aws-controllers-k8s/community#2182) Description of changes: Backup field is used during creation of an EFS File System, and nowhere else. For Find and Update, the API instead uses a BackupPolicy field. Moving forward the ACK controller will return a Terminal error when the Backup field is defined, and instead we will only be accepting backup configurations through the backupPolicy field. I am choosing sdkFind to return this failure since it's the funtion that is called after each event that happens to a resource. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 0f766ee commit 570bbaa

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ api_directory_checksum: ebeb6f826282ad9134ca78efd74dc9125898fddf
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6
99
generator_config_info:
10-
file_checksum: 04422334db0c3aa480faf9a643b0dd1e4ae05c21
10+
file_checksum: 56ea3e58543a7b3a26ef07a8c2cd6277d59bdf6f
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ controller_name: efs
2626
resources:
2727
FileSystem:
2828
fields:
29+
Backup:
30+
compare:
31+
is_ignored: true
32+
set:
33+
- ignore: all
2934
KMSKeyID:
3035
references:
3136
resource: Key
@@ -61,6 +66,8 @@ resources:
6166
template_path: hooks/file_system/sdk_read_many_post_set_output.go.tpl
6267
sdk_update_pre_build_request:
6368
template_path: hooks/file_system/sdk_update_pre_build_request.go.tpl
69+
sdk_read_many_pre_build_request:
70+
template_path: hooks/file_system/sdk_read_many_pre_build_request.go.tpl
6471
print:
6572
add_age_column: true
6673
add_synced_column: true

generator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ controller_name: efs
2626
resources:
2727
FileSystem:
2828
fields:
29+
Backup:
30+
compare:
31+
is_ignored: true
32+
set:
33+
- ignore: all
2934
KMSKeyID:
3035
references:
3136
resource: Key
@@ -61,6 +66,8 @@ resources:
6166
template_path: hooks/file_system/sdk_read_many_post_set_output.go.tpl
6267
sdk_update_pre_build_request:
6368
template_path: hooks/file_system/sdk_update_pre_build_request.go.tpl
69+
sdk_read_many_pre_build_request:
70+
template_path: hooks/file_system/sdk_read_many_pre_build_request.go.tpl
6471
print:
6572
add_age_column: true
6673
add_synced_column: true

pkg/resource/file_system/delta.go

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

pkg/resource/file_system/hooks.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,17 @@ func (rm *resourceManager) syncBackupPolicy(ctx context.Context, r *resource) (e
242242
exit := rlog.Trace("rm.syncBackupPolicy")
243243
defer func() { exit(err) }()
244244

245+
status := svcsdktypes.StatusDisabled
246+
if r.ko.Spec.BackupPolicy != nil && r.ko.Spec.BackupPolicy.Status != nil {
247+
status = svcsdktypes.Status(*r.ko.Spec.BackupPolicy.Status)
248+
}
249+
245250
_, err = rm.sdkapi.PutBackupPolicy(
246251
ctx,
247252
&svcsdk.PutBackupPolicyInput{
248253
FileSystemId: r.ko.Status.FileSystemID,
249254
BackupPolicy: &svcsdktypes.BackupPolicy{
250-
Status: svcsdktypes.Status(*r.ko.Spec.BackupPolicy.Status),
255+
Status: status,
251256
},
252257
},
253258
)

pkg/resource/file_system/sdk.go

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if r.ko.Spec.Backup != nil {
2+
msg := fmt.Errorf("field Backup is a NO-OP field. Set BackupPolicy.Status instead")
3+
return nil, ackerr.NewTerminalError(msg)
4+
}

0 commit comments

Comments
 (0)