-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat(health probe): health and readiness endpoints #53
Conversation
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
5d58d15
to
8930945
Compare
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
8930945
to
9f174e1
Compare
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
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.
How service is set as not healthy
state?
service/handlers.go
Outdated
defer s.Status.MuHealthy.Unlock() | ||
if s.Status.IsHealthy { | ||
data.MarshalWithCode(w, r, "OK", 200) | ||
} else { |
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.
we should avoid else
in go if possible. It better to read:
if expression {
// some stuff
return // return
}
// other stuff
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
@pbrzostowski we let the service implementation to set the flag. I will provide two functions for this purpose. |
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
75067ef
to
d9a736e
Compare
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
2 similar comments
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
We let the implementation to set Health and Readiness flags. |
service/service.go
Outdated
@@ -123,7 +131,11 @@ func New(name string) *Service { | |||
Router: mux.NewRouter(), | |||
ServeMux: http.NewServeMux(), | |||
} | |||
|
|||
s.Status.IsHealthy = true | |||
s.Status.IsReady = false |
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.
Service is never ready? 🤔
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.
It depends on your k8s definition whether you use the readiness probe or not.
I will change it to true, because in many cases running = healthy = ready. Otherwise it might confuse us.
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.
Ah, so the service should be in charge of setting this to true
. Makes sense.
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. However. Your comment helped me to realize that setting it to true will work for most of our lightweight micro-services.
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
service/service.go
Outdated
@@ -123,7 +131,11 @@ func New(name string) *Service { | |||
Router: mux.NewRouter(), | |||
ServeMux: http.NewServeMux(), | |||
} | |||
|
|||
s.Status.IsHealthy = true |
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 am not sure if this is the proper place for status set? I mean, we have a Start()
func that spin off service. Is the creation on the service
proper place for this setup here? Actually service is not ready/health because it's not even started/serving, isn't it?
And btw... I really think that we should get a chan
out of service.Start()
to be able to notify/get notified about stuff (like if service actually ready and listen etc, and maybe statuses management should be through it?).
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.
The Chan on the start is a separate concern, definitely we should have it. Notice, that I have moved the creation of the stop chan, so you can subscribe to it.
This setting is the default value, you, as a service-based-on-missy developer, should manage it yourself.
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
c703e71
to
75ae5ac
Compare
75ae5ac
to
60d5619
Compare
service/handlers.go
Outdated
s.StateProbes.MuHealthy.Lock() | ||
defer s.StateProbes.MuHealthy.Unlock() | ||
|
||
if s.StateProbes.IsHealthy { |
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'd prefer to have fail-fast strategy. First handle errors and successful resolution should be at the end of function
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.
Fixed.
service/handlers.go
Outdated
s.StateProbes.MuReady.Lock() | ||
defer s.StateProbes.MuReady.Unlock() | ||
|
||
if s.StateProbes.IsReady { |
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.
again fail-fast please
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.
LGTM
There were the following issues with your Pull Request
Guidelines are available at https://github.com/microdevs/missy This message was auto-generated by https://gitcop.com |
02b1e2a
to
57730a7
Compare
The health probe helps us to inform kubernetes that the service should be killed. The readiness probe will let us support components with very slow start.