From 7c7530f977d2b9361e290a7eb38e642ad81aa7a3 Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Thu, 27 Mar 2025 14:12:20 +1000 Subject: [PATCH] chore: add comments and TODOs about the disabled image digest resolver --- pkg/api/service.go | 10 ++++++---- pkg/client/deploy/resolver.go | 8 ++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/api/service.go b/pkg/api/service.go index 7623b0cc..449753c4 100644 --- a/pkg/api/service.go +++ b/pkg/api/service.go @@ -17,14 +17,16 @@ const ( ServiceModeReplicated = "replicated" ServiceModeGlobal = "global" - // PullPolicyAlways means the latest image is always pulled from the registry. + // PullPolicyAlways means the image is always pulled from the registry. PullPolicyAlways = "always" - // PullPolicyMissing means the latest image is pulled from the registry only if it's not available in the cluster - // (missing on all machines). If the image is available on any machine, its registry digest is used which may result - // in pulling the image on machines where it's not available. This is the default pull policy. + // PullPolicyMissing means the image is pulled from the registry only if it's not available on the machine where + // a container is started. This is the default pull policy. + // TODO: make each machine aware of the images on other machines and it possible to pull from them. + // Pull from the registry only if the image is missing on all machines. PullPolicyMissing = "missing" // PullPolicyNever means the image is never pulled from the registry. A service with this pull policy can only be // deployed to machines where the image is already available. + // TODO: see the TODO above for PullPolicyMissing. Pull from other machines in the cluster if available. PullPolicyNever = "never" ) diff --git a/pkg/client/deploy/resolver.go b/pkg/client/deploy/resolver.go index 7dfdbb57..e3fd4e12 100644 --- a/pkg/client/deploy/resolver.go +++ b/pkg/client/deploy/resolver.go @@ -151,6 +151,14 @@ type ImageDigestResolver struct { Client ImageResolverClient } +// Resolve resolves the image to the image with the digest according to the pull policy: +// - always: Fetch the latest digest for the image tag in the registry. +// - missing: Find the latest image matching the tag on any machine and use its digest, if it exists. +// When there is no matching image on any machine, it behaves like 'always'. +// - never: !Not implemented! Similar to 'missing' but when there is no matching image on any machine, +// it returns an error. +// +// If the image is already pinned to a digest, it is returned as is. func (r *ImageDigestResolver) Resolve(image, policy string) (string, error) { if r.Ctx == nil { r.Ctx = context.Background()