-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(opensearchservice): L2 properties for offPeakWindowOptions and softwareUpdateOptions #26403
Conversation
…oftwareUpdateOptions properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good @lpizzinidev! Just a couple comments about defaults
* Options for a domain's off-peak window, during which OpenSearch Service can perform mandatory | ||
* configuration changes on the domain. | ||
*/ | ||
readonly offPeakWindowOptions?: OffPeakWindowOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifically the default for this prop may be confusing. looks like the default should be that it is configured by default and cannot be turned off, but still, what will the default window be?
Off-peak windows were introduced on February 16, 2023. All domains created before this date have the off-peak window disabled by default. You must manually enable and configure the off-peak window for these domains. All domains created after this date will have the off-peak window enabled by default. You can't disable the off-peak window for a domain after it's enabled.
https://docs.aws.amazon.com/opensearch-service/latest/developerguide/off-peak.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defaulted it to 00:00 UTC
If you don't specify a custom window start time, it defaults to 00:00 UTC.
https://docs.aws.amazon.com/opensearch-service/latest/developerguide/off-peak.html (in Enabling the off-peak window > CLI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lpizzinidev, a couple more comments
/** | ||
* Options for configuring service software updates for a domain. | ||
*/ | ||
export interface SoftwareUpdateOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think we need an interface for this, lets default to a flatter API. Think we should just expose a boolean enableAutoSoftwareUpdate
export interface OffPeakWindowOptions { | ||
/** | ||
* Specifies whether off-peak window settings are enabled for the domain. | ||
* | ||
* @default - true | ||
*/ | ||
readonly enabled?: boolean; | ||
|
||
/** | ||
* Off-peak window settings for the domain. | ||
* | ||
* @default - default window start time is 00:00 UTC | ||
*/ | ||
readonly offPeakWindow?: OffPeakWindow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this to be an interface either. We should be able to get away with just offPeakWindow?: OffPeakWindow
. If its specified, users probably want it to be enabled as well. In general I like to default to a single prop rather than specifying interfaces.
@@ -1558,6 +1632,23 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { | |||
} | |||
} | |||
|
|||
let offPeakWindowOptions: OffPeakWindowOptions = { | |||
enabled: props.offPeakWindowOptions?.enabled ?? true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All domains created before this date have the off-peak window disabled by default.
So we can't just default to true here, as that will represent a behavior change to existing domains. Rather, without setting offPeakWindow
(i.e. offPeakWindow: undefined
) what we have to do is document the service-level behavior (enabled post 2/16/23, disabled prior). Then, we just pass undefined
into the L1 and let the service handle the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies @lpizzinidev I feel like I've been giving you half-baked reviews on this PR. But this last little redesign should be enough I think. Thanks for the quick turnarounds.
* You can't disable the off-peak window for a domain after it's enabled. | ||
* | ||
* @see https://docs.aws.amazon.com/it_it/AWSCloudFormation/latest/UserGuide/aws-properties-opensearchservice-domain-offpeakwindow.html | ||
* @default - no off-peak window will be configured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @default - no off-peak window will be configured | |
* @default - disabled for domains created before February 16, 2023. enabled for domains created after. |
offPeakWindowOptions: props.offPeakWindow ? { | ||
enabled: true, | ||
offPeakWindow: { | ||
windowStartTime: props.offPeakWindow.windowStartTime ?? { | ||
hours: 22, | ||
minutes: 0, | ||
}, | ||
}, | ||
} : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the reason why I'm not in love with this API yet is because to specify offPeakWindow with the given defaults we have to do:
offPeakWindow: {},
That's not very intuitive. Which now makes me understand why enabled
was a prop in the first place :). Still, though, this potential experience to get the default window isn't great either:
offPeakWindow: {
enabled: true,
},
It feels weird to supply an object with just a boolean prop. So I suggest we do the following:
offPeakWindowEnabled: true,
// if people want to customize the window
// offPeakWindowStart: {
// hours: 22,
// minutes: 0,
// },
I think having two separate properties on the base construct is the way to go and what we've generally done in the past for similar situations.
Of course, the default for offPeakWindowEnabled
is true if offPeakWindowStart is set, false otherwise
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lpizzinidev! Just added one last thing that allows offPeakWindowEnabled
to be omitted if you specify offPeakWindowStart
. Thanks for the contribution!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
The
OffPeakWindowOptions
andSoftwareUpdateOptions
are supported by OpenSearch Domain, but not by the CDK high-level construct.This change adds the corresponding properties to the
Domain
construct:Closes #26388.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license