Skip to content

Commit

Permalink
fix(zfs): timer stop when checkVolCreation exit
Browse files Browse the repository at this point in the history
  • Loading branch information
rfyiamcool committed Nov 7, 2024
1 parent b2f57b9 commit c193520
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 c193520

Please sign in to comment.