-
Notifications
You must be signed in to change notification settings - Fork 4k
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
appconfig: Constrain environments to a single deployment at a time #29345
appconfig: Constrain environments to a single deployment at a time #29345
Comments
Thank you for your feedback. This LGTM but we'll discuss with the team this week. |
Thanks! In the meantime, here's the simplified (single-env) workaround we were looking at when considering the migration to L2 constructs. // The L2 constructs currently create every deployment in isolation.
// This means that deploying >1 config to the same env will fail, as simultaneous deployments are not allowed.
// To avoid this, we locate the underlying deployment object and create a dependency on the prior one.
// This approach is simplified for the single-env use case, and as such only uses a single queue.
const deploymentQueue: Array<CfnDeployment> = [];
hostedConfigurations.forEach((namedConfigurationOptions) =>
mainApp
.addHostedConfiguration(
`HC-${namedConfigurationOptions.name}`,
{
deployTo: [mainEnv],
deploymentStrategy,
...namedConfigurationOptions,
}
)
.node.children.forEach((child) => {
if (child instanceof CfnDeployment) {
deploymentQueue.push(child);
}
})
);
for (let i = 1; i < deploymentQueue.length; i += 1) {
deploymentQueue[i].addDependency(deploymentQueue[i - 1]);
} |
Hi @M-Hawkins, have you tried adding dependencies on the configs so only one is created at a time?
|
Hello, while that might* work for my simplified use case, it is not something I'd want to encourage in general. To put it another way - it is inaccurate to say that there is a dependency between the Configurations. *I would need to test your suggestion, it might not even work. |
Hello @M-Hawkins thanks for raising this issue. Your proposed solution looks good to me in general. I just have a few questions:
|
Hello @xazhao Today the |
If the current public abstract name: string | undefined;
protected deploymentQueue: Array<CfnDeployment> = [];
public addDeployment(configuration: IConfiguration): void {
const queueSize = this.deploymentQueue.push(new CfnDeployment(configuration, `Deployment${getHash(this.name!)}`, {
...
} |
Hi @M-Hawkins, thanks for the detailed proposal and answering questions. It would be great if it doesn't incur a breaking change for current users. However, even if it does, we can work on wrapping everything inside feature flags. I love the solution you provided so feel free to come up with a PR and we can get more detailed reviews on the PR. |
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
Hello @GavinZZ , I've opened a pull request now, pending reviewer assignment. |
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
Hello again, it's been a few weeks since my PR received community review and approval. |
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
[Issue aws#29345] ------------------------------------------------------------------------ [Reason for this change] ------------------------------------------------------------------------ The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. [Description of changes] ------------------------------------------------------------------------ This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. [Description of how you validated changes] ------------------------------------------------------------------------ Added new unit test coverage.
…ime (#29500) ### Issue # (if applicable) Closes #29345. ### Reason for this change The current L2 AppConfig constructs do not have any guardrails that prevent simultaneous Deployments to a single Environment. This is not allowed, and will result in Cfn deploy-time conflicts. ### Description of changes This commit adds a pair of new public methods to IEnvironment that enable the addition of a new Deployment for a given IConfiguration. It then updates the creation of new Deployments in ConfigurationBase to utilize these new methods instead of the current resource creation. These new methods interact with an internal queue. This queue creates a chain of Cfn dependencies between Deployments in order to enforce that only a single Deployment can be in progress for the Environment at any given time. ### Description of how you validated changes Added new unit and integ test coverage. Deployed the new integ test without these changes and confirmed that Cfn failed at deployment time. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe the feature
Summary
The current L2 constructs make it easy to create Cfn deploy-time conflicts. They do not expose any mechanisms to resolve concurrent deployment without leveraging escape hatches or ignoring the L2 methods in favor of manual L1 deployments.
Context
AppConfig requires that its resources are deployed in a particular order:
The last of these is modeled as CfnDeployment, and consists of:
The Problem
With the newly added L2 constructs, the creation of deployments is owned by the Configuration (both Hosted and Shared use the same base class implementation).
This creates a problem, as no individual Configuration is aware of another.
If more than one Configuration intends to deploy to the same Environment, they will attempt to do so at the same time, resulting in a Cfn failure.
Per the AppConfig docs:
In other words, this extension of the basic use case will fail to deploy:
Use Case
It is common and expected for an AppConfig Environment to host more than one Configuration.
The current behavior makes it impossible to rely solely on the L2 constructs and impacts our adoption of them.
Proposed Solution
Migrate the ownership and creation of
CfnDeployment
from Configuration to Environment.Then, Cfn dependencies can be created whenever a new
CfnDeployment
is added, such that each deployment depends on the previous one.This will ensure that only one
CfnDeployment
is in progress at any given point in time, avoiding deploy-time conflicts.Prototype solution
In
environment.ts
, first expose new functionality forIEnvironment
.Then, implement this new functionality as a part of
EnvironmentBase
.Then, change the existing internal helper in
configuration.ts
to utilize this function instead.Other Information
No response
Acknowledgements
CDK version used
2.130.0
Environment details (OS name and version, etc.)
Various Linux
The text was updated successfully, but these errors were encountered: