-
Notifications
You must be signed in to change notification settings - Fork 94
CD health check: adjust naming and log messages for clarity #657
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
Open
jgehrcke
wants to merge
1
commit into
NVIDIA:main
Choose a base branch
from
jgehrcke:jp/cd-plugin-healthcheck-log
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -46,16 +46,17 @@ type healthcheck struct { | |
| draClient drapb.DRAPluginClient | ||
| } | ||
|
|
||
| func startHealthcheck(ctx context.Context, config *Config) (*healthcheck, error) { | ||
| func setupHealthcheckPrimitives(ctx context.Context, config *Config) (*healthcheck, error) { | ||
| port := config.flags.healthcheckPort | ||
| if port < 0 { | ||
| return nil, nil | ||
| } | ||
|
|
||
| // Bind on all available interfaces. | ||
| addr := net.JoinHostPort("", strconv.Itoa(port)) | ||
| lis, err := net.Listen("tcp", addr) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to listen for healthcheck service at %s: %w", addr, err) | ||
| return nil, fmt.Errorf("failed to listen on %s: %w", addr, err) | ||
| } | ||
|
|
||
| regSockPath := (&url.URL{ | ||
|
|
@@ -64,26 +65,28 @@ func startHealthcheck(ctx context.Context, config *Config) (*healthcheck, error) | |
| // are enabled and the filename includes a uid. | ||
| Path: path.Join(config.flags.kubeletRegistrarDirectoryPath, DriverName+"-reg.sock"), | ||
| }).String() | ||
| klog.V(6).Infof("connecting to registration socket path=%s", regSockPath) | ||
|
|
||
| klog.V(6).Infof("Connect to registration socket at %s", regSockPath) | ||
| regConn, err := grpc.NewClient( | ||
| regSockPath, | ||
| grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
| ) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("connect to registration socket: %w", err) | ||
| return nil, fmt.Errorf("error connecting to registration socket: %w", err) | ||
| } | ||
|
|
||
| draSockPath := (&url.URL{ | ||
| Scheme: "unix", | ||
| Path: path.Join(config.DriverPluginPath(), "dra.sock"), | ||
| }).String() | ||
| klog.V(6).Infof("connecting to DRA socket path=%s", draSockPath) | ||
|
|
||
| klog.V(6).Infof("Connect to plugin socket at %s", draSockPath) | ||
| draConn, err := grpc.NewClient( | ||
| draSockPath, | ||
| grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
| ) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("connect to DRA socket: %w", err) | ||
| return nil, fmt.Errorf("error connecting to plugin socket: %w", err) | ||
| } | ||
|
|
||
| server := grpc.NewServer() | ||
|
|
@@ -97,9 +100,10 @@ func startHealthcheck(ctx context.Context, config *Config) (*healthcheck, error) | |
| healthcheck.wg.Add(1) | ||
| go func() { | ||
| defer healthcheck.wg.Done() | ||
| klog.Infof("starting healthcheck service at %s", lis.Addr().String()) | ||
| klog.Infof("Starting healthcheck server on %s", lis.Addr().String()) | ||
| if err := server.Serve(lis); err != nil { | ||
| klog.Errorf("failed to serve healthcheck service on %s: %v", addr, err) | ||
| // Note(JP): let's review if this should be fatal | ||
| klog.Errorf("failed to start healthcheck server: %v", err) | ||
| } | ||
| }() | ||
|
|
||
|
|
@@ -108,13 +112,13 @@ func startHealthcheck(ctx context.Context, config *Config) (*healthcheck, error) | |
|
|
||
| func (h *healthcheck) Stop() { | ||
| if h.server != nil { | ||
| klog.Info("Stopping healthcheck service") | ||
| klog.Info("Stopping healthcheck server") | ||
| h.server.GracefulStop() | ||
| } | ||
| h.wg.Wait() | ||
| } | ||
|
|
||
| // Check implements [grpc_health_v1.HealthServer]. | ||
| // Check implements [grpc_health_v1.HealthServer.Check]. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previous discussion: #633 (comment) |
||
| func (h *healthcheck) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) { | ||
| knownServices := map[string]struct{}{"": {}, "liveness": {}} | ||
| if _, known := knownServices[req.GetService()]; !known { | ||
|
|
@@ -125,16 +129,19 @@ func (h *healthcheck) Check(ctx context.Context, req *grpc_health_v1.HealthCheck | |
| Status: grpc_health_v1.HealthCheckResponse_NOT_SERVING, | ||
| } | ||
|
|
||
| // This simulates the kubelet reaching out to the plugin for discovery | ||
| // (towards registering it). | ||
| info, err := h.regClient.GetInfo(ctx, ®isterapi.InfoRequest{}) | ||
| if err != nil { | ||
| klog.ErrorS(err, "failed to call GetInfo") | ||
| klog.ErrorS(err, "failed to call GetInfo on registration socket") | ||
| return status, nil | ||
| } | ||
| klog.V(6).Infof("Successfully invoked GetInfo: %v", info) | ||
|
|
||
| // This simulates the kubelet reaching out to the plugin | ||
| _, err = h.draClient.NodePrepareResources(ctx, &drapb.NodePrepareResourcesRequest{}) | ||
| if err != nil { | ||
| klog.ErrorS(err, "failed to call NodePrepareResources") | ||
| klog.ErrorS(err, "failed to call NodePrepareResources on plugin socket") | ||
| return status, nil | ||
| } | ||
| klog.V(6).Info("Successfully invoked NodePrepareResources") | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
previous discussion: #633 (comment)