Skip to content

Commit

Permalink
remove double execution to work around flaky endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
damoon committed Feb 4, 2021
1 parent d538416 commit e68d377
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
17 changes: 5 additions & 12 deletions pkg/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func buildParameters(r *http.Request) (*buildConfig, error) {
// memory limit
memoryArg := r.URL.Query().Get("memory")
if memoryArg == "" || memoryArg == "0" {
memoryArg = "2147483648" // 2Gi default
memoryArg = buildMemory
}
memory, err := strconv.Atoi(memoryArg)
if err != nil {
Expand Down Expand Up @@ -368,17 +368,10 @@ buildctl-daemonless.sh \
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Image: buildkitImage,
Name: "buildkit",
Command: []string{
"timeout",
strconv.Itoa(int(MaxExecutionTime / time.Second)),
},
Args: []string{
"sh",
"-c",
fmt.Sprintf("(%s) || (%s)", buildScript, buildScript),
},
Image: buildkitImage,
Name: "buildkit",
Command: []string{"timeout", strconv.Itoa(int(MaxExecutionTime / time.Second))},
Args: []string{"sh", "-c", buildScript},
VolumeMounts: []corev1.VolumeMount{
{
MountPath: "/home/user/.docker",
Expand Down
5 changes: 2 additions & 3 deletions pkg/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ func (s Service) inspect(w http.ResponseWriter, r *http.Request) {
script := fmt.Sprintf(`
set -euo pipefail
mkdir %s
skopeo copy --quiet --retry-times 3 --src-tls-verify=false docker://%s dir://%s || \
skopeo copy --quiet --retry-times 3 --src-tls-verify=false docker://%s dir://%s
skopeo copy --quiet --retry-times 3 --src-tls-verify=false docker://%s dir://%s
skopeo inspect dir://%s
rm -r %s
`, randomID, image, randomID, image, randomID, randomID, randomID)
`, randomID, image, randomID, randomID, randomID)

ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
defer cancel()
Expand Down
2 changes: 1 addition & 1 deletion pkg/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s Service) pullImage(w http.ResponseWriter, r *http.Request) {
}

o := &output{w: w}
err = scheduler(r.Context(), o, "pull", script+" || "+script, dockerCfg.mustToJSON())
err = scheduler(r.Context(), o, "pull", script, dockerCfg.mustToJSON())
if err != nil {
log.Printf("execute pull: %v", err)
o.Errorf("execute pull: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s Service) pushImage(w http.ResponseWriter, r *http.Request) {
}

o := &output{w: w}
err = scheduler(r.Context(), o, "push", script+" || "+script, dockerCfg.mustToJSON())
err = scheduler(r.Context(), o, "push", script, dockerCfg.mustToJSON())
if err != nil {
log.Printf("execute push: %v", err)
o.Errorf("execute push: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s Service) tagImage(w http.ResponseWriter, r *http.Request) {
}

o := &bytes.Buffer{}
err = scheduler(r.Context(), o, "tag", script+" || "+script, "")
err = scheduler(r.Context(), o, "tag", script, "")
if err != nil {
log.Printf("execute tag: %v", err)
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit e68d377

Please sign in to comment.