Skip to content

Commit 8182af8

Browse files
Merge pull request #56 from odvarkadaniel/failed-machine-disks
OCPBUGS-10762: Machine should be Failed if Machine has a Failed state on Azure
2 parents 83b07d5 + e5e75b8 commit 8182af8

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pkg/cloud/azure/actuators/machine/actuator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/openshift/machine-api-provider-azure/pkg/cloud/azure"
2929
"github.com/openshift/machine-api-provider-azure/pkg/cloud/azure/actuators"
3030
corev1 "k8s.io/api/core/v1"
31+
apierrors "k8s.io/apimachinery/pkg/api/errors"
3132
"k8s.io/client-go/tools/record"
3233
"k8s.io/klog/v2"
3334
controllerclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -221,6 +222,9 @@ func (a *Actuator) Exists(ctx context.Context, machine *machinev1.Machine) (bool
221222
}
222223

223224
isExists, err := a.reconcilerBuilder(scope).Exists(context.Background())
225+
if apierrors.IsUnexpectedObjectError(err) {
226+
return isExists, nil
227+
}
224228
if err != nil {
225229
klog.Errorf("failed to check machine %s exists: %v", machine.Name, err)
226230
}

pkg/cloud/azure/actuators/machine/reconciler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"github.com/openshift/machine-api-provider-azure/pkg/cloud/azure/services/virtualmachineextensions"
4545
"github.com/openshift/machine-api-provider-azure/pkg/cloud/azure/services/virtualmachines"
4646
apicorev1 "k8s.io/api/core/v1"
47+
apierrors "k8s.io/apimachinery/pkg/api/errors"
4748
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4849
"k8s.io/klog/v2"
4950
"k8s.io/utils/pointer"
@@ -448,7 +449,10 @@ func (s *Reconciler) Exists(ctx context.Context) (bool, error) {
448449
case machinev1.VMStateDeleting:
449450
return true, fmt.Errorf("vm for machine %s has unexpected 'Deleting' provisioning state", s.scope.Machine.GetName())
450451
case machinev1.VMStateFailed:
451-
return true, fmt.Errorf("vm for machine %s exists, but has unexpected 'Failed' provisioning state", s.scope.Machine.GetName())
452+
klog.Infof("vm for machine %s has unexpected 'Failed' provisioning state", s.scope.Machine.GetName())
453+
return false, &apierrors.UnexpectedObjectError{
454+
Object: s.scope.Machine,
455+
}
452456
}
453457

454458
klog.Infof("Provisioning state is '%s' for machine %s", *vm.ProvisioningState, s.scope.Machine.GetName())

pkg/cloud/azure/actuators/machine/reconciler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestExists(t *testing.T) {
8585
ID: "machine-test-ID",
8686
ProvisioningState: "Failed",
8787
},
88-
expected: true,
88+
expected: false,
8989
errExpected: true,
9090
},
9191
{

0 commit comments

Comments
 (0)