Skip to content

Commit

Permalink
fix(zfs): timer stop when checkVolCreation exit (#600)
Browse files Browse the repository at this point in the history
Signed-off-by: rfyiamcool <[email protected]>
  • Loading branch information
rfyiamcool authored Nov 27, 2024
1 parent 98610ac commit 51972c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/zfs/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ func GetNodeID(nodename string) (string, error) {
}

func checkVolCreation(ctx context.Context, volname string) (bool, error) {
timeout := time.After(10 * time.Second)
timeout := time.NewTimer(10 * time.Second)
defer timeout.Stop()

for {
select {
case <-ctx.Done():
return true, fmt.Errorf("zfs: context deadline reached")
case <-timeout:
case <-timeout.C:
return true, fmt.Errorf("zfs: vol creation timeout reached")
default:
vol, err := GetZFSVolume(volname)
Expand Down

0 comments on commit 51972c4

Please sign in to comment.