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

Fail fast when non-existent URL passed to docker build #140

Merged
merged 1 commit into from
Sep 27, 2014

Conversation

soltysh
Copy link
Contributor

@soltysh soltysh commented Sep 24, 2014

This PR is to address issue talked in #115
@smarterclayton @csrwng @mfojtik lemme know what do you think?

The other thing is, I'd like to extend our integration tests a little bit, as it was talked some time ago on IRC with possibility to test e.g. this as well. I'll working on it as well, unless told otherwise.

if [[ $URL != "http://"* ]] && [[ $URL != "https://"* ]]; then
URL="https://"$URL
fi
curl -sf $URL > /dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to use something like --max-time here, otherwise you've just shifted the timeout issues to curl.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we also need to be able to handle redirect (-L option) and deal with invalid SSL certificates (?). Curl provides many useful options for retries/timeouts, worth to explore them as Dan mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

How much more complex does this script get before it should be written in a real programming language?

----- Original Message -----

@@ -14,6 +14,17 @@ if [ -n "$DOCKER_REGISTRY" ]; then
TAG=$DOCKER_REGISTRY/$BUILD_TAG
fi

+if [[ $DOCKER_CONTEXT_URL != "git://"* ]] && [[ $DOCKER_CONTEXT_URL !=
"git@"* ]]; then

  • URL=$DOCKER_CONTEXT_URL
  • if [[ $URL != "http://"* ]] && [[ $URL != "https://"* ]]; then
  • URL="https://"$URL
  • fi
  • curl -sf $URL > /dev/null

I think we also need to be able to handle redirect (-L option) and deal
with invalid SSL certificates (?). Curl provides many useful options for
retries/timeouts, worth to explore them as Dan mentioned.


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/140/files#r17983782

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smarterclayton I know what you mean, I was thinking the same way when I was writing those bytes of code. But on the other hand if docker w/ git does not give us that flexibility, we need to do it by ourselves. Should I take your proposal as a challenge to create such a thing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Id like to see a proposal for what that might look like before we invest significant effort into it. We should not however mistake the current code for a general purpose solution that captures all corner cases. Curl and bash is NOT a production quality library when used in this was

On Sep 24, 2014, at 4:29 PM, Maciej Szulik notifications@github.com wrote:

In images/builder/docker/docker-builder/build.sh:

@@ -14,6 +14,17 @@ if [ -n "$DOCKER_REGISTRY" ]; then
TAG=$DOCKER_REGISTRY/$BUILD_TAG
fi

+if [[ $DOCKER_CONTEXT_URL != "git://"* ]] && [[ $DOCKER_CONTEXT_URL != "git@"* ]]; then

  • URL=$DOCKER_CONTEXT_URL
  • if [[ $URL != "http://"* ]] && [[ $URL != "https://"* ]]; then
  • URL="https://"$URL
  • fi
  • curl -sf $URL > /dev/null
    @smarterclayton I know what you mean, I was thinking the same way when I was writing those bytes of code. But on the other hand if docker w/ git does not give us that flexibility, we need to do it by ourselves. Should I take your proposal as a challenge to create such a thing?


Reply to this email directly or view it on GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ironcladlou the problem here was that when git was accessing non-existent repository it though that it might be private (priv repos are 404-ed on github) so it asked for credentials. Plain curl will get 404 which is what I wanted to achieve with it. I've added --max-time and --location as @mfojtik suggested. I don't think we need to address wrong cert issue here, as git will have exactly the same problems accessing those.

@smarterclayton
Copy link
Contributor

Can we get the last comment addressed?

@soltysh
Copy link
Contributor Author

soltysh commented Sep 25, 2014

Working on it right now...

@soltysh
Copy link
Contributor Author

soltysh commented Sep 25, 2014

Addressed all the comments.
@smarterclayton @ironcladlou @mfojtik review pls

@soltysh soltysh mentioned this pull request Sep 25, 2014
@smarterclayton
Copy link
Contributor

@csrwng

if [[ $URL != "http://"* ]] && [[ $URL != "https://"* ]]; then
URL="https://"$URL
fi
curl --silent --fail --location --max-time 16 $URL > /dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we have good reason not to, I'd think it be good to include the --head option so we don't download things twice.

@soltysh
Copy link
Contributor Author

soltysh commented Sep 26, 2014

Rebased and applied @csrwng suggestion.
@smarterclayton after merging please close #115, thx.

@smarterclayton
Copy link
Contributor

LGTM [merge]

@openshift-bot
Copy link
Contributor

Origin Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_openshift3/146/) (Image: devenv-fedora_210)

@openshift-bot
Copy link
Contributor

Evaluated for origin up to 2be282a

openshift-bot pushed a commit that referenced this pull request Sep 27, 2014
@openshift-bot openshift-bot merged commit ab07903 into openshift:master Sep 27, 2014
pmorie pushed a commit to pmorie/origin that referenced this pull request Nov 5, 2014
@soltysh soltysh deleted the issue115 branch November 26, 2014 09:57
deads2k pushed a commit to deads2k/origin that referenced this pull request May 17, 2016
danwinship pushed a commit to danwinship/origin that referenced this pull request Jun 24, 2016
Improve error messages in pkg/netutils/server/server_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants