Skip to content

feat: expose image digest on Application#457

Open
ybelMekk wants to merge 10 commits into
mainfrom
feat/container-image-digest
Open

feat: expose image digest on Application#457
ybelMekk wants to merge 10 commits into
mainfrom
feat/container-image-digest

Conversation

@ybelMekk

@ybelMekk ybelMekk commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Exposes ContainerImage.digest directly on Application.image and InstanceGroup.image by reading ContainerStatus.ImageID from running pods via the existing podWatcher cache.

Changes

  • Add digest field to ContainerImage GraphQL type
  • Populate digest on Application.image via new imageDigestForApplication using podWatcher
  • Populate digest on InstanceGroup.image via imageDigestForInstanceGroup
  • Remove unused ctx from ToGraphJobRun and lastRunFailed
  • Refactor unit tests to table-driven style with go-cmp
  • Add integration test for digest on application.image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 exposes container image digests through the existing ContainerImage GraphQL type and wires digest population into workload image fields by extracting digests from pod ImageID values via the shared pod watcher cache.

Changes:

  • Add digest: String to ContainerImage in the GraphQL schema and generated code.
  • Extend workload image parsing/modeling to support digests and more robust tag parsing (incl. registry host:port).
  • Populate image digests for Application, InstanceGroup, and JobRun images using pod watcher-backed lookups; add unit + integration tests.

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/workload/queries.go Switch image node lookup to use the new ContainerImage constructor.
internal/workload/models.go Add digest support to ContainerImage, implement image splitting + digest extraction helpers.
internal/workload/models_test.go Add unit tests for image splitting/digest extraction and container image construction.
internal/workload/job/queries.go Attach per-run image digests (single + batch) by correlating runs to pods.
internal/workload/job/models.go Store/run digest on JobRun and include it in JobRun.Image().
internal/workload/job/dataloader.go Extend job loader context to include the pod watcher.
internal/workload/instancegroup/queries.go Populate instance group image digests by selecting pods for a ReplicaSet.
internal/workload/instancegroup/queries_test.go Add unit test coverage for ReplicaSet pod selector behavior.
internal/workload/instancegroup/models.go Thread imageDigest through InstanceGroup and use it when building ContainerImage.
internal/workload/application/queries.go Populate application image digest by selecting pods via app=<name> label.
internal/workload/application/models.go Improve instance image selection to use the application container (by name) and include digest in Image().
internal/workload/application/models_test.go Add unit test ensuring instance image/digest comes from the application container, not a sidecar.
internal/workload/application/dataloader.go Extend application loader context to include the pod watcher.
internal/thirdparty/promclient/fake/fake_test.go Update test wiring for the new application loader context signature.
internal/issue/checker/workload_lastfailed.go Update ToGraphJobRun call sites to match the new signature.
internal/graph/schema/workloads.graphqls Add digest field to ContainerImage with description.
internal/graph/gengql/workloads.generated.go Generated resolver wiring for ContainerImage.digest.
internal/graph/gengql/root_.generated.go Generated schema/complexity updates to include digest.
internal/cmd/api/http.go Wire pod watcher into application/job loader contexts.
integration_tests/k8s_resources/application_image_digest/dev/myteam/app.yaml Add fixtures for an application pod with an imageID containing a digest.
integration_tests/application_image_digest.lua Add integration test asserting application.image.digest is populated.
Files not reviewed (1)
  • internal/graph/gengql/workloads.generated.go: Language not supported

Comment thread internal/workload/models_test.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/application/queries.go
Comment thread internal/workload/instancegroup/queries.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 21 changed files in this pull request and generated 7 comments.

Files not reviewed (1)
  • internal/graph/gengql/workloads.generated.go: Language not supported

Comment thread internal/workload/instancegroup/queries.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/models_test.go
Comment thread internal/workload/application/queries.go
@ybelMekk ybelMekk changed the title feat: expose image digest on Application and InstanceGroup feat: expose image digest on Application Jun 9, 2026
ybelMekk and others added 10 commits June 9, 2026 09:06
…RunFailed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…via podWatcher

Digest is now available directly on app.image.digest without going
via instances.nodes.image. Source is ContainerStatus.ImageID from
the running pod, resolved through an in-memory podWatcher cache.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…text

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pdate

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
DigestFromPodStatus used containers[0] which could be a Nais-injected
sidecar (e.g. Linkerd), causing the sidecar digest to surface on
Application.image and InstanceGroup.image instead of the app's digest.

Add DigestFromPodStatusByAppName that matches by appName first (per Nais
convention: container name == app/RS name), falling back to any available
digest. Update imageDigestForApplication and imageDigestForInstanceGroup
to use the new function.

Also removes the unnecessary Spec.Containers guard from
imageDigestForInstanceGroup since the function no longer needs the
container spec.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ReplicaSet names include a hash suffix (e.g. myapp-7d9f8b6c5) and do not
match the container name. Use the 'app' label instead, which per Nais
convention matches the container name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…g rollouts

During rollouts, multiple pods with the same app label exist with different
digests. Sorting newest-first ensures Application.image.digest reflects the
target image being rolled out, not an arbitrary pod's digest.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ybelMekk ybelMekk force-pushed the feat/container-image-digest branch from ecb1ce9 to 00ef8fa Compare June 9, 2026 07:06
@ybelMekk ybelMekk marked this pull request as ready for review June 9, 2026 07:07
@ybelMekk ybelMekk requested a review from a team as a code owner June 9, 2026 07:07
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.

2 participants