Merge pull request #1401 from umohnani8/image
Fix create container failure due to wrong image reference
This commit is contained in:
commit
860fba80eb
2 changed files with 20 additions and 8 deletions
|
@ -616,6 +616,8 @@ func splitDockerDomain(name string) (domain, remainder string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveNames resolves an image name into a storage image ID or a fully-qualified image name (domain/repo/image:tag).
|
||||||
|
// Will only return an empty slice if err != nil.
|
||||||
func (svc *imageService) ResolveNames(imageName string) ([]string, error) {
|
func (svc *imageService) ResolveNames(imageName string) ([]string, error) {
|
||||||
// _Maybe_ it's a truncated image ID. Don't prepend a registry name, then.
|
// _Maybe_ it's a truncated image ID. Don't prepend a registry name, then.
|
||||||
if len(imageName) >= minimumTruncatedIDLength && svc.store != nil {
|
if len(imageName) >= minimumTruncatedIDLength && svc.store != nil {
|
||||||
|
|
|
@ -1038,14 +1038,24 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get imageName and imageRef that are later requested in container status
|
// Get imageName and imageRef that are later requested in container status
|
||||||
status, err := s.StorageImageServer().ImageStatus(s.ImageContext(), images[0])
|
var (
|
||||||
if err != nil {
|
imgResult *storage.ImageResult
|
||||||
return nil, err
|
imgResultErr error
|
||||||
|
)
|
||||||
|
for _, img := range images {
|
||||||
|
imgResult, imgResultErr = s.StorageImageServer().ImageStatus(s.ImageContext(), img)
|
||||||
|
if imgResultErr == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
imageName := status.Name
|
if imgResultErr != nil {
|
||||||
imageRef := status.ID
|
return nil, imgResultErr
|
||||||
if len(status.RepoDigests) > 0 {
|
}
|
||||||
imageRef = status.RepoDigests[0]
|
|
||||||
|
imageName := imgResult.Name
|
||||||
|
imageRef := imgResult.ID
|
||||||
|
if len(imgResult.RepoDigests) > 0 {
|
||||||
|
imageRef = imgResult.RepoDigests[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
specgen.AddAnnotation(annotations.Image, image)
|
specgen.AddAnnotation(annotations.Image, image)
|
||||||
|
@ -1163,7 +1173,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
|
||||||
attempt := metadata.Attempt
|
attempt := metadata.Attempt
|
||||||
containerInfo, err := s.StorageRuntimeServer().CreateContainer(s.ImageContext(),
|
containerInfo, err := s.StorageRuntimeServer().CreateContainer(s.ImageContext(),
|
||||||
sb.Name(), sb.ID(),
|
sb.Name(), sb.ID(),
|
||||||
image, status.ID,
|
image, imgResult.ID,
|
||||||
containerName, containerID,
|
containerName, containerID,
|
||||||
metaname,
|
metaname,
|
||||||
attempt,
|
attempt,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue