Repository navigation
engine/serviceconnect: read image digest from metadata json - #5006
Merged
Merged
Conversation
nade007
force-pushed
the
sc-sidecar-image-digest
branch
from
June 12, 2026 01:46
a46f409 to
bc9dacd
Compare
nade007
marked this pull request as ready for review
June 12, 2026 02:58
singholt
previously approved these changes
Jun 15, 2026
nade007
force-pushed
the
sc-sidecar-image-digest
branch
from
June 15, 2026 18:30
bc9dacd to
be8379a
Compare
singholt
approved these changes
Jun 15, 2026
mye956
reviewed
Jun 15, 2026
mye956
reviewed
Jun 15, 2026
mye956
reviewed
Jun 15, 2026
mye956
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Service Connect sidecar container is loaded from a tarball at
/managed-agents/serviceconnect/ecs-service-connect-agent.interface-v1.tar. Because it never gets pulled from a registry, Docker has noRepoDigestsfor it, so the agent reports an emptyImageDigestinSubmitContainerStateChange. This means consumers downstream to the ECS controlplane cannot consume them.This change makes the agent read a sidecar JSON file at
/managed-agents/serviceconnect/ecs-service-connect-agent.interface-v1.metadata.jsoncontaining{"schemaVersion":1,"digest":"sha256:..."}, cache the digest on the manager struct atLoadImagetime, and stamp it on the SC container inaugmentAgentContainer. The existing state change pipeline carries it the rest of the way to control plane.The metadata.json is shipped by the SC RPM (the file is produced upstream in the SC release pipeline that pushes the image to ECR, captured via
docker inspect --format '{{index .RepoDigests 0}}'right after pull, and bundled into the RPM next to the tarball).Implementation details
manager.go: one new method on the interface,GetLoadedImageDigest() string.manager_linux.go: a constant for the metadata path, a struct fieldappnetImageDigest, a helperreadLoadedImageDigestwith graceful failure, the call site inLoadImage, the public getter, and theSetImageDigestcall insideaugmentAgentContainer.manager_other.go: a no-op stub returning""for non-Linux. SC is Linux only anyway.mock/manager.go: gomock entries for the new method (manually edited to match whatmockgenwould produce, the existinggo:generatedirective ingenerate_mocks.goregenerates it identically).manager_linux_test.go: two new tests covering the read fn (4 subcases including missing file and malformed JSON) and the augment plumbing (digest set when present, untouched when empty).Backward compatibility
If the file is absent (older RPM that predates this work), malformed, or has an empty
digestfield,readLoadedImageDigestlogs a warning and returns"". Theif d != ""guard inaugmentAgentContainerthen skips theSetImageDigestcall entirely. SC sidecar still launches normally, just with empty digest, which is the existing behavior on those AMIs.The metadata file is consumer-facing but optional. Agent works the same as today on hosts that don't have it.
Testing
Unit tests:
TestReadLoadedImageDigestcovers the four shapes of metadata.json (valid, missing, malformed, empty digest field).TestAugmentTaskContainerSetsImageDigestverifies the plumbing both when the manager has a cached digest and when it doesn't.go test -tags "linux unit" ./engine/serviceconnect/...).go build ./...clean across the whole agent module.gofmt,go vetclean.End to end on a real EC2:
1. Install the SC RPM that ships metadata.json alongside the tarball on a fresh
amazon-ecs-optimized-amazon-linux-2AMI host. After install,/var/lib/ecs/deps/serviceconnect/contains the tar, the metadata.json ({"schemaVersion":1,"digest":"sha256:..."}), and theecs-service-connect-agent.tarsymlink.2. Build the patched agent with the linker flags the release pipeline uses. Without these the binary panics at startup because
DefaultPauseContainerImageNameandDefaultPauseContainerTagare blank:3. Swap the agent binary on EC2.
4. Agent log on first load confirms the new
appnetImageDigestfield is populated, matching whatdocker inspect --format '{{index .RepoDigests 0}}'returns for the same tag in ECR:5. Launch a real SC-enabled task. Once the task transitions to RUNNING:
The SC sidecar reports the registry manifest digest from metadata.json end to end through the agent into the ECS API.
With metadata.json present (sidecar shipped by current RPM):
Without metadata.json (older RPM):
New tests cover the changes: yes
Description for the changelog
Enhancement - Populate ImageDigest for Service Connect sidecar containers.
Additional Information
Does this PR include breaking model changes? If so, Have you added transformation functions?
No
Does this PR include the addition of new environment variables in the README?
No
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.