Refactor Update ECS command#1956
Conversation
| if (!string.IsNullOrWhiteSpace(update.PackageReference)) | ||
| { | ||
| containerToUpdate.Image = containerUpdate.Image; | ||
| var image = variables.Get(PackageVariables.IndexedImage(update.PackageReference)); |
There was a problem hiding this comment.
This new way of handling container images works well and resolves this bug
This bug was caused by having nested Octostache as the previous container image handling wrapped any SPF value in an Octostache expression of its own
| namespace Octopus.Calamari.Contracts.Aws.Ecs; | ||
|
|
||
| public record ContainerDefinition | ||
| public record ContainerSpec |
There was a problem hiding this comment.
Renamed this type to avoid clashes with AWS SDK types
| { | ||
| public string ContainerName { get; init; } = string.Empty; | ||
| public string? Image { get; init; } | ||
| public string? PackageReference { get; init; } |
There was a problem hiding this comment.
Changed this field name as its not strictly an image but a key used to lookup the package reference variable
There was a problem hiding this comment.
Pull request overview
This PR refactors the Update ECS workflow to use shared contract types and move image selection to Calamari (via package image variables), while also changing wait options from flat variables to a single JSON object. This aligns Update ECS with the direction of the Deploy ECS rework and is intended to address production issues.
Changes:
- Update ECS inputs now use shared contract types (
ContainerUpdate,WaitOption, etc.) and new variable keys (e.g.,Octopus.Action.Aws.Ecs.Update.*,Octopus.Action.Aws.Ecs.WaitOption). - Container images are now resolved from
PackageVariables.IndexedImage(packageReference)inside Calamari rather than being passed as raw image strings. - Contract JSON serialization settings were updated to include string-enum support.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| source/Calamari.Tests/AWS/Ecs/Update/UpdateEcsServiceFixture.cs | Updates Update ECS integration test to use new contract inputs (package references + wait option object). |
| source/Calamari.Tests/AWS/Ecs/RegisterTaskDefinitionRequestFactoryTests.cs | Updates tests to use ContainerUpdate + package image lookup; adds coverage for “preserve existing image” scenarios. |
| source/Calamari.Tests/AWS/Ecs/EcsPostDeployWatcherTests.cs | Updates watcher tests to use WaitOption/WaitType contract. |
| source/Calamari.Tests/AWS/Ecs/DeployEcsServiceFixture.cs | Keeps Deploy ECS fixture on legacy wait-option keys while Update ECS migrates. |
| source/Calamari.Contracts/Aws/Ecs/WaitOption.cs | Introduces contract wait option parsing (Timeout → TimeSpan?). |
| source/Calamari.Contracts/Aws/Ecs/ContainerUpdate.cs | Changes container update contract from Image to PackageReference. |
| source/Calamari.Contracts/Aws/Ecs/ContainerSpec.cs | Renames contract type ContainerDefinition → ContainerSpec. |
| source/Calamari.Common/Plumbing/Variables/CalamariContractSerializationSettings.cs | Adds StringEnumConverter to contract serialization settings. |
| source/Calamari.Aws/Integration/Ecs/WaitOptionType.cs | Removes old internal wait option enum. |
| source/Calamari.Aws/Integration/Ecs/RegisterTaskDefinitionRequestFactory.cs | Uses contract ContainerUpdate and resolves images via package variables. |
| source/Calamari.Aws/Integration/Ecs/EnvVarItem.cs | Removes old env var item model (replaced by contract types). |
| source/Calamari.Aws/Integration/Ecs/EnvAction.cs | Removes old env action model (replaced by contract types). |
| source/Calamari.Aws/Integration/Ecs/EcsPostDeployWatcher.cs | Switches watcher to contract WaitOption and parses timeout via GetTimeoutSpan(). |
| source/Calamari.Aws/Integration/Ecs/EcsContainerUpdate.cs | Removes old container update model (replaced by contract types). |
| source/Calamari.Aws/Deployment/Conventions/UpdateEcsServiceConvention.cs | Wires new contract inputs into task definition registration + watcher. |
| source/Calamari.Aws/Deployment/AwsSpecialVariables.cs | Introduces new Update ECS variable keys and a JSON wait-option key; preserves legacy deploy wait keys separately. |
| source/Calamari.Aws/Commands/UpdateEcsServiceCommand.cs | Reads new Update ECS inputs (contracts + JSON variables), including new tag/wait option handling. |
| source/Calamari.Aws/Commands/DeployEcsServiceCommand.cs | Updates Deploy ECS to use WaitOptionLegacy.* keys after variable key refactor. |
| source/Calamari.Aws/Calamari.Aws.csproj | Adds reference to Calamari.Contracts for shared ECS contracts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR reworks the Update ECS step to resolve issues we are seeing in production
The main changes are:
Ref MD-1890