Skip to content

Commit

Permalink
fix: reduce crp throttling in attach disk scenario
Browse files Browse the repository at this point in the history
fix golint
  • Loading branch information
andyzhangx committed May 9, 2021
1 parent 7285c2e commit b4c413f
Show file tree
Hide file tree
Showing 15 changed files with 247 additions and 91 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ replace (
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.21.0
k8s.io/sample-controller => k8s.io/sample-controller v0.21.0

sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210429115850-450dd74c84e6
sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210509025847-cb8b9f330ffa
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15 h1:4uqm9Mv+w2MmBYD+F4qf/v6tDFUdPOk29C095RbU5mY=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210429115850-450dd74c84e6 h1:T66QlmCOM+ViaqW2lb8NGHnIHHDR1k52lkSI7yVFWNk=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210429115850-450dd74c84e6/go.mod h1:wt7ijmWLw2zKIqr2Ncjtgjc/b0uWOqrS5BeXy5AAsio=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210509025847-cb8b9f330ffa h1:v5DmhwVqyq/stJkwArg582BD4yZIXfPUzRKvU2l41Lc=
sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210509025847-cb8b9f330ffa/go.mod h1:wt7ijmWLw2zKIqr2Ncjtgjc/b0uWOqrS5BeXy5AAsio=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/kustomize/api v0.8.5/go.mod h1:M377apnKT5ZHJS++6H4rQoCHmWtt6qTpp3mbe7p6OLY=
sigs.k8s.io/kustomize/cmd/config v0.9.7/go.mod h1:MvXCpHs77cfyxRmCNUQjIqCmZyYsbn5PyQpWiq44nW0=
Expand Down
4 changes: 3 additions & 1 deletion pkg/azuredisk/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func GetCloudProvider(kubeconfig string) (*azure.Cloud, error) {
if kubeClient != nil {
klog.V(2).Infof("reading cloud config from secret")
az.KubeClient = kubeClient
az.InitializeCloudFromSecret()
if err := az.InitializeCloudFromSecret(); err != nil {
klog.V(2).Infof("InitializeCloudFromSecret failed with error: %v", err)
}
}

if az.TenantID == "" || az.SubscriptionID == "" || az.ResourceGroup == "" {
Expand Down
5 changes: 5 additions & 0 deletions pkg/azuredisk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
klog.V(2).Infof("Attach operation successful: volume %q attached to node %q.", diskURI, nodeName)
} else {
if derr, ok := err.(*volerr.DanglingAttachError); ok {
if strings.EqualFold(string(nodeName), string(derr.CurrentNode)) {
err := fmt.Errorf("volume %q is actually attached to current node %q, return error", diskURI, nodeName)
klog.Warningf("%v", err)
return nil, err
}
klog.Warningf("volume %q is already attached to node %q, try detach first", diskURI, derr.CurrentNode)
if err = d.cloud.DetachDisk(diskName, diskURI, derr.CurrentNode); err != nil {
return nil, status.Errorf(codes.Internal, "Could not detach volume %q from node %q: %v", diskURI, derr.CurrentNode, err)
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ k8s.io/utils/trace
# sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15
sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client
sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client
# sigs.k8s.io/cloud-provider-azure v0.7.4 => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210429115850-450dd74c84e6
# sigs.k8s.io/cloud-provider-azure v0.7.4 => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210509025847-cb8b9f330ffa
## explicit
sigs.k8s.io/cloud-provider-azure/pkg/auth
sigs.k8s.io/cloud-provider-azure/pkg/azureclients
Expand Down Expand Up @@ -945,4 +945,4 @@ sigs.k8s.io/yaml
# k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.21.0
# k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.21.0
# k8s.io/sample-controller => k8s.io/sample-controller v0.21.0
# sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210429115850-450dd74c84e6
# sigs.k8s.io/cloud-provider-azure => sigs.k8s.io/cloud-provider-azure v0.7.4-0.20210509025847-cb8b9f330ffa

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions vendor/sigs.k8s.io/cloud-provider-azure/pkg/consts/consts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 35 additions & 4 deletions vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b4c413f

Please sign in to comment.