From ab7343f8de3113eee29085b75b67f38111cee82f Mon Sep 17 00:00:00 2001 From: rfyiamcool Date: Wed, 6 Nov 2024 17:22:08 +0800 Subject: [PATCH] fix(zfs): timer stop when checkVolCreation exit --- 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)