Parcourir la source

remove retry count logic

Alexander Belanger il y a 4 ans
Parent
commit
7baa51f837
3 fichiers modifiés avec 14 ajouts et 48 suppressions
  1. 1 9
      cli/cmd/deploy/create.go
  2. 1 9
      cli/cmd/deploy/deploy.go
  3. 12 30
      cli/cmd/docker/agent.go

+ 1 - 9
cli/cmd/deploy/create.go

@@ -303,15 +303,7 @@ func (c *CreateAgent) CreateFromDocker(
 		return "", err
 	}
 
-	retryCount := 1
-
-	// sometimes newly created gcr repositories aren't ready on the initial
-	// creation, so retry count is set higher
-	if strings.Contains(imageURL, "gcr.io") {
-		retryCount = 5
-	}
-
-	err = agent.PushImage(fmt.Sprintf("%s:%s", imageURL, "latest"), retryCount)
+	err = agent.PushImage(fmt.Sprintf("%s:%s", imageURL, "latest"))
 
 	if err != nil {
 		return "", err

+ 1 - 9
cli/cmd/deploy/deploy.go

@@ -266,15 +266,7 @@ func (d *DeployAgent) Build() error {
 
 // Push pushes a local image to the remote repository linked in the release
 func (d *DeployAgent) Push() error {
-	retryCount := 1
-
-	// sometimes newly created gcr repositories aren't ready on the initial
-	// creation, so retry count is set higher
-	if strings.Contains(d.imageRepo, "gcr.io") {
-		retryCount = 5
-	}
-
-	return d.agent.PushImage(fmt.Sprintf("%s:%s", d.imageRepo, d.tag), retryCount)
+	return d.agent.PushImage(fmt.Sprintf("%s:%s", d.imageRepo, d.tag))
 }
 
 // UpdateImageAndValues updates the current image for a release, along with new

+ 12 - 30
cli/cmd/docker/agent.go

@@ -6,7 +6,6 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
-	"io"
 	"os"
 	"strings"
 	"time"
@@ -188,45 +187,28 @@ func (a *Agent) PullImage(image string) error {
 }
 
 // PushImage pushes an image specified by the image string
-func (a *Agent) PushImage(image string, retryCount int) error {
-	var err error
-
+func (a *Agent) PushImage(image string) error {
 	opts, err := a.getPushOptions(image)
 
 	if err != nil {
 		return err
 	}
 
-	var out io.ReadCloser
-
-	for i := 0; i < retryCount; i++ {
-		out, err = a.client.ImagePush(
-			context.Background(),
-			image,
-			opts,
-		)
-
-		// an error in this case is fatal, since it likely means the docker daemon is
-		// not running
-		if err != nil {
-			return err
-		}
+	out, err := a.client.ImagePush(
+		context.Background(),
+		image,
+		opts,
+	)
 
-		defer out.Close()
-
-		termFd, isTerm := term.GetFdInfo(os.Stderr)
-
-		err = jsonmessage.DisplayJSONMessagesStream(out, os.Stderr, termFd, isTerm, nil)
+	defer out.Close()
 
-		if err != nil {
-			time.Sleep(1 * time.Second)
-			continue
-		} else {
-			break
-		}
+	if err != nil {
+		return err
 	}
 
-	return err
+	termFd, isTerm := term.GetFdInfo(os.Stderr)
+
+	return jsonmessage.DisplayJSONMessagesStream(out, os.Stderr, termFd, isTerm, nil)
 }
 
 func (a *Agent) getPullOptions(image string) (types.ImagePullOptions, error) {