Skip to content

Commit

Permalink
Merge pull request #175 from DataDog/fricounet/probe-first
Browse files Browse the repository at this point in the history
Restore ProbeForever behavior of probing first before sleeping
  • Loading branch information
k8s-ci-robot authored May 30, 2024
2 parents 565ff53 + a8003ad commit e2e2abb
Showing 1 changed file with 23 additions and 20 deletions.
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

0 comments on commit e2e2abb

Please sign in to comment.