Skip to content

Commit 283db1d

Browse files
committed
handle autotuneOption progress states
1 parent 5d90142 commit 283db1d

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ack_generate_info:
2-
build_date: "2025-05-01T21:10:59Z"
3-
build_hash: f0e8616acf8e1aabb66c73da53b041f9b4b63679
2+
build_date: "2025-05-02T18:40:01Z"
3+
build_hash: f8dc5330705b3752ce07dce0ac831161fd4cb14f
44
go_version: go1.24.1
5-
version: v0.44.0-4-gf0e8616
5+
version: v0.45.0
66
api_directory_checksum: 13af9d3a7962f45a46b4bedaca965631b194a9a8
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6

pkg/resource/domain/hooks.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package domain
1616
import (
1717
"context"
1818
"errors"
19+
"fmt"
1920
"strings"
2021

2122
"github.com/aws-controllers-k8s/opensearchservice-controller/apis/v1alpha1"
@@ -48,6 +49,22 @@ func domainProcessing(r *resource) bool {
4849
return *r.ko.Status.Processing
4950
}
5051

52+
func isAutoTuneOptionReady(autoTuneOption *svcsdktypes.AutoTuneOptionsOutput) (bool, error) {
53+
switch autoTuneOption.State {
54+
case svcsdktypes.AutoTuneStateEnabled, svcsdktypes.AutoTuneStateDisabled:
55+
return true, nil
56+
57+
case svcsdktypes.AutoTuneStateError:
58+
if autoTuneOption.ErrorMessage != nil {
59+
return false, fmt.Errorf("error: %s", *autoTuneOption.ErrorMessage)
60+
}
61+
return false, fmt.Errorf("there is an error when updating AutoTuneOptions")
62+
63+
default:
64+
return false, nil
65+
}
66+
}
67+
5168
// isAutoTuneSupported returns true if instance type supports AutoTune
5269
// https://docs.aws.amazon.com/opensearch-service/latest/developerguide/supported-instance-types.html
5370
func isAutoTuneSupported(r *resource) bool {

pkg/resource/domain/sdk.go

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

templates/hooks/domain/sdk_read_one_post_set_output.go.tpl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
if resp.DomainStatus.AutoTuneOptions != nil {
2-
if resp.DomainStatus.AutoTuneOptions.State == svcsdktypes.AutoTuneStateError && !isAutoTuneSupported(&resource{ko}) {
3-
// t2,t3 instances does not support AutoTuneOptions.DesiredState: DISABLED
4-
// set value manually to remove delta
5-
ko.Spec.AutoTuneOptions.DesiredState = aws.String(string(svcsdktypes.AutoTuneStateDisabled))
6-
} else {
7-
ko.Spec.AutoTuneOptions.DesiredState = aws.String(string(resp.DomainStatus.AutoTuneOptions.State))
2+
if ready, err := isAutoTuneOptionReady(resp.DomainStatus.AutoTuneOptions); err != nil {
3+
return latest, ackrequeue.Needed(err)
4+
} else if !ready {
5+
return latest, ackrequeue.Needed(fmt.Errorf("waiting for AutotuneOptions to sync. Current state: ", resp.DomainStatus.AutoTuneOptions.State))
86
}
7+
ko.Spec.AutoTuneOptions.DesiredState = aws.String(string(resp.DomainStatus.AutoTuneOptions.State))
98
}
109

1110
if domainProcessing(&resource{ko}) {

0 commit comments

Comments
 (0)