Skip to content

hack/util: wait for registry readiness - #9079

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
miminar:wait-until-registry-is-ready
Jun 1, 2016
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
miminar:wait-until-registry-is-ready

Conversation

@miminar

@miminar miminar commented May 30, 2016

Copy link
Copy Markdown

Waiting just for registry's endpoints isn't sufficient. It takes few
more seconds for the registry to become ready. Let's wait until ready
before launching tests.

The race occured for example in job#200 (#8195).

The wait_for_registry now generates following log:

[INFO] Waiting for command to finish: '[[ "$(oc get endpoints docker-registry --output-version=v1 --template='{{ if .subsets }}{{ len .subsets }}{{ else }}0{{ end }}' --config=/tmp/openshift/test-extended/core/openshift.local.config/master/admin.kubeconfig || echo 0)" != "0" ]]'...
[INFO] Success running command: '[[ "$(oc get endpoints docker-registry --output-version=v1 --template='{{ if .subsets }}{{ len .subsets }}{{ else }}0{{ end }}' --config=/tmp/openshift/test-extended/core/openshift.local.config/master/admin.kubeconfig || echo 0)" != "0" ]]' after 12 seconds
[INFO] Waiting for command to finish: 'oc get pod -l deploymentconfig=docker-registry --output-version=v1 --template='{{ range .items }}{{ range .status.conditions }}{{ if eq .type "Ready" }}{{ .status }}{{ end }}{{ end }}{{ end }}' --config=/tmp/openshift/test-extended/core/openshift.local.config/master/admin.kubeconfig | grep -qi '^True$''...
[INFO] Success running command: 'oc get pod -l deploymentconfig=docker-registry --output-version=v1 --template='{{ range .items }}{{ range .status.conditions }}{{ if eq .type "Ready" }}{{ .status }}{{ end }}{{ end }}{{ end }}' --config=/tmp/openshift/test-extended/core/openshift.local.config/master/admin.kubeconfig | grep -qi '^True$'' after 7 seconds

@miminar miminar mentioned this pull request May 30, 2016
4 tasks done
@miminar

miminar commented May 30, 2016

Copy link
Copy Markdown
Author

@stevekuznetsov PTAL

[test]

