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

Use github.com/heptio/healthcheck #98

Merged
merged 1 commit into from
Feb 27, 2018
Merged

Use github.com/heptio/healthcheck #98

merged 1 commit into from
Feb 27, 2018

Conversation

enocom
Copy link
Contributor

@enocom enocom commented Feb 20, 2018

Rather than a handrolled solution, this commit uses heptio's healthcheck
library. Future consumers of the health check handler need only to
register liveness or readiness probes.

@enocom enocom requested a review from markmandel February 20, 2018 21:26
@enocom
Copy link
Contributor Author

enocom commented Feb 20, 2018

There will be conflicts with this PR and #95. Let's merge #95 first and I'll deal with the conflicts.

One thing to note about this PR is the significant number of transitive dependencies that Heptio's healthcheck library pulls in:

  1. beorn7/perks
  2. matttproud/golang_protobuf_extensions
  3. prometheus/client_golang
  4. prometheus/common
  5. prometheus/procfs

If that list seems too big, we might consider the hand-rolled approach after all.

Copy link
Collaborator

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@markmandel
Copy link
Member

#95 is merged! 🔨 😁

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Just blocking until we confirm we are good on the health check URL path changes and install.yaml

Gopkg.toml Outdated
version = "1.8.0"
Copy link
Member

Choose a reason for hiding this comment

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

Super, super nitpicky, but can we keep a line between each constraint?

Having them right next to each other freaks me out ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely. Sorry for missing this. I agree it's nicer.

err = c.Run(2, stop)
if err != nil {
logrus.WithError(err).Fatal("Could not run gameserver controller")
}

logrus.Info("Shut down gameserver controller")
}

func startHealthCheck(h healthcheck.Handler) {
Copy link
Member

Choose a reason for hiding this comment

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

Curious why you wrote your own function, rather than just a:
go http.ListenAndServe("0.0.0.0:8086", health)

Keeping the logging? (Not a bad thing)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's mostly a matter of style. I like having all the things together so as to avoid any subtle closure state, which in turn makes it easy to extract the thing if there's ever a need. That said, I see the webhook goroutine is inline. So in the interest of consistency, I'll follow that pattern and we can move things around later if need be.

}
defer srv.Close() // nolint: errcheck

if err := srv.ListenAndServe(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I believe this will change the health check paths.

If so we'll need to update install.yaml to point to /live , otherwise this will break the controller and it would also be good to have a new readiness check too since this now exists (and because of #95 we actually have a service that this sits behind as well).

Copy link
Contributor Author

@enocom enocom Feb 23, 2018

Choose a reason for hiding this comment

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

I'll update install.yaml. What would a good readiness check of the game server be? Or a liveness check?

@markmandel
Copy link
Member

@enocom curious what your concern is over the extra dependencies. It's not something that has really bugged me in the past, but would be interested to hear what issues you might see arising from it.

@enocom
Copy link
Contributor Author

enocom commented Feb 23, 2018

@markmandel I like to be careful about pulling in dependencies just because they represent a certain amount of liability and risk. But the healthcheck library seems like a nice addition. So as long as you're OK with the transitive dependencies, I am too.

@enocom
Copy link
Contributor Author

enocom commented Feb 23, 2018

We need to decide on a good liveness check and maybe a readiness check too and presumably this PR will be done.

@markmandel
Copy link
Member

I don't know if this is possible, but what would make this controller healthy is that the goroutines generated in this code are still running and haven't exited in any way.

I just can't think of a way of doing that?

markmandel added a commit that referenced this pull request Feb 25, 2018
There were multiple places where queue and worker
goroutines pattern for controllers (and related) were
repeated in almost exactly the same ways.

Since there are more controllers coming, it made sense
to consolidate this logic into a centralised place that
could be reused to make authoring them easier.

This may also allow us to centralise some health checking in #98
markmandel added a commit that referenced this pull request Feb 25, 2018
There were multiple places where queue and worker
goroutines pattern for controllers (and related) were
repeated in almost exactly the same ways.

Since there are more controllers coming, it made sense
to consolidate this logic into a centralised place that
could be reused to make authoring them easier.

This may also allow us to centralise some health checking in #98
markmandel added a commit that referenced this pull request Feb 25, 2018
There were multiple places where queue and worker
goroutines pattern for controllers (and related) were
repeated in almost exactly the same ways.

Since there are more controllers coming, it made sense
to consolidate this logic into a centralised place that
could be reused to make authoring them easier.

This may also allow us to centralise some health checking in #98
markmandel added a commit that referenced this pull request Feb 25, 2018
There were multiple places where queue and worker
goroutines pattern for controllers (and related) were
repeated in almost exactly the same ways.

Since there are more controllers coming, it made sense
to consolidate this logic into a centralised place that
could be reused to make authoring them easier.

This may also allow us to centralise some health checking in #98
markmandel added a commit that referenced this pull request Feb 25, 2018
There were multiple places where queue and worker
goroutines pattern for controllers (and related) were
repeated in almost exactly the same ways.

Since there are more controllers coming, it made sense
to consolidate this logic into a centralised place that
could be reused to make authoring them easier.

This may also allow us to centralise some health checking in #98
markmandel added a commit that referenced this pull request Feb 25, 2018
There were multiple places where queue and worker
goroutines pattern for controllers (and related) were
repeated in almost exactly the same ways.

Since there are more controllers coming, it made sense
to consolidate this logic into a centralised place that
could be reused to make authoring them easier.

This may also allow us to centralise some health checking in #98
markmandel added a commit that referenced this pull request Feb 26, 2018
There were multiple places where queue and worker
goroutines pattern for controllers (and related) were
repeated in almost exactly the same ways.

Since there are more controllers coming, it made sense
to consolidate this logic into a centralised place that
could be reused to make authoring them easier.

This may also allow us to centralise some health checking in #98
@enocom
Copy link
Contributor Author

enocom commented Feb 26, 2018

@markmandel In the interest of finishing the 0.1 milestone, how would you feel if we moved adding a particular health check to the GameServer into a separate issue and associated PR?

@markmandel
Copy link
Member

@enocom Assuming you meant the healthcheck for the sdk sidecar, I think this makes a lot of sense.

If this feature also should be pushed to 0.2, that's also an option.

Rather than a handrolled solution, this commit uses heptio's healthcheck
library. Future consumers of the health check handler need only to
register liveness or readiness probes.

Update install.yaml to use /live for liveness check.

Also, inline health handler function for consistent style.
@enocom
Copy link
Contributor Author

enocom commented Feb 27, 2018

@markmandel I propose merging this PR with the heptio health check library and adding a liveness check to a 0.2 milestone. Since this PR touches a few places in the gameservers package, it's subject to endless merge conflicts -- I think I've fixed three now. What do you think?

@markmandel
Copy link
Member

SGTM!

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.

3 participants