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

Restore ProbeForever behavior of probing first before sleeping #175

Merged
merged 2 commits into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions rpc/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,32 +136,35 @@ func GetGroupControllerCapabilities(ctx context.Context, conn *grpc.ClientConn)
func ProbeForever(ctx context.Context, conn *grpc.ClientConn, singleProbeTimeout time.Duration) error {
logger := klog.FromContext(ctx)
ticker := time.NewTicker(probeInterval)
defer ticker.Stop()

for {
// Run the probe once before waiting for the ticker
logger.Info("Probing CSI driver for readiness")
ready, err := probeOnce(ctx, conn, singleProbeTimeout)
if err != nil {
st, ok := status.FromError(err)
if !ok {
// This is not gRPC error. The probe must have failed before gRPC
// method was called, otherwise we would get gRPC error.
return fmt.Errorf("CSI driver probe failed: %s", err)
}
if st.Code() != codes.DeadlineExceeded {
return fmt.Errorf("CSI driver probe failed: %s", err)
}
// Timeout -> driver is not ready. Fall through to sleep() below.
logger.Info("CSI driver probe timed out")
} else {
if ready {
return nil
}
logger.Info("CSI driver is not ready")
}
select {
case <-ctx.Done():
return ctx.Err()
case <-ticker.C:
logger.Info("Probing CSI driver for readiness")
ready, err := probeOnce(ctx, conn, singleProbeTimeout)
if err != nil {
st, ok := status.FromError(err)
if !ok {
// This is not gRPC error. The probe must have failed before gRPC
// method was called, otherwise we would get gRPC error.
return fmt.Errorf("CSI driver probe failed: %s", err)
}
if st.Code() != codes.DeadlineExceeded {
return fmt.Errorf("CSI driver probe failed: %s", err)
}
// Timeout -> driver is not ready. Fall through to sleep() below.
logger.Info("CSI driver probe timed out")
} else {
if ready {
return nil
}
logger.Info("CSI driver is not ready")
}
continue
}
}
}
Expand Down