Fix create container failure due to wrong image reference
When the image name is resolved with the registries from crio.conf only the resolved name with the first registry is passed to create_container eventhough there are more registries in the crio.conf file. Fix this to try the resolved image names with all the registries given in the conf file. Signed-off-by: umohnani8 <umohnani@redhat.com>
This commit is contained in:
parent
0b736bb43f
commit
e35204c5e0
2 changed files with 20 additions and 8 deletions
|
@ -616,6 +616,8 @@ func splitDockerDomain(name string) (domain, remainder string) {
|
|||
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) {
|
||||
// _Maybe_ it's a truncated image ID. Don't prepend a registry name, then.
|
||||
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
|
||||
status, err := s.StorageImageServer().ImageStatus(s.ImageContext(), images[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var (
|
||||
imgResult *storage.ImageResult
|
||||
imgResultErr error
|
||||
)
|
||||
for _, img := range images {
|
||||
imgResult, imgResultErr = s.StorageImageServer().ImageStatus(s.ImageContext(), img)
|
||||
if imgResultErr == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
imageName := status.Name
|
||||
imageRef := status.ID
|
||||
if len(status.RepoDigests) > 0 {
|
||||
imageRef = status.RepoDigests[0]
|
||||
if imgResultErr != nil {
|
||||
return nil, imgResultErr
|
||||
}
|
||||
|
||||
imageName := imgResult.Name
|
||||
imageRef := imgResult.ID
|
||||
if len(imgResult.RepoDigests) > 0 {
|
||||
imageRef = imgResult.RepoDigests[0]
|
||||
}
|
||||
|
||||
specgen.AddAnnotation(annotations.Image, image)
|
||||
|
@ -1163,7 +1173,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
|
|||
attempt := metadata.Attempt
|
||||
containerInfo, err := s.StorageRuntimeServer().CreateContainer(s.ImageContext(),
|
||||
sb.Name(), sb.ID(),
|
||||
image, status.ID,
|
||||
image, imgResult.ID,
|
||||
containerName, containerID,
|
||||
metaname,
|
||||
attempt,
|
||||
|
|
Loading…
Reference in a new issue