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
add add-hosts #927
add add-hosts #927
Conversation
fixes #921 |
please add a test that confirms the hosts are added to the container at assemble time (which i assume is your goal). |
/ok-to-test |
[test] |
Evaluated for source to image test up to 1ca77a1 |
Source To Image Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_s2i/777/) (Base Commit: 8f7dcac) (PR Branch Commit: 1ca77a1) |
example: |
great, please add that scenario as a test to https://github.com/openshift/source-to-image/blob/master/hack/test-stirunimage.sh so we can make sure it continues to work. |
@bparees The scenario has been added to |
thanks @magicsong, can you squash your commits and i'll merge? |
hack/test-stirunimage.sh
Outdated
@@ -136,6 +136,11 @@ docker run test >& "${WORK_DIR}/s2i-override-run.log" | |||
grep "Running custom run" "${WORK_DIR}/s2i-override-run.log" | |||
check_result $? "${WORK_DIR}/s2i-override-run.log" | |||
|
|||
test_debug "s2i build with add-host option" | |||
s2i build https://github.com/openshift/ruby-hello-world centos/ruby-23-centos7 --add-host rubygems.org:1.1.1.1 test-ruby-app &> "${WORK_DIR}/s2i-add-host.log" | |||
grep "Build failed" "${WORK_DIR}/s2i-add-host.log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this check for a more specific failure reason related to the rubygems.org host not being found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but the error will change if 1.1.1.1 is down or close its http/https ports. I change the test scenario testing both cases----with and without --add-host flag---to make sure the failure is caused by --add-host flag
5798f2b
to
d460203
Compare
@@ -136,6 +136,12 @@ docker run test >& "${WORK_DIR}/s2i-override-run.log" | |||
grep "Running custom run" "${WORK_DIR}/s2i-override-run.log" | |||
check_result $? "${WORK_DIR}/s2i-override-run.log" | |||
|
|||
test_debug "s2i build with add-host option" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should be two separate tests, less one give the wrong result and they both pass.
Also, it should give some kind of specific error if rubygems.org can not be found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could set rubygems.org:127.0.0.1 and it should fail (since localhost is not a rubygems server) and you should get an error message about rubygems.org not being "accessible"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have change to 0.0.0.0 because error of 172.0.0.1 is much more unclear and it takes more time because it is the LOOPBACK internet interface. I also squash all my commits. @bparees
540ea59
to
d84ff01
Compare
[merge] |
hack/test-stirunimage.sh
Outdated
@@ -136,6 +136,11 @@ docker run test >& "${WORK_DIR}/s2i-override-run.log" | |||
grep "Running custom run" "${WORK_DIR}/s2i-override-run.log" | |||
check_result $? "${WORK_DIR}/s2i-override-run.log" | |||
|
|||
test_debug "s2i build with add-host option" | |||
s2i build https://github.com/openshift/ruby-hello-world centos/ruby-23-centos7 --add-host rubygems.org:0.0.0.0 test-ruby-app &> "${WORK_DIR}/s2i-add-host.log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you expect this to fail you need an || true at the end, because we run our script with exit on error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I added a set +e
before running my test.
pkg/cmd/cli/cmd/build.go
Outdated
@@ -215,5 +215,6 @@ $ s2i build . centos/ruby-22-centos7 hello-world-app | |||
buildCmd.Flags().StringVar(&(networkMode), "network", "", "Specify the default Docker Network name to be used in build process") | |||
buildCmd.Flags().StringVarP(&(cfg.AsDockerfile), "as-dockerfile", "", "", "EXPERIMENTAL: Output a Dockerfile to this path instead of building a new image") | |||
buildCmd.Flags().BoolVarP(&(cfg.KeepSymlinks), "keep-symlinks", "", false, "When using '--copy', copy symlinks as symlinks. Default behavior is to follow symlinks and copy files by content") | |||
buildCmd.Flags().StringArrayVar(&cfg.AddHost, "add-host", []string{}, "Specify additional entry added to /etc/hosts in container, multiple --add-host can be used to add multiple entry") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar. should be:
"Specify additional entries to add to the /etc/hosts in the assemble container, multiple --add-host arguments can be used to add multiple entries"
[merge] |
Evaluated for source to image merge up to 1b45714 |
Source To Image Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_s2i/779/) (Base Commit: 8f7dcac) (PR Branch Commit: 1b45714) |
Source To Image Action Required: Please contact #openshift-dev to have this pull request manually reviewed and tested |
Add a
--add-host
flag,same as--add-host
indocker run
. It is very useful when user in LAN or in dev environment.