Skip to content

Commit 6240c80

Browse files
fix the bug of checking nodes (#238)
1 parent e32a3d7 commit 6240c80

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/cloudprovider/huaweicloud/instances.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ func (i *Instances) NodeAddressesByProviderID(_ context.Context, providerID stri
8282
func (i *Instances) InstanceID(_ context.Context, name types.NodeName) (string, error) {
8383
klog.Infof("InstanceID is called with name %s", name)
8484
server, err := i.ecsClient.GetByNodeName(string(name))
85+
8586
if err != nil {
87+
if common.IsNotFound(err) {
88+
return "", nil
89+
}
8690
return "", err
8791
}
8892
return server.Id, nil
@@ -175,8 +179,16 @@ func (i *Instances) InstanceShutdownByProviderID(_ context.Context, providerID s
175179

176180
// InstanceExists returns true if the instance for the given node exists according to the cloud provider.
177181
func (i *Instances) InstanceExists(ctx context.Context, node *v1.Node) (bool, error) {
178-
klog.Infof("InstanceExists is called with node %s/%s", node.Namespace, node.Name)
179-
return i.InstanceExistsByProviderID(ctx, node.Spec.ProviderID)
182+
klog.Infof("InstanceExists is called with node %s", node.Name)
183+
_, err := i.ecsClient.GetByNodeName(node.Name)
184+
185+
if err != nil {
186+
if common.IsNotFound(err) {
187+
return false, nil
188+
}
189+
return false, err
190+
}
191+
return true, nil
180192
}
181193

182194
// InstanceShutdown returns true if the instance is shutdown according to the cloud provider.

0 commit comments

Comments
 (0)