From 51972c4a5502abeb12a78460a87162c9bb75073b Mon Sep 17 00:00:00 2001 From: "fengyun.rui" Date: Wed, 27 Nov 2024 22:29:35 +0800 Subject: [PATCH] fix(zfs): timer stop when checkVolCreation exit (#600) 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)