mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 16:21:13 +00:00
Merge pull request #68388 from wgliang/fixbug/defer-in-loop
fix bug that defer in infinite loop
This commit is contained in:
commit
7ffaa2f713
@ -19,24 +19,23 @@ package vsphere
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/vmware/govmomi/vim25"
|
"github.com/vmware/govmomi/vim25"
|
||||||
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/vmware/govmomi/vim25/mo"
|
"github.com/vmware/govmomi/vim25/mo"
|
||||||
"io/ioutil"
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
k8stypes "k8s.io/apimachinery/pkg/types"
|
k8stypes "k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib/diskmanagers"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib/diskmanagers"
|
||||||
"k8s.io/kubernetes/pkg/util/version"
|
"k8s.io/kubernetes/pkg/util/version"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -298,12 +297,16 @@ func (vs *VSphere) cleanUpDummyVMs(dummyVMPrefix string) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// A write lock is acquired to make sure the cleanUp routine doesn't delete any VM's created by ongoing PVC requests.
|
// A write lock is acquired to make sure the cleanUp routine doesn't delete any VM's created by ongoing PVC requests.
|
||||||
defer cleanUpDummyVMLock.Lock()
|
cleanUpDummyVMs := func() {
|
||||||
|
cleanUpDummyVMLock.Lock()
|
||||||
|
defer cleanUpDummyVMLock.Unlock()
|
||||||
err = diskmanagers.CleanUpDummyVMs(ctx, vmFolder, dc)
|
err = diskmanagers.CleanUpDummyVMs(ctx, vmFolder, dc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(4).Infof("Unable to clean up dummy VM's in the kubernetes cluster: %q. err: %+v", vs.cfg.Workspace.Folder, err)
|
glog.V(4).Infof("Unable to clean up dummy VM's in the kubernetes cluster: %q. err: %+v", vs.cfg.Workspace.Folder, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cleanUpDummyVMs()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get canonical volume path for volume Path.
|
// Get canonical volume path for volume Path.
|
||||||
|
Loading…
Reference in New Issue
Block a user