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

Introduce health check grpc service to Signer #902

Merged
merged 7 commits into from
Aug 19, 2016
Merged

Introduce health check grpc service to Signer #902

merged 7 commits into from
Aug 19, 2016

Conversation

HuKeping
Copy link
Contributor

@HuKeping HuKeping commented Aug 9, 2016

Fixes #894
Fixes #917

As per SPEC:
https://github.com/grpc/grpc/blob/master/doc/health-checking.md

We hook a health check service into notary-signer along with
the normal services, say "KeyManagement" and "Signer".

After booting "KeyManagement" and "Signer", we set the health status
of each to be "SERVING" which would be returned as the status of
service on the health checking time.

Signed-off-by: Hu Keping hukeping@huawei.com

@docker-jenkins
Copy link

Can one of the admins verify this patch?

@riyazdf
Copy link
Contributor

riyazdf commented Aug 9, 2016

jenkins, test this please.

// The server will use an empty string as the key for server's overall health status,
// so that a client not interested in a specific service can query the server's status
// with an empty service name.
err := notarySigner.CheckHealth(duration, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test for CheckHealth with the empty service argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test added

@riyazdf
Copy link
Contributor

riyazdf commented Aug 11, 2016

jenkins, test this please


}

// TestHealthCheckUnExistsService query for an un-exists service's health status
Copy link
Contributor

@riyazdf riyazdf Aug 11, 2016

Choose a reason for hiding this comment

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

nit: can we change an un-exists to a nonexistent here, in the function name, and in the comment below?

@HuKeping
Copy link
Contributor Author

updated

@riyazdf
Copy link
Contributor

riyazdf commented Aug 12, 2016

jenkins, test this please.

}

// healthCheckHealthy succeeds if server is healthy and reachable.
func healthCheckKMHealthy(t *testing.T, serviceName string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: function name should probably be healthCheckHealthy to match the description

@riyazdf
Copy link
Contributor

riyazdf commented Aug 12, 2016

LGTM after nits! Thank you @HuKeping for your work on this :)

// healthCheckConnectionDied fails immediately if not connected to the server.
func healthCheckConnectionDied(t *testing.T, serviceName string) {
hs := health.NewServer()
hs.SetServingStatus(serviceName, healthpb.HealthCheckResponse_NOT_SERVING)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we change this to healthpb.HealthCheckResponse_SERVING so that the only reason it should be failing is the disconnection?

@cyli
Copy link
Contributor

cyli commented Aug 12, 2016

Thank you all your work on this! LGTM after the two minor nitpick changes!

@HuKeping
Copy link
Contributor Author

HuKeping commented Aug 13, 2016

Updated. After this PR, we could also regenerate the proto of signer, I think at least the Void structure could be dropped. I'd like to do it in another separated PR if you don't mind.

@HuKeping HuKeping mentioned this pull request Aug 15, 2016
@HuKeping
Copy link
Contributor Author

ping ...

@riyazdf
Copy link
Contributor

riyazdf commented Aug 17, 2016

@HuKeping thanks for checking in.

I think @cyli and I still have a couple of unresolved nit comments on healthCheckConnectionDied and healthCheckKMHealthy - are those proposed changes okay with you?

@HuKeping
Copy link
Contributor Author

Oh I must have forgotten to commit that !

@riyazdf
Copy link
Contributor

riyazdf commented Aug 17, 2016

No problem, thank you for updating! LGTM pending CI

@riyazdf
Copy link
Contributor

riyazdf commented Aug 17, 2016

jenkins, test this please.

@HuKeping
Copy link
Contributor Author

HuKeping commented Aug 17, 2016

Sorry for having you review this again @riyazdf @cyli , I just pushed a new commit into this PR to remove all the unused code from proto/signer.proto and the relatives as #917 , plz take a look in case I missing anything.

@@ -1,12 +1,12 @@
// Code generated by protoc-gen-go.
// source: proto/signer.proto
// source: signer.proto
Copy link
Contributor

@riyazdf riyazdf Aug 17, 2016

Choose a reason for hiding this comment

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

huh this change seems unexpected, do we know why this changed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's relative from where you run the protoc command. If you run make protos from the main repo directory you get proto/signer.proto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, updated!

@cyli
Copy link
Contributor

cyli commented Aug 18, 2016

jenkins, test this please

@riyazdf
Copy link
Contributor

riyazdf commented Aug 18, 2016

@HuKeping: thanks for updating the protos, LGTM!

@cyli
Copy link
Contributor

cyli commented Aug 18, 2016

Thanks @HuKeping! LGTM pending CI!

@HuKeping
Copy link
Contributor Author

HuKeping commented Aug 18, 2016

Every time this happens,
when I walked into the night,
you are in light,
when I'm finally get into the sunshine,
you rest under the moonlight .
At that time I always wander,
what's the hell did Colombo said,
THE WORLD IS ROUND!

As per SPEC:
https://github.com/grpc/grpc/blob/master/doc/health-checking.md

We hook a health check service into notary-signer along with
the normal services, say "KeyManagement" and "Signer".

After booting "KeyManagement" and "Signer", we set the health status
of each to be "SERVING" which would be returned as the status of
service on the health checking time.

Signed-off-by: Hu Keping <hukeping@huawei.com>
As per riyazdf's suggestion, this patch fixes:
- Remove an unused function
- Cleanup comments
- Add a test for health check of the overall status
- Change the place of function "CheckHealth" - for better code review
  on github.

Signed-off-by: Hu Keping <hukeping@huawei.com>
1) Create three constants for different grpc services.

2) Create two helper function used to check the health status of Signer
and KeyManagement.

3) Due to 2), we refator the CheckHealth function to use switch to
see which service's health status was required.

Signed-off-by: Hu Keping <hukeping@huawei.com>
Signed-off-by: Hu Keping <hukeping@huawei.com>
Create some helper functions and refactor the health check test.

Signed-off-by: Hu Keping <hukeping@huawei.com>
Signed-off-by: Hu Keping <hukeping@huawei.com>
Signed-off-by: Hu Keping <hukeping@huawei.com>
@riyazdf
Copy link
Contributor

riyazdf commented Aug 18, 2016

jenkins, test this please.

@riyazdf
Copy link
Contributor

riyazdf commented Aug 18, 2016

thanks for regenerating the protos and all of your work on this 👍

@cyli
Copy link
Contributor

cyli commented Aug 18, 2016

LGTM! Thank you for all your work on adding this!

@HuKeping
Copy link
Contributor Author

ping :)

@riyazdf
Copy link
Contributor

riyazdf commented Aug 19, 2016

CI green, merging :)

@riyazdf riyazdf merged commit 7d4b66f into notaryproject:master Aug 19, 2016
@HuKeping HuKeping deleted the health-check-signer branch August 19, 2016 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants