mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Retry image pulling 5 times before giving up in node e2e.
Signed-off-by: Vishnu kannan <vishnuk@google.com>
This commit is contained in:
parent
69b90028cf
commit
2be9cd4854
@ -17,12 +17,18 @@ limitations under the License.
|
|||||||
package e2e_node
|
package e2e_node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
busyBoxImage = iota
|
// Number of attempts to pull an image.
|
||||||
|
maxImagePullRetries = 5
|
||||||
|
// Sleep duration between image pull retry attempts.
|
||||||
|
imagePullRetryDelay = time.Second
|
||||||
|
busyBoxImage = iota
|
||||||
|
|
||||||
hostExecImage
|
hostExecImage
|
||||||
netExecImage
|
netExecImage
|
||||||
@ -51,7 +57,16 @@ var NoPullImagRegistry = map[int]string{
|
|||||||
// Pre-fetch all images tests depend on so that we don't fail in an actual test
|
// Pre-fetch all images tests depend on so that we don't fail in an actual test
|
||||||
func PrePullAllImages() error {
|
func PrePullAllImages() error {
|
||||||
for _, image := range ImageRegistry {
|
for _, image := range ImageRegistry {
|
||||||
output, err := exec.Command("docker", "pull", image).CombinedOutput()
|
var (
|
||||||
|
err error
|
||||||
|
output []byte
|
||||||
|
)
|
||||||
|
for i := maxImagePullRetries; i > 0; i++ {
|
||||||
|
if output, err = exec.Command("docker", "pull", image).CombinedOutput(); err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(imagePullRetryDelay)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Could not pre-pull image %s %v output: %s", image, err, output)
|
glog.Warningf("Could not pre-pull image %s %v output: %s", image, err, output)
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user