Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow retry action of pulling image in build process #13380

Merged
merged 1 commit into from
Mar 18, 2017

Conversation

guangxuli
Copy link
Contributor

@guangxuli guangxuli commented Mar 14, 2017

command :
[cloud@centos ~]$ oc new-build https://github.com/openshift/ruby-hello-world --source-image=openshift/jenkins-1-centos7 --source-image-path=/var/lib/jenkins:tmp --allow-missing-images=false

result:

--> Found Docker image bce81d0 (2 weeks old) from Docker Hub for "centos/ruby-22-centos7"

Ruby 2.2 
-------- 
Platform for building and running Ruby 2.2 applications

Tags: builder, ruby, ruby22

* An image stream will be created as "ruby-22-centos7:latest" that will track the source image
* A Docker build using source code from https://github.com/openshift/ruby-hello-world will be created
  * The resulting image will be pushed to image stream "ruby-hello-world:latest"
  * Every time "ruby-22-centos7:latest" changes a new build will be triggered

--> Creating resources with label build=ruby-hello-world ...
    imagestream "ruby-22-centos7" created
    imagestream "ruby-hello-world" created
    buildconfig "ruby-hello-world" created
    imagestream "jenkins-1-centos7" created
--> Success
    Build configuration "ruby-hello-world" created and build triggered.
    Run 'oc logs -f bc/ruby-hello-world' to stream the build progress.

Log:

[cloud@centos ~]$ oc logs -f bc/ruby-hello-world
Cloning "https://github.com/openshift/ruby-hello-world" ...
	Commit:	022d87e4160c00274b63cdad7c238b5c6a299265 (Merge pull request #58 from junaruga/feature/fix-for-ruby24)
	Author:	Ben Parees <[email protected]>
	Date:	Fri Mar 3 15:29:12 2017 -0500
Pulling image "openshift/jenkins-1-centos7@sha256:1fc2d985e743c43ac32344d4987778647621c68810d2d25551736f40de34b2ce" ...
error: build error: error pulling image openshift/jenkins-1-centos7@sha256:1fc2d985e743c43ac32344d4987778647621c68810d2d25551736f40de34b2ce: Get https://registry-1.docker.io/v2/: read tcp 192.168.122.251:60528->50.17.62.194:443: read: **connection reset by peer**

Since the error connection reset by peer had been handled in build pushing process,
I think we should add retry action of pulling image like what pushing image does. Test result seems acceptable which always successful after retrying pull image 2~3 time in my workaround.

/cc @bparees

if err := RetryImageAction(client, opts, authConfig); err != nil {
return "", err
} else {
return digestWriter.Digest, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no else block needed, just "return digestWriter.Digest,nil"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@bparees
Copy link
Contributor

bparees commented Mar 15, 2017

[test]

@bparees
Copy link
Contributor

bparees commented Mar 15, 2017

[testextended][extended:core(builds)]

@guangxuli
Copy link
Contributor Author

@bparees

test falilure seems a flake


[ERROR] PID 12365: hack/lib/build/environment.sh:137: `return "${exitcode}"` exited with status 2.
13:02:27 [INFO] 		Stack Trace: 
13:02:27 [INFO] 		  1: hack/lib/build/environment.sh:137: `return "${exitcode}"`
13:02:27 [INFO] 		  2: hack/lib/build/environment.sh:217: os::build::environment::withsource
13:02:27 [INFO] 		  3: hack/env:36: os::build::environment::run
13:02:27 [INFO]   Exiting with code 2.
13:02:27 ++ export status=FAILURE
13:02:27 ++ status=FAILURE
13:02:27 + set +o xtrace
13:02:27 
########## FINISHED STAGE: FAILURE: RUN CHECK AND VERIFY TASKS ##########

@bparees
Copy link
Contributor

bparees commented Mar 16, 2017 via email

@guangxuli guangxuli force-pushed the fix_docker_pull_fail branch from be2e5e6 to bce7095 Compare March 16, 2017 06:54
@guangxuli
Copy link
Contributor Author

@bparees sorry, in my local test I did not check the test error carefully. RetryImageActionshould return error after retry out max times. Fixed.

@@ -141,8 +141,8 @@ func TestTagImage(t *testing.T) {
func TestPushImage(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a TestPullImage equivalent to this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

time.Sleep(DefaultPushOrPullRetryDelay)
}

return fmt.Errorf("After retry %d times, %s image still failed", DefaultPushOrPullRetryDelay, actionName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retry->retrying

@guangxuli guangxuli force-pushed the fix_docker_pull_fail branch from bce7095 to c4afcce Compare March 17, 2017 12:54
@guangxuli
Copy link
Contributor Author

@bparees Test case addressed, ptal.

Copy link
Contributor

@bparees bparees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last nit.

fakeDocker := NewFakeDockerClient()
fakeDocker.pullImageFunc = fakePullImageFunc
testAuth := docker.AuthConfiguration{
Username: "usernname_foo_bar",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

username_foo_bar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@bparees
Copy link
Contributor

bparees commented Mar 17, 2017

[testextended][extended:core(builds)]

@bparees
Copy link
Contributor

bparees commented Mar 17, 2017

[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to c4afcce

delete else block

return error after retry maxtimes

add test case for pull image

fix username
@guangxuli guangxuli force-pushed the fix_docker_pull_fail branch from c4afcce to ca07fa9 Compare March 17, 2017 15:22
@guangxuli
Copy link
Contributor Author

@bparees conformance test fail, the failure cause seems not related to what this PR does.

@bparees
Copy link
Contributor

bparees commented Mar 17, 2017

agree, looks like a flake.

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/48/) (Base Commit: 75c6750) (Extended Tests: core(builds))

@bparees
Copy link
Contributor

bparees commented Mar 17, 2017

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to ca07fa9

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to ca07fa9

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/288/) (Base Commit: fae18e0)

@openshift-bot
Copy link
Contributor

openshift-bot commented Mar 17, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/131/) (Base Commit: 65a0cbf) (Image: devenv-rhel7_6083)

@openshift-bot
Copy link
Contributor

Origin Action Required: Please contact #openshift-dev to have this pull request manually reviewed and tested

@openshift-bot openshift-bot merged commit bd0bf10 into openshift:master Mar 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants