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

feat(health probe): health and readiness endpoints #53

Merged
merged 2 commits into from
Dec 7, 2018

Conversation

wojciech12
Copy link
Contributor

@wojciech12 wojciech12 commented Nov 7, 2018

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.

@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 5d58d15
  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12 wojciech12 force-pushed the add_support_for_readiness_probe branch from 5d58d15 to 8930945 Compare November 7, 2018 09:35
@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 8930945
  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12 wojciech12 force-pushed the add_support_for_readiness_probe branch from 8930945 to 9f174e1 Compare November 7, 2018 09:38
@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1
  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

Copy link
Contributor

@pbrzostowski pbrzostowski left a 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?

defer s.Status.MuHealthy.Unlock()
if s.Status.IsHealthy {
data.MarshalWithCode(w, r, "OK", 200)
} else {
Copy link
Contributor

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

@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1
  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12
Copy link
Contributor Author

@pbrzostowski we let the service implementation to set the flag. I will provide two functions for this purpose.

@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1
  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12 wojciech12 force-pushed the add_support_for_readiness_probe branch from 75067ef to d9a736e Compare November 7, 2018 09:52
@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1
  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12 wojciech12 changed the title feat(health probe): Add flag for service health and, another, for the readiness feat(health probe): health and readiness endpoints Nov 7, 2018
@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1
  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1

  • Your subject line is longer than 72 characters

  • Commit: 18959e7

  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

2 similar comments
@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1

  • Your subject line is longer than 72 characters

  • Commit: 18959e7

  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1

  • Your subject line is longer than 72 characters

  • Commit: 18959e7

  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12
Copy link
Contributor Author

We let the implementation to set Health and Readiness flags.

@@ -123,7 +131,11 @@ func New(name string) *Service {
Router: mux.NewRouter(),
ServeMux: http.NewServeMux(),
}

s.Status.IsHealthy = true
s.Status.IsReady = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Service is never ready? 🤔

Copy link
Contributor Author

@wojciech12 wojciech12 Nov 7, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@GitCop
Copy link

GitCop commented Nov 7, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1

  • Your subject line is longer than 72 characters

  • Commit: 18959e7

  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@@ -123,7 +131,11 @@ func New(name string) *Service {
Router: mux.NewRouter(),
ServeMux: http.NewServeMux(),
}

s.Status.IsHealthy = true
Copy link
Contributor

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?).

Copy link
Contributor Author

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.

@GitCop
Copy link

GitCop commented Nov 8, 2018

There were the following issues with your Pull Request

  • Commit: 9f174e1

  • Your subject line is longer than 72 characters

  • Commit: 18959e7

  • Your subject line is longer than 72 characters

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12 wojciech12 force-pushed the add_support_for_readiness_probe branch from c703e71 to 75ae5ac Compare December 7, 2018 09:58
@wojciech12 wojciech12 force-pushed the add_support_for_readiness_probe branch from 75ae5ac to 60d5619 Compare December 7, 2018 09:59
s.StateProbes.MuHealthy.Lock()
defer s.StateProbes.MuHealthy.Unlock()

if s.StateProbes.IsHealthy {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

s.StateProbes.MuReady.Lock()
defer s.StateProbes.MuReady.Unlock()

if s.StateProbes.IsReady {
Copy link
Contributor

Choose a reason for hiding this comment

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

again fail-fast please

mwarzynski
mwarzynski previously approved these changes Dec 7, 2018
Copy link
Contributor

@mwarzynski mwarzynski left a comment

Choose a reason for hiding this comment

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

LGTM

@GitCop
Copy link

GitCop commented Dec 7, 2018

There were the following issues with your Pull Request

  • Commit: 02b1e2a
  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert, merge

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@wojciech12 wojciech12 force-pushed the add_support_for_readiness_probe branch from 02b1e2a to 57730a7 Compare December 7, 2018 10:27
@wojciech12 wojciech12 merged commit c53da85 into master Dec 7, 2018
@wojciech12 wojciech12 deleted the add_support_for_readiness_probe branch December 7, 2018 11:43
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