Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Add readiness probe#287

Merged
seanmalloy merged 6 commits intomasterfrom
210-readiness
Feb 11, 2020
Merged

Add readiness probe#287
seanmalloy merged 6 commits intomasterfrom
210-readiness

Conversation

@mkyc
Copy link
Copy Markdown

@mkyc mkyc commented Feb 5, 2020

Description

This PR adds readinessProbe to allow kubernetes decide if requests should be routed to this pod or not. There is also separate e2e test added to verify visibility of /readyz (and already exisiting /healthz) endpoint.

Fixes #210

Changes

  • adds /readyz endpoint handler in main package
  • adds readinessProbe section in helm deployment template
  • renames TEST_NAMESPACE environment variable to OPERATOR_NAMESPACE in scripts/e2e-test.sh as it was interfering with TEST_NAMESPACE variable used by operator-sdk testing framework.
  • adds MINIKUBE_IP and WEBHOOK_PORT environment variables in scripts/e2e-test.sh to be available for new TestReadinessAndLivelinessProbes test.
  • adds TestReadinessAndLivelinessProbes test which checks visibility of /readyz and /healthz endpoints

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • [ok] Unit tests and e2e tests updated
  • [no] Documentation updated - No related documentation. Also readinessProbe is standard mechanism.

Mateusz Kyc added 2 commits February 5, 2020 18:16
This commit adds readinessProbe to allow kubernetes decide if requests should be routed to this pod or not. There is also separate e2e test added to verify visibility of /readyz (and already exisiting /healthz) endpoint.
Comment thread test/e2e/probes_test.go
if !found {
operatorName = "eunomia-operator"
}
operatorNamespace, found := os.LookupEnv("OPERATOR_NAMESPACE")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the namespace should be retrieved using the method ctx.GetNamespace().

Ref: a41add5

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.

Hmmm ... no. This namespace, err := ctx.GetNamespace() gets temporary namespace prepared for test, but in this test, I'm testing availability of endpoints of operator itself, so I need its namespace, not temporary one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ahhhh yes, misunderstanding on my part. Thanks!

@seanmalloy seanmalloy added this to the v0.1.3 milestone Feb 6, 2020
Mateusz Kyc added 2 commits February 6, 2020 15:31
This commit fixes dependency removed by mistake because of local 1.13 go version. It also fixes service connection initialization problem because of some little time required by Service to obtain connection to operator pod.
I moved service creation at the very beginning of test.
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 6, 2020

Codecov Report

Merging #287 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #287   +/-   ##
=====================================
  Coverage       0%     0%           
=====================================
  Files           1      1           
  Lines          52     52           
=====================================
  Misses         52     52

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 253bc36...6b6a872. Read the comment docs.

Copy link
Copy Markdown

@akavel akavel left a comment

Choose a reason for hiding this comment

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

Wow, so few comments from me on this one! ;P

Comment thread cmd/manager/main.go Outdated
Comment thread deploy/helm/eunomia-operator/templates/deployment.yaml
Comment thread scripts/e2e-test.sh Outdated
Comment thread test/e2e/probes_test.go
Comment thread test/e2e/probes_test.go
Comment thread test/e2e/probes_test.go Outdated
wantBody: "ok",
},
{
endpoint: "healthz",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this seems to be the only field that changes between the test structs; can we remove all the other ones and just inline them in the body of the for _, tt loop?

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 believe it's good to see clearly what test is trying to verify. I removed requestBody and requestMethod but I think I'd keep want... things. If you think that this is important to remove those as well, let me know.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[optional] I would personally remove as we talked, but I understand what you mean and leave the choice to you.

Comment thread test/e2e/probes_test.go Outdated
Comment thread test/e2e/probes_test.go Outdated
Comment thread test/e2e/probes_test.go Outdated
Comment thread cmd/manager/main.go
In this commit I'm:
 - fixing issue possibly leading to infinite test run
 - adding comments explaining some not obvious moments
 - improving error levels
@seanmalloy
Copy link
Copy Markdown
Contributor

@mkyc I had one inline comment/question here. Let me know what you think.

Other than that I think we just need @vinny-sabatini and @akavel to review one more time.

Comment thread test/e2e/probes_test.go Outdated
Comment thread test/e2e/probes_test.go Outdated
Comment thread test/e2e/probes_test.go Outdated
Comment thread test/e2e/probes_test.go Outdated
Comment thread test/e2e/probes_test.go Outdated
Comment thread cmd/manager/main.go
Comment thread scripts/e2e-test.sh
Comment thread test/e2e/probes_test.go Outdated
wantBody: "ok",
},
{
endpoint: "healthz",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[optional] I would personally remove as we talked, but I understand what you mean and leave the choice to you.

In this commit I'm:
 - polishing comments even more
 - fixing error messages as suggested
 - removing recurrent parameters from test
Copy link
Copy Markdown

@akavel akavel left a comment

Choose a reason for hiding this comment

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

❤️ thanks!

@seanmalloy seanmalloy merged commit 55c1280 into master Feb 11, 2020
@seanmalloy seanmalloy deleted the 210-readiness branch February 11, 2020 16:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add kubernetes readiness check uri

4 participants