mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #14182 from jiangyaoguo/distinguish-registry-unavailable-and-pull-failure
Auto commit by PR queue bot
This commit is contained in:
commit
916ddbca65
@ -105,7 +105,12 @@ func (puller *imagePuller) PullImage(pod *api.Pod, container *api.Container, pul
|
|||||||
if err = puller.runtime.PullImage(spec, pullSecrets); err != nil {
|
if err = puller.runtime.PullImage(spec, pullSecrets); err != nil {
|
||||||
puller.logIt(ref, "Failed", logPrefix, fmt.Sprintf("Failed to pull image %q: %v", container.Image, err), glog.Warning)
|
puller.logIt(ref, "Failed", logPrefix, fmt.Sprintf("Failed to pull image %q: %v", container.Image, err), glog.Warning)
|
||||||
puller.backOff.Next(backOffKey, puller.backOff.Clock.Now())
|
puller.backOff.Next(backOffKey, puller.backOff.Clock.Now())
|
||||||
return ErrImagePull, err.Error()
|
if err == RegistryUnavailable {
|
||||||
|
msg := fmt.Sprintf("image pull failed for %s because the registry is temporarily unavailable.", container.Image)
|
||||||
|
return err, msg
|
||||||
|
} else {
|
||||||
|
return ErrImagePull, err.Error()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
puller.logIt(ref, "Pulled", logPrefix, fmt.Sprintf("Successfully pulled image %q", container.Image), glog.Info)
|
puller.logIt(ref, "Pulled", logPrefix, fmt.Sprintf("Successfully pulled image %q", container.Image), glog.Info)
|
||||||
puller.backOff.GC()
|
puller.backOff.GC()
|
||||||
|
@ -45,6 +45,9 @@ var (
|
|||||||
|
|
||||||
// Required Image is absent on host and PullPolicy is NeverPullImage
|
// Required Image is absent on host and PullPolicy is NeverPullImage
|
||||||
ErrImageNeverPull = errors.New("ErrImageNeverPull")
|
ErrImageNeverPull = errors.New("ErrImageNeverPull")
|
||||||
|
|
||||||
|
// Get http error when pulling image from registry
|
||||||
|
RegistryUnavailable = errors.New("RegistryUnavailable")
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrRunContainer = errors.New("RunContainerError")
|
var ErrRunContainer = errors.New("RunContainerError")
|
||||||
|
@ -130,7 +130,7 @@ func filterHTTPError(err error, image string) error {
|
|||||||
jerr.Code == http.StatusServiceUnavailable ||
|
jerr.Code == http.StatusServiceUnavailable ||
|
||||||
jerr.Code == http.StatusGatewayTimeout) {
|
jerr.Code == http.StatusGatewayTimeout) {
|
||||||
glog.V(2).Infof("Pulling image %q failed: %v", image, err)
|
glog.V(2).Infof("Pulling image %q failed: %v", image, err)
|
||||||
return fmt.Errorf("image pull failed for %s because the registry is temporarily unavailable.", image)
|
return kubecontainer.RegistryUnavailable
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ func TestPullWithJSONError(t *testing.T) {
|
|||||||
"Bad gateway": {
|
"Bad gateway": {
|
||||||
"ubuntu",
|
"ubuntu",
|
||||||
&jsonmessage.JSONError{Code: 502, Message: "<!doctype html>\n<html class=\"no-js\" lang=\"\">\n <head>\n </head>\n <body>\n <h1>Oops, there was an error!</h1>\n <p>We have been contacted of this error, feel free to check out <a href=\"http://status.docker.com/\">status.docker.com</a>\n to see if there is a bigger issue.</p>\n\n </body>\n</html>"},
|
&jsonmessage.JSONError{Code: 502, Message: "<!doctype html>\n<html class=\"no-js\" lang=\"\">\n <head>\n </head>\n <body>\n <h1>Oops, there was an error!</h1>\n <p>We have been contacted of this error, feel free to check out <a href=\"http://status.docker.com/\">status.docker.com</a>\n to see if there is a bigger issue.</p>\n\n </body>\n</html>"},
|
||||||
"because the registry is temporarily unavailable",
|
kubecontainer.RegistryUnavailable.Error(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user