Skip to content

Conversation

@googs1025
Copy link
Contributor

To improve observability and facilitate debugging, this PR enhances logging after the GRPC server crashes

@copy-pr-bot
Copy link

copy-pr-bot bot commented Dec 11, 2024

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@googs1025
Copy link
Contributor Author

friendly ping @elezar /PTAL thanks

@googs1025
Copy link
Contributor Author

@cdesiniotis can you help this ?

Copy link
Member

@elezar elezar left a comment

Choose a reason for hiding this comment

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

Since we're changing this anyway. Let's use the built-in types.

lastCrashTime := time.Now()
restartCount := 0
maxRestarts := 5
crashTimeoutSeconds := float64(3600) // 1 hour in seconds
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
crashTimeoutSeconds := float64(3600) // 1 hour in seconds
crashTimeout := 1 * time.Hour


klog.Infof("GRPC server for '%s' crashed with error: %v", plugin.rm.Resource(), err)

timeSinceLastCrash := time.Since(lastCrashTime).Seconds()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
timeSinceLastCrash := time.Since(lastCrashTime).Seconds()
timeSinceLastCrash := time.Since(lastCrashTime)

timeSinceLastCrash,
)

if timeSinceLastCrash > crashTimeoutSeconds {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if timeSinceLastCrash > crashTimeoutSeconds {
if timeSinceLastCrash > crashTimeout {

plugin.rm.Resource(),
err,
restartCount+1,
timeSinceLastCrash,
Copy link
Member

Choose a reason for hiding this comment

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

You probably need:

Suggested change
timeSinceLastCrash,
timeSinceLastCrash.Seconds(),

or need to adjust the format string.

// add a small delay before restarting to prevent tight loops
retryDelay := 5 * time.Second
klog.Infof("Waiting for %v before attempting to restart GRPC server for '%s'", retryDelay, plugin.rm.Resource())
time.Sleep(retryDelay) // Wait for 5 seconds before attempting to restart
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
time.Sleep(retryDelay) // Wait for 5 seconds before attempting to restart
time.Sleep(retryDelay)

restartCount++
}

// add a small delay before restarting to prevent tight loops
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason that you chose 5 seconds specifically? This seems quite long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, 5 seconds is too long, I changed it to 500 Millisecond. wdyt 🤔

Comment on lines 215 to 216
// it has been one hour since the last crash.. reset the count
// to reflect on the frequency
Copy link
Member

Choose a reason for hiding this comment

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

Let's rather just log the crashTimeout instead of a comment that is now further from the place where the one hour is specified.

Comment on lines 190 to 191
// quite if it has been restarted too often
// i.e. if server has crashed more than 5 times and it didn't last more than one hour each time
Copy link
Member

Choose a reason for hiding this comment

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

This comment should be moved to the docstring or at the point where we declare the variables.

Signed-off-by: googs1025 <googs1025@gmail.com>
@googs1025
Copy link
Contributor Author

friendly ping @elezar :) /PTAL

@googs1025 googs1025 requested a review from elezar April 12, 2025 05:17
@googs1025 googs1025 closed this Nov 21, 2025
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.

2 participants