Skip to content

Refactor Update ECS command#1956

Open
sathvikkumar-octo wants to merge 8 commits into
mainfrom
sk/update-ecs-spf-migration
Open

Refactor Update ECS command#1956
sathvikkumar-octo wants to merge 8 commits into
mainfrom
sk/update-ecs-spf-migration

Conversation

@sathvikkumar-octo
Copy link
Copy Markdown
Contributor

@sathvikkumar-octo sathvikkumar-octo commented May 20, 2026

This PR reworks the Update ECS step to resolve issues we are seeing in production

The main changes are:

  • Wait options are a JSON object
  • Container image lookup now happens on the Calamari side
  • Use the shared contracts.

Ref MD-1890

@Jtango18
Copy link
Copy Markdown
Contributor

Comment thread source/Calamari.Contracts/Serialization/CalamariContractsSerializerSettings.cs Outdated
Comment thread source/Calamari.Contracts/Calamari.Contracts.csproj Outdated
Comment thread source/Calamari.Aws/Commands/UpdateEcsServiceCommand.cs Outdated
Comment thread source/Calamari.Aws/Commands/UpdateEcsServiceCommand.cs Outdated
if (!string.IsNullOrWhiteSpace(update.PackageReference))
{
containerToUpdate.Image = containerUpdate.Image;
var image = variables.Get(PackageVariables.IndexedImage(update.PackageReference));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new way of handling container images works well and resolves this bug

OctopusDeploy/Issues#10033

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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this field name as its not strictly an image but a key used to lookup the package reference variable

@sathvikkumar-octo
Copy link
Copy Markdown
Contributor Author

@sathvikkumar-octo sathvikkumar-octo marked this pull request as ready for review May 21, 2026 05:35
@sathvikkumar-octo sathvikkumar-octo requested a review from Copilot May 21, 2026 05:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (TimeoutTimeSpan?).
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 ContainerDefinitionContainerSpec.
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.

Comment thread source/Calamari.Aws/Commands/UpdateEcsServiceCommand.cs
Comment thread source/Calamari.Tests/AWS/Ecs/Update/UpdateEcsServiceFixture.cs
Comment thread source/Calamari.Tests/AWS/Ecs/Update/UpdateEcsServiceFixture.cs Outdated
Comment thread source/Calamari.Aws/Integration/Ecs/EcsPostDeployWatcher.cs
Comment thread source/Calamari.Contracts/Aws/Ecs/WaitOption.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants