Skip to content

Commit

Permalink
always passing the formating string in required func
Browse files Browse the repository at this point in the history
  • Loading branch information
unnatiagg committed Aug 29, 2024
1 parent 85d1fe3 commit cd4938c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion controller/linodefirewall_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (r *LinodeFirewallReconciler) reconcile(
if err != nil {
fwScope.LinodeFirewall.Status.FailureReason = util.Pointer(failureReason)
fwScope.LinodeFirewall.Status.FailureMessage = util.Pointer(err.Error())
conditions.MarkFalse(fwScope.LinodeFirewall, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, err.Error())
conditions.MarkFalse(fwScope.LinodeFirewall, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())
r.Recorder.Event(fwScope.LinodeFirewall, corev1.EventTypeWarning, string(failureReason), err.Error())
}

Expand Down
2 changes: 1 addition & 1 deletion controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (r *LinodeMachineReconciler) reconcile(
machineScope.LinodeMachine.Status.FailureReason = util.Pointer(failureReason)
machineScope.LinodeMachine.Status.FailureMessage = util.Pointer(err.Error())

conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, err.Error())
conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())

r.Recorder.Event(machineScope.LinodeMachine, corev1.EventTypeWarning, string(failureReason), err.Error())
}
Expand Down
7 changes: 4 additions & 3 deletions controller/linodemachine_controller_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ func createDisks(ctx context.Context, logger logr.Logger, machineScope *scope.Ma
ConditionPreflightAdditionalDisksCreated,
string(cerrs.CreateMachineError),
clusterv1.ConditionSeverityWarning,
"%s",
err.Error(),
)
return err
Expand All @@ -561,7 +562,7 @@ func resizeRootDisk(ctx context.Context, logger logr.Logger, machineScope *scope
if err != nil {
logger.Error(err, "Failed to get default instance configuration")

conditions.MarkFalse(machineScope.LinodeMachine, ConditionPreflightRootDiskResized, string(cerrs.CreateMachineError), clusterv1.ConditionSeverityWarning, err.Error())
conditions.MarkFalse(machineScope.LinodeMachine, ConditionPreflightRootDiskResized, string(cerrs.CreateMachineError), clusterv1.ConditionSeverityWarning, "%s", err.Error())
return err
}

Expand All @@ -579,7 +580,7 @@ func resizeRootDisk(ctx context.Context, logger logr.Logger, machineScope *scope
if err != nil {
logger.Error(err, "Failed to get root disk for instance")

conditions.MarkFalse(machineScope.LinodeMachine, ConditionPreflightRootDiskResizing, string(cerrs.CreateMachineError), clusterv1.ConditionSeverityWarning, err.Error())
conditions.MarkFalse(machineScope.LinodeMachine, ConditionPreflightRootDiskResizing, string(cerrs.CreateMachineError), clusterv1.ConditionSeverityWarning, "%s", err.Error())

return err
}
Expand All @@ -594,7 +595,7 @@ func resizeRootDisk(ctx context.Context, logger logr.Logger, machineScope *scope
}

if err := machineScope.LinodeClient.ResizeInstanceDisk(ctx, linodeInstanceID, rootDiskID, diskSize); err != nil {
conditions.MarkFalse(machineScope.LinodeMachine, ConditionPreflightRootDiskResizing, string(cerrs.CreateMachineError), clusterv1.ConditionSeverityWarning, err.Error())
conditions.MarkFalse(machineScope.LinodeMachine, ConditionPreflightRootDiskResizing, string(cerrs.CreateMachineError), clusterv1.ConditionSeverityWarning, "%s", err.Error())
return err
}
conditions.MarkTrue(machineScope.LinodeMachine, ConditionPreflightRootDiskResizing)
Expand Down
2 changes: 1 addition & 1 deletion controller/linodeplacementgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *LinodePlacementGroupReconciler) reconcile(
pgScope.LinodePlacementGroup.Status.FailureReason = util.Pointer(failureReason)
pgScope.LinodePlacementGroup.Status.FailureMessage = util.Pointer(err.Error())

conditions.MarkFalse(pgScope.LinodePlacementGroup, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, err.Error())
conditions.MarkFalse(pgScope.LinodePlacementGroup, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())

r.Recorder.Event(pgScope.LinodePlacementGroup, corev1.EventTypeWarning, string(failureReason), err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion controller/linodevpc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *LinodeVPCReconciler) reconcile(
vpcScope.LinodeVPC.Status.FailureReason = util.Pointer(failureReason)
vpcScope.LinodeVPC.Status.FailureMessage = util.Pointer(err.Error())

conditions.MarkFalse(vpcScope.LinodeVPC, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, err.Error())
conditions.MarkFalse(vpcScope.LinodeVPC, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())

r.Recorder.Event(vpcScope.LinodeVPC, corev1.EventTypeWarning, string(failureReason), err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions util/reconciler/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func HasConditionSeverity(from conditions.Getter, typ clusterv1.ConditionType, s
}

func RecordDecayingCondition(to conditions.Setter, typ clusterv1.ConditionType, reason, message string, timeout time.Duration) bool {
conditions.MarkFalse(to, typ, reason, clusterv1.ConditionSeverityWarning, message)
conditions.MarkFalse(to, typ, reason, clusterv1.ConditionSeverityWarning, "%s", message)

if HasStaleCondition(to, typ, timeout) {
conditions.MarkFalse(to, typ, reason, clusterv1.ConditionSeverityError, message)
conditions.MarkFalse(to, typ, reason, clusterv1.ConditionSeverityError, "%s", message)
return true
}

Expand Down

0 comments on commit cd4938c

Please sign in to comment.