kubernetes/kops · error
different sources for same image target %s: %s vs %s
Error message
different sources for same image target %s: %s vs %s
What it means
While building the copy task set, assetcopy deduplicates tasks by task name (the image target). If two image assets map to the same target name but have different CanonicalLocation sources, copying would non-deterministically pick one, so Copy fails fast with this error instead of producing a corrupt mirror.
Source
Thrown at pkg/assets/assetcopy/copy.go:50
type assetTask interface {
Run() error
}
func Copy(imageAssets []*assets.ImageAsset, fileAssets []*assets.FileAsset, vfsContext *vfs.VFSContext, cluster *kops.Cluster) error {
tasks := map[string]assetTask{}
for _, imageAsset := range imageAssets {
if imageAsset.DownloadLocation != imageAsset.CanonicalLocation {
copyImageTask := &CopyImage{
Name: imageAsset.DownloadLocation,
SourceImage: imageAsset.CanonicalLocation,
TargetImage: imageAsset.DownloadLocation,
}
if existing, ok := tasks[copyImageTask.Name]; ok {
if existing.(*CopyImage).SourceImage != copyImageTask.SourceImage {
return fmt.Errorf("different sources for same image target %s: %s vs %s", copyImageTask.Name, copyImageTask.SourceImage, existing.(*CopyImage).SourceImage)
}
}
tasks[copyImageTask.Name] = copyImageTask
}
}
for _, fileAsset := range fileAssets {
if fileAsset.DownloadURL.String() != fileAsset.CanonicalURL.String() {
copyFileTask := &CopyFile{
Name: fileAsset.CanonicalURL.String(),
TargetFile: fileAsset.DownloadURL.String(),
SourceFile: fileAsset.CanonicalURL.String(),
SHA: fileAsset.SHAValue.Hex(),
VFSContext: vfsContext,
Cluster: cluster,
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Ensure each distinct source image gets a unique target name, or normalize the CanonicalLocation so duplicates agree
- Pin image versions/tags so all assets resolve to the same source for a given target
- Refresh the asset build from a consistent source (single registry/repo) so mixed-location assets are not combined
- If using image mirrors/overrides in the cluster spec, verify no two entries collide on the same target
Example fix
// before // two assets: nginx:1.25 from registry.k8s.io and from mirror.example rewritten to same target // after // use distinct targets or a single canonical source: // target: my-registry.io/nginx:1.25 sourced only from registry.k8s.io/nginx:1.25
Defensive patterns
Strategy: validation
Validate before calling
seen := map[string]string{}
for _, a := range imageAssets {
target := a.DownloadLocation
if prev, ok := seen[target]; ok && prev != a.CanonicalLocation {
return fmt.Errorf("pre-check: image target %s has conflicting sources %s vs %s", target, prev, a.CanonicalLocation)
}
seen[target] = a.CanonicalLocation
} Type guard
func imageSourcesConsistent(assets []ImageAsset) bool {
seen := map[string]string{}
for _, a := range assets {
if p, ok := seen[a.DownloadLocation]; ok && p != a.CanonicalLocation {
return false
}
seen[a.DownloadLocation] = a.CanonicalLocation
}
return true
} Try / catch
if err := copy.Run(ctx); err != nil {
if strings.Contains(err.Error(), "different sources for same image target") {
return fmt.Errorf("asset config bug: %w — pin image versions so one target maps to one source", err)
}
return err
} Prevention
- Pin image tags/digests so all builds resolve to one canonical source
- Use a single image registry/mirror configuration per cluster
- Check image overrides in the cluster spec for target collisions
- Regenerate assets from one consistent kOps version
When it happens
Trigger: Two ImageAssets whose DownloadLocation (task name/target) collide while their CanonicalLocation values differ, both processed in one Copy call from the AssetBuilder.
Common situations: Image tags pointing at the same local target name but resolved from different registries (e.g. registry.k8s.io vs a mirror); an image retagged/relocated between runs so assets built from mixed versions disagree; customized asset file overrides mapping two upstream images to one target.
Related errors
- different targets for same file %s: %s vs %s
- unable to marshal YAML: %v
- unable to marshal JSON: %v
- unable to find any containerd binaries in assets
- error finding runc asset
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/f6fa6762dc29c92a.
Report an issue: GitHub.