Skip to content

Modern Docker Management, Designed for Everyone

fix: stop checking Arcane-built local images against a registry

Kyle Mendell8d10b7db2d34
diff --git a/backend/internal/imageupdate/image_update.go b/backend/internal/imageupdate/image_update.go
index 8e07ae324..afe6c1b87 100644
--- a/backend/internal/imageupdate/image_update.go
+++ b/backend/internal/imageupdate/image_update.go
@@ -414,6 +414,15 @@ func digestPinnedImageUpdateResultInternal(imageRef string) mo.Option[*imageupda
})
}
+func isLocalBuildImageRefInternal(imageRef string, composeBuildRefs map[string]struct{}) bool {
+ if named, err := ref.ParseNormalizedNamed(strings.TrimSpace(imageRef)); err == nil &&
+ registryauth.NormalizeRegistryForComparison(ref.Domain(named)) == imageref.LocalBuildRegistry {
+ return true
+ }
+ _, ok := composeBuildRefs[refs.NormalizeImageUpdateRef(imageRef)]
+ return ok
+}
+
func (s *ImageUpdateService) checkDigestUpdateWithSnapshotInternal(ctx context.Context, parts *ImageParts, composeBuildRefs map[string]struct{}) (*imageupdate.Response, *localImageSnapshot, error) {
if s.registryService == nil {
return nil, nil, errors.New("registry service unavailable")
@@ -425,10 +434,8 @@ func (s *ImageUpdateService) checkDigestUpdateWithSnapshotInternal(ctx context.C
if err == nil && snapshot.IsLocalBuild {
return localBuildImageUpdateResultInternal(snapshot, int(time.Since(start).Milliseconds())), snapshot, nil
}
- if err != nil && cerrdefs.IsNotFound(err) {
- if _, isComposeBuild := composeBuildRefs[refs.NormalizeImageUpdateRef(imageRef)]; isComposeBuild {
- return missingLocalBuildImageUpdateResultInternal(parts.Tag, int(time.Since(start).Milliseconds())), nil, nil
- }
+ if err != nil && cerrdefs.IsNotFound(err) && isLocalBuildImageRefInternal(imageRef, composeBuildRefs) {
+ return missingLocalBuildImageUpdateResultInternal(parts.Tag, int(time.Since(start).Milliseconds())), nil, nil
}
registryCtx, registryCancel := s.registryContextInternal(ctx)
@@ -868,10 +875,7 @@ func (s *ImageUpdateService) inspectLocalImageSnapshotInternal(ctx context.Conte
primaryDigest = inspectResponse.ID
allDigests = []string{primaryDigest}
}
- if normalizedRef := refs.NormalizeImageUpdateRef(imageRef); normalizedRef != "" {
- _, isComposeBuild := composeBuildRefs[normalizedRef]
- isLocalBuild = isLocalBuild || isComposeBuild
- }
+ isLocalBuild = isLocalBuild || isLocalBuildImageRefInternal(imageRef, composeBuildRefs)
repo, tag := extractRepoAndTagFromImage(inspectResponse.InspectResponse)
tag = tagWithFallbackInternal(tag, s.parseImageReference(imageRef))
@@ -1337,10 +1341,8 @@ func (s *ImageUpdateService) checkSingleImageInBatchInternal(ctx context.Context
if ldErr == nil && snapshot.IsLocalBuild {
return localBuildImageUpdateResultInternal(snapshot, int(time.Since(start).Milliseconds())), snapshot
}
- if ldErr != nil && cerrdefs.IsNotFound(ldErr) {
- if _, isComposeBuild := composeBuildRefs[refs.NormalizeImageUpdateRef(imageRef)]; isComposeBuild {
- return missingLocalBuildImageUpdateResultInternal(parts.Tag, int(time.Since(start).Milliseconds())), nil
- }
+ if ldErr != nil && cerrdefs.IsNotFound(ldErr) && isLocalBuildImageRefInternal(imageRef, composeBuildRefs) {
+ return missingLocalBuildImageUpdateResultInternal(parts.Tag, int(time.Since(start).Milliseconds())), nil
}
registryCtx, registryCancel := s.registryContextInternal(ctx)
diff --git a/backend/internal/imageupdate/service_test.go b/backend/internal/imageupdate/service_test.go
index a31914d5f..3f8cb986a 100644
--- a/backend/internal/imageupdate/service_test.go
+++ b/backend/internal/imageupdate/service_test.go
@@ -534,6 +534,92 @@ func TestImageUpdateService_CheckMultipleImages_ComposeBuildMissingLocallySkipsR
assert.Zero(t, registryCalls.Load())
}
+func newArcaneLocalImageUpdateServiceInternal(t *testing.T, imageExists bool) (*ImageUpdateService, *atomic.Int32) {
+ t.Helper()
+
+ db := setupImageUpdateTestDB(t)
+ localDigest := digest.FromString("arcane-local-build").String()
+ dockerServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if imageExists && strings.Contains(r.URL.Path, "/images/") && strings.HasSuffix(r.URL.Path, "/json") {
+ w.Header().Set("Content-Type", "application/json")
+ assert.NoError(t, json.NewEncoder(w).Encode(dockertypesimage.InspectResponse{
+ ID: "sha256:arcane-local-image-id",
+ RepoTags: []string{"arcane.local/demo-2ab41b29/worker:latest"},
+ RepoDigests: []string{"arcane.local/demo-2ab41b29/worker@" + localDigest},
+ }))
+ return
+ }
+ http.Error(w, "No such image", http.StatusNotFound)
+ }))
+ t.Cleanup(dockerServer.Close)
+
+ var registryCalls atomic.Int32
+ registryService := registry.NewContainerRegistryService(db, func(context.Context) (registry.RegistryDaemonClient, error) {
+ return &fakeRegistryDaemonClient{
+ distributionInspectFn: func(context.Context, string, client.DistributionInspectOptions) (client.DistributionInspectResult, error) {
+ registryCalls.Add(1)
+ return client.DistributionInspectResult{
+ Descriptor: ocispec.Descriptor{Digest: digest.FromString("arcane-local-remote")},
+ }, nil
+ },
+ }, nil
+ }, nil)
+
+ dockerService := &docker.DockerClientService{Client: newImageUpdateTestDockerClientInternal(t, dockerServer)}
+ eventService := event.NewEventService(db, nil, nil)
+ return NewImageUpdateService(db, nil, registryService, dockerService, eventService, nil, nil), &registryCalls
+}
+
+func TestImageUpdateService_CheckImageUpdate_ArcaneLocalHostSkipsRegistry(t *testing.T) {
+ svc, registryCalls := newArcaneLocalImageUpdateServiceInternal(t, true)
+ staleError := "failed to get remote digest"
+ require.NoError(t, svc.db.Create(&ImageUpdateRecord{
+ ID: "sha256:arcane-local-image-id",
+ Repository: "arcane.local/demo-2ab41b29/worker",
+ Tag: "latest",
+ LastError: &staleError,
+ CheckTime: time.Now(),
+ }).Error)
+
+ result, err := svc.CheckImageUpdate(context.Background(), "arcane.local/demo-2ab41b29/worker:latest")
+ require.NoError(t, err)
+ require.NotNil(t, result)
+ assert.Equal(t, UpdateTypeLocal, result.UpdateType)
+ assert.False(t, result.HasUpdate)
+ assert.Empty(t, result.Error)
+ assert.Zero(t, registryCalls.Load())
+
+ var saved ImageUpdateRecord
+ require.NoError(t, svc.db.First(&saved, "id = ?", "sha256:arcane-local-image-id").Error)
+ assert.Equal(t, UpdateTypeLocal, saved.UpdateType)
+ assert.Nil(t, saved.LastError)
+}
+
+func TestImageUpdateService_CheckMultipleImages_ArcaneLocalMissingImageSkipsRegistry(t *testing.T) {
+ svc, registryCalls := newArcaneLocalImageUpdateServiceInternal(t, false)
+
+ results, err := svc.CheckMultipleImages(context.Background(), []string{"arcane.local/demo-2ab41b29/worker:latest"}, nil)
+ require.NoError(t, err)
+ result := results["arcane.local/demo-2ab41b29/worker:latest"]
+ require.NotNil(t, result)
+ assert.Empty(t, result.Error)
+ assert.False(t, result.HasUpdate)
+ assert.Equal(t, UpdateTypeLocal, result.UpdateType)
+ assert.Zero(t, registryCalls.Load())
+}
+
+func TestImageUpdateService_CheckMultipleImages_OtherDottedRegistryStillChecked(t *testing.T) {
+ svc, registryCalls := newArcaneLocalImageUpdateServiceInternal(t, false)
+
+ results, err := svc.CheckMultipleImages(context.Background(), []string{"registry.local/team/app:latest"}, nil)
+ require.NoError(t, err)
+ result := results["registry.local/team/app:latest"]
+ require.NotNil(t, result)
+ assert.Empty(t, result.Error)
+ assert.Equal(t, UpdateTypeNotPulled, result.UpdateType)
+ assert.Positive(t, registryCalls.Load())
+}
+
func TestImageUpdateService_InspectLocalImageSnapshot_NoRepoDigestsRemainsLocal(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.Contains(r.URL.Path, "/images/") && strings.HasSuffix(r.URL.Path, "/json") {
diff --git a/backend/pkg/projects/build_translation.go b/backend/pkg/projects/build_translation.go
index cf5ce3d29..06563a972 100644
--- a/backend/pkg/projects/build_translation.go
+++ b/backend/pkg/projects/build_translation.go
@@ -7,6 +7,7 @@ import (
"strings"
composetypes "github.com/compose-spec/compose-go/v2/types"
+ "github.com/getarcaneapp/arcane/backend/v2/pkg/utils/imageref"
)
// BuildArgsFromCompose flattens compose build args into a string map, dropping nil values.
@@ -122,7 +123,7 @@ func BuildLocalImageTag(projectID, projectName, serviceName string) string {
servicePart = "service"
}
- return fmt.Sprintf("arcane.local/%s-%s/%s:latest", projectPart, shortID, servicePart)
+ return fmt.Sprintf("%s/%s-%s/%s:latest", imageref.LocalBuildRegistry, projectPart, shortID, servicePart)
}
// SanitizeImageComponent lowercases a value and replaces characters that are
diff --git a/backend/pkg/utils/imageref/update_lookup.go b/backend/pkg/utils/imageref/update_lookup.go
index 535d3b0a3..4877dadcc 100644
--- a/backend/pkg/utils/imageref/update_lookup.go
+++ b/backend/pkg/utils/imageref/update_lookup.go
@@ -9,6 +9,9 @@ import (
registryauth "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/registryauth"
)
+// LocalBuildRegistry is Arcane's reserved registry host for locally built image tags.
+const LocalBuildRegistry = "arcane.local"
+
// ParseUpdateLookup normalizes an image reference into the repository and tag
// candidates used to match persisted update records.
func ParseUpdateLookup(imageRef string) (originalRef, tag string, repositoryCandidates map[string]struct{}, ok bool) {