Skip to content

Commit dee8ba2

Browse files
theobarberbanyopenshift-cherrypick-robot
authored andcommitted
Updates message verbs to use %q where appropriate
This change updates the message verbs to use %q instead of %s, where appropriate, to properly escape output. This is to ensure potentially malicious input will be properly escaped.
1 parent 8fda37a commit dee8ba2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/controller/machine/controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (r *ReconcileMachine) Reconcile(ctx context.Context, request reconcile.Requ
161161

162162
// Implement controller logic here
163163
machineName := m.GetName()
164-
klog.Infof("%v: reconciling Machine", machineName)
164+
klog.Infof("%q: reconciling Machine", machineName)
165165

166166
// Get the original state of conditions now so that they can be used to calculate the patch later.
167167
// This must be a copy otherwise the referenced slice will be modified by later machine conditions changes.
@@ -229,14 +229,14 @@ func (r *ReconcileMachine) Reconcile(ctx context.Context, request reconcile.Requ
229229
// we can loose instances, e.g. right after request to create one
230230
// was sent and before a list of node addresses was set.
231231
if len(m.Status.Addresses) > 0 || !isInvalidMachineConfigurationError(err) {
232-
klog.Errorf("%v: failed to delete machine: %v", machineName, err)
232+
klog.Errorf("%q: failed to delete machine: %v", machineName, err)
233233
return delayIfRequeueAfterError(err)
234234
}
235235
}
236236

237237
instanceExists, err := r.actuator.Exists(ctx, m)
238238
if err != nil {
239-
klog.Errorf("%v: failed to check if machine exists: %v", machineName, err)
239+
klog.Errorf("%q: failed to check if machine exists: %v", machineName, err)
240240
return reconcile.Result{}, err
241241
}
242242

@@ -271,7 +271,7 @@ func (r *ReconcileMachine) Reconcile(ctx context.Context, request reconcile.Requ
271271

272272
instanceExists, err := r.actuator.Exists(ctx, m)
273273
if err != nil {
274-
klog.Errorf("%v: failed to check if machine exists: %v", machineName, err)
274+
klog.Errorf("%q: failed to check if machine exists: %v", machineName, err)
275275

276276
conditions.Set(m, conditions.UnknownCondition(
277277
machinev1.InstanceExistsCondition,
@@ -289,7 +289,7 @@ func (r *ReconcileMachine) Reconcile(ctx context.Context, request reconcile.Requ
289289
if instanceExists {
290290
klog.Infof("%v: reconciling machine triggers idempotent update", machineName)
291291
if err := r.actuator.Update(ctx, m); err != nil {
292-
klog.Errorf("%v: error updating machine: %v, retrying in %v seconds", machineName, err, requeueAfter)
292+
klog.Errorf("%q: error updating machine: %v, retrying in %s seconds", machineName, err, requeueAfter.String())
293293

294294
if patchErr := r.updateStatus(ctx, m, ptr.Deref(m.Status.Phase, ""), nil, originalConditions); patchErr != nil {
295295
klog.Errorf("%v: error patching status: %v", machineName, patchErr)
@@ -356,7 +356,7 @@ func (r *ReconcileMachine) Reconcile(ctx context.Context, request reconcile.Requ
356356

357357
klog.Infof("%v: reconciling machine triggers idempotent create", machineName)
358358
if err := r.actuator.Create(ctx, m); err != nil {
359-
klog.Warningf("%v: failed to create machine: %v", machineName, err)
359+
klog.Warningf("%q: failed to create machine: %v", machineName, err)
360360
if isInvalidMachineConfigurationError(err) {
361361
if err := r.updateStatus(ctx, m, machinev1.PhaseFailed, err, originalConditions); err != nil {
362362
return reconcile.Result{}, err

pkg/controller/vsphere/actuator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewActuator(params ActuatorParams) *Actuator {
6060
// Set corresponding event based on error. It also returns the original error
6161
// for convenience, so callers can do "return handleMachineError(...)".
6262
func (a *Actuator) handleMachineError(machine *machinev1.Machine, err error, eventAction string) error {
63-
klog.Errorf("%v error: %v", machine.GetName(), err)
63+
klog.Errorf("%q error: %v", machine.GetName(), err)
6464
if eventAction != noEventAction {
6565
a.eventRecorder.Eventf(machine, corev1.EventTypeWarning, "Failed"+eventAction, "%v", err)
6666
}

0 commit comments

Comments
 (0)