Skip to content

Commit fabf531

Browse files
committed
Reduce metrics cardinality
1 parent 4cc5ca7 commit fabf531

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,13 +766,13 @@ func TestStatusCodeBasedCreationErrors(t *testing.T) {
766766
},
767767
{
768768
name: "CreateMachine",
769-
event: "Warning FailedCreate CreateError: failed to reconcile machine \"azure-actuator-testing-machine\"s: failed to create vm azure-actuator-testing-machine: failed to create or get machine: failed to create or get machine: compute.VirtualMachinesClient#CreateOrUpdate: MOCK: StatusCode=300",
769+
event: "Warning FailedCreate CreateError: failed to reconcile machine \"azure-actuator-testing-machine\"s: failed to create vm azure-actuator-testing-machine: failed to create VM: failed to create or get machine: compute.VirtualMachinesClient#CreateOrUpdate: MOCK: StatusCode=300",
770770
statusCode: 300,
771771
requeable: true,
772772
},
773773
{
774774
name: "CreateMachine",
775-
event: "Warning FailedCreate CreateError: failed to reconcile machine \"azure-actuator-testing-machine\"s: failed to create vm azure-actuator-testing-machine: failed to create or get machine: failed to create or get machine: compute.VirtualMachinesClient#CreateOrUpdate: MOCK: StatusCode=401",
775+
event: "Warning FailedCreate CreateError: failed to reconcile machine \"azure-actuator-testing-machine\"s: failed to create vm azure-actuator-testing-machine: failed to create VM: failed to create or get machine: compute.VirtualMachinesClient#CreateOrUpdate: MOCK: StatusCode=401",
776776
statusCode: 401,
777777
requeable: true,
778778
},

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ func (s *Reconciler) Delete(ctx context.Context) error {
483483
metrics.RegisterFailedInstanceDelete(&metrics.MachineLabels{
484484
Name: s.scope.Machine.Name,
485485
Namespace: s.scope.Machine.Namespace,
486-
Reason: err.Error(),
486+
Reason: "failed to delete OS disk",
487487
})
488488
return fmt.Errorf("failed to delete OS disk: %w", err)
489489
}
@@ -502,7 +502,7 @@ func (s *Reconciler) Delete(ctx context.Context) error {
502502
metrics.RegisterFailedInstanceDelete(&metrics.MachineLabels{
503503
Name: s.scope.Machine.Name,
504504
Namespace: s.scope.Machine.Namespace,
505-
Reason: err.Error(),
505+
Reason: "failed to delete network interface",
506506
})
507507
return fmt.Errorf("Unable to delete network interface: %w", err)
508508
}
@@ -526,7 +526,7 @@ func (s *Reconciler) Delete(ctx context.Context) error {
526526
metrics.RegisterFailedInstanceDelete(&metrics.MachineLabels{
527527
Name: s.scope.Machine.Name,
528528
Namespace: s.scope.Machine.Namespace,
529-
Reason: err.Error(),
529+
Reason: "failed to delete Public IP",
530530
})
531531
return fmt.Errorf("unable to delete Public IP: %w", err)
532532
}
@@ -565,7 +565,7 @@ func (s *Reconciler) createNetworkInterface(ctx context.Context, nicName string)
565565
metrics.RegisterFailedInstanceCreate(&metrics.MachineLabels{
566566
Name: s.scope.Machine.Name,
567567
Namespace: s.scope.Machine.Namespace,
568-
Reason: err.Error(),
568+
Reason: "failed to obtain instance type information",
569569
})
570570

571571
if errors.Is(err, resourceskus.ErrResourceNotFound) {
@@ -622,7 +622,7 @@ func (s *Reconciler) createNetworkInterface(ctx context.Context, nicName string)
622622
metrics.RegisterFailedInstanceCreate(&metrics.MachineLabels{
623623
Name: s.scope.Machine.Name,
624624
Namespace: s.scope.Machine.Namespace,
625-
Reason: err.Error(),
625+
Reason: "failed to create public IP",
626626
})
627627
return fmt.Errorf("unable to create Public IP: %w", err)
628628
}
@@ -634,7 +634,7 @@ func (s *Reconciler) createNetworkInterface(ctx context.Context, nicName string)
634634
metrics.RegisterFailedInstanceCreate(&metrics.MachineLabels{
635635
Name: s.scope.Machine.Name,
636636
Namespace: s.scope.Machine.Namespace,
637-
Reason: err.Error(),
637+
Reason: "failed to create VM network interface",
638638
})
639639
return fmt.Errorf("unable to create VM network interface: %w", err)
640640
}
@@ -702,14 +702,14 @@ func (s *Reconciler) createVirtualMachine(ctx context.Context, nicName, asName s
702702
metrics.RegisterFailedInstanceCreate(&metrics.MachineLabels{
703703
Name: s.scope.Machine.Name,
704704
Namespace: s.scope.Machine.Namespace,
705-
Reason: err.Error(),
705+
Reason: "failed to create VM",
706706
})
707707

708708
var detailedError autorest.DetailedError
709709
if errors.As(err, &detailedError) && detailedError.Message == "Failure sending request" {
710710
return machinecontroller.InvalidMachineConfiguration("failure sending request for machine %s: %v", s.scope.Machine.Name, err)
711711
}
712-
return fmt.Errorf("failed to create or get machine: %w", err)
712+
return fmt.Errorf("failed to create VM: %w", err)
713713
}
714714
} else if err != nil {
715715
return fmt.Errorf("failed to get vm: %w", err)

0 commit comments

Comments
 (0)