Skip to content

Commit b8b486b

Browse files
authored
Fix deletion request can receive empty provider id. (#39)
1 parent d9e3f9d commit b8b486b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/metal/core.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,18 @@ func (p *Provider) DeleteMachine(ctx context.Context, req *driver.DeleteMachineR
171171
return nil, status.Error(codes.Internal, err.Error())
172172
}
173173

174+
if req.Machine.Spec.ProviderID == "" {
175+
klog.Infof("machine has no provider id attached anymore, already deleted and therefore skipping deletion")
176+
return &driver.DeleteMachineResponse{}, nil
177+
}
178+
174179
id := decodeMachineID(req.Machine.Spec.ProviderID)
175180

176181
mfr := &models.V1MachineFindRequest{
177182
ID: id,
178183
AllocationProject: providerSpec.Project,
179184
Tags: []string{fmt.Sprintf("%s=%s", tag.ClusterID, clusterIDTag)},
185+
AllocationRole: models.V1MachineAllocationRoleMachine,
180186
}
181187

182188
resp, err := m.Machine().FindMachines(machine.NewFindMachinesParams().WithBody(mfr), nil)

0 commit comments

Comments
 (0)