Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pkg/controller/deployment_machineset_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,11 @@ func calculateMachineSetStatus(is *v1alpha1.MachineSet, filteredMachines []*v1al
}
}

// Update the FailedMachines field only if we see new failures
// Clear FailedMachines if ready replicas equals total replicas,
// which means the machineset doesn't have any machine objects which are in any failed state
// #nosec G115 -- number of machines will not exceed MaxInt32
// Update the FailedMachines field when we see new failures
// Set the FailedMachines field to nil if there are no failed machines.
if len(failedMachines) > 0 {
newStatus.FailedMachines = &failedMachines
} else if int32(readyReplicasCount) == is.Status.Replicas {
} else {
newStatus.FailedMachines = nil
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func updateMachineSetStatusRelatedMetric(machineSet *v1alpha1.MachineSet, msMeta
}

func updateMachineSetStatusFailedMachinesMetric(machineSet *v1alpha1.MachineSet, msMeta metav1.ObjectMeta) {
metrics.MachineSetStatusFailedMachines.DeletePartialMatch(prometheus.Labels{
"name": msMeta.Name,
"namespace": msMeta.Namespace,
})

if machineSet.Status.FailedMachines != nil {
for _, failedMachine := range *machineSet.Status.FailedMachines {
metrics.MachineSetStatusFailedMachines.With(prometheus.Labels{
Expand Down
Loading