From 611b755c89b27d8bc28cab2269258040c20e31fd Mon Sep 17 00:00:00 2001 From: rfyiamcool Date: Thu, 7 Nov 2024 13:07:31 +0800 Subject: [PATCH] fix(zfs): timer stop when checkVolCreation exit Signed-off-by: rfyiamcool --- pkg/zfs/volume.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/zfs/volume.go b/pkg/zfs/volume.go index 350678abe..44a75427c 100644 --- a/pkg/zfs/volume.go +++ b/pkg/zfs/volume.go @@ -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)