@stevekuznetsov stevekuznetsov self-assigned this May 30, 2016
Comment thread hack/util.sh Outdated
function wait_for_registry {
wait_for_command '[[ "$(oc get endpoints docker-registry --output-version=v1 --template="{{ if .subsets }}{{ len .subsets }}{{ else }}0{{ end }}" --config=${ADMIN_KUBECONFIG} || echo "0")" != "0" ]]' $((5*TIME_MIN))
local config="--config=${ADMIN_KUBECONFIG}"
local tmplsubsets='{{ if .subsets }}{{ len .subsets }}{{ else }}0{{ end }}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've been holding off on this for a while, but ...

If we do a simple "string is equal to a non-zero number" check, we don't need the if/else in this template or the || echo 0 in the next command.

I also would like to see us transition to jsonpath as it seems easier to understand and write 99% of the time. However, we can't do len() in jsonpath so the question becomes ... are we always happy to see that the service has any endpoints? Do we need / can we use a less fragile check? Since we're doing the setup in a function, we can assume things about which endpoints should exist?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@deads2k thinking about this, does it make sense to have an oadm registry is-up command or something in the CLI to facilitate this? Won't customers doing custom install/setup scripts end up building their own version of this function?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, that being said, can we use oc status here? Will that correctly tell us when the service is "ready"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

thinking about this, does it make sense to have an oadm registry is-up command or something in the CLI to facilitate this?

I like the idea!

Actually, that being said, can we use oc status here? Will that correctly tell us when the service is "ready"?

We could, but we we'd be waiting perhaps unnecessarily long:

# when the deployer is running regardless of registry pod running or ready
...
svc/docker-registry - 172.30.186.199:5000
  dc/docker-registry deploys docker.io/openshift/origin-docker-registry:latest 
    deployment #1 running for 40 seconds - 1 pod
...
# when the deployer is deleted
...
svc/docker-registry - 172.30.186.199:5000
  dc/docker-registry deploys docker.io/openshift/origin-docker-registry:latest 
    deployment #1 deployed about a minute ago - 1 pod
...

Somewhen in between the endpoints are set and the deployer destroyed registry becomes ready. On my setup the deployer is deleted 2 seconds after the registry becomes ready. Moreover I'd prefer parsing of pod's status rather than status description which can easily change.

Let me try with the jsonpath.

@stevekuznetsov

Copy link
Copy Markdown
Contributor

Are we always going to see the endpoints show up before the pod posts a successful readiness check? If so, can we get rid of the endpoint check?

@soltysh

soltysh commented May 30, 2016

Copy link
Copy Markdown
Contributor

/sub

@0xmichalis

Copy link
Copy Markdown
Contributor

Are we always going to see the endpoints show up before the pod posts a successful readiness check? If so, can we get rid of the endpoint check?

Endpoint means the pod is added in rotation. It doesn't happen before the readiness check.

@miminar
miminar force-pushed the wait-until-registry-is-ready branch from 03ca0da to 9710e2d Compare May 30, 2016 19:17
@miminar

miminar commented May 30, 2016

Copy link
Copy Markdown
Author

@stevekuznetsov ready for another review. Thanks for the suggestions.

Comment thread hack/util.sh Outdated

function wait_for_registry {
wait_for_command '[[ "$(oc get endpoints docker-registry --output-version=v1 --template="{{ if .subsets }}{{ len .subsets }}{{ else }}0{{ end }}" --config=${ADMIN_KUBECONFIG} || echo "0")" != "0" ]]' $((5*TIME_MIN))
local config="--config=${ADMIN_KUBECONFIG}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a fan of this because it's very hard to think about what would happen if this contained a space (as it could on a dev box) ... forgetting the naked $config substitution, there is more confusion as the string gets passed into a function and then to eval ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I inlined the $config.

@stevekuznetsov

Copy link
Copy Markdown
Contributor

Shame the imports aren't working as expected ... the call stack is all screwed up as well. I not only have a refactor of the imports but also one of the stacktrace in the pipe, one blocking the second ... hopefully they get in soon and at that point I'll refactor this to use the os::cmd function.

@stevekuznetsov

stevekuznetsov commented May 30, 2016 •

Copy link
Copy Markdown
Contributor

@danmcp not an indication of where the current Bash limits us when we add new features, but definitely some indication of how fragile the current setup is that we aren't guaranteed successful import statements or correct stacktraces (since you asked in that meeting how often our current Bash seems limiting)

Waiting just for registry's endpoints isn't sufficient. It takes few
more seconds for the registry to become ready. Let's wait until ready
before launching tests.

Signed-off-by: Michal Minář <[email protected]>
@miminar
miminar force-pushed the wait-until-registry-is-ready branch from 9710e2d to 7302258 Compare May 31, 2016 07:10
@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 7302258

@stevekuznetsov

Copy link
Copy Markdown
Contributor

LGTM

@deads2k

deads2k commented May 31, 2016

Copy link
Copy Markdown
Contributor

@deads2k thinking about this, does it make sense to have an oadm registry is-up command or something in the CLI to facilitate this?

Not specific to the registry. I would have expected there to be a PodCondition you could look for. Does the Ready condition not do what you want?

@deads2k

deads2k commented May 31, 2016

Copy link
Copy Markdown
Contributor

Ah, that's exactly what he did. That seems pretty reasonable: "am I ready? check my ready condition to see".

[merge] on Steve's lgtm.

@stevekuznetsov

Copy link
Copy Markdown
Contributor

@deads2k I was thinking there might be use for a more direct "is this thing ready" query backed by oc that didn't involve jsonpath and string matching

@mfojtik

mfojtik commented May 31, 2016

Copy link
Copy Markdown
Contributor

This: #7114 seems to help here as well?

@openshift-bot

Copy link
Copy Markdown
Contributor

@soltysh

soltysh commented May 31, 2016

Copy link
Copy Markdown
Contributor

The tests are good,
re-[merge]

@openshift-bot

openshift-bot commented Jun 1, 2016 •

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/4260/) (Image: devenv-rhel7_4301)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 7302258

openshift-bot pushed a commit that referenced this pull request Jun 1, 2016
@openshift-bot
openshift-bot merged commit 7afe72b into openshift:master Jun 1, 2016
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.

7 participants