-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prototype implementation for managing healthcheck (#91)
* prototype implementation for managing healthcheck - healthcheck service invokes get public key api to verify connectivity with the PKCS11 device - oorhandler exposes InRotation function which can be managed via SIGUSR1 and SIGUSR2 signals - server starts a https listener utilizing healthcheck service and oor handler. Load balancer can be configured to use this this https listener. * proto regen and bump deps * license and lint fixes * update go version * address comments
- Loading branch information
Showing
17 changed files
with
753 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2022 Yahoo. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package healthcheck implements health check service for crypki. | ||
package healthcheck | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/theparanoids/crypki/api" | ||
"github.com/theparanoids/crypki/proto" | ||
) | ||
|
||
// Service implements proto.HealthCheckServer | ||
type Service struct { | ||
proto.UnimplementedHealthServer | ||
SigningService *api.SigningService | ||
KeyID string | ||
// InRotation returns true if the instance is intended to serve traffic, false otherwise. | ||
InRotation func() bool | ||
} | ||
|
||
// Check implements the health check service for crypki. | ||
// Based on InRotation() and GetUserSSHCertificateSigningKey() api, it will report appropriate status. | ||
func (s *Service) Check(ctx context.Context, r *proto.HealthCheckRequest) (*proto.HealthCheckResponse, error) { | ||
if s.InRotation == nil || !s.InRotation() { | ||
return &proto.HealthCheckResponse{Status: proto.HealthCheckResponse_NOT_SERVING}, nil | ||
} | ||
_, err := s.SigningService.GetUserSSHCertificateSigningKey(ctx, &proto.KeyMeta{Identifier: s.KeyID}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &proto.HealthCheckResponse{Status: proto.HealthCheckResponse_SERVING}, nil | ||
} |
Oops, something went wrong.