baremetal-operator: `saveHostStatus` triggers even on unchanged object

func (r *BareMetalHostReconciler) saveHostStatus(host *metal3v1alpha1.BareMetalHost) error {
	t := metav1.Now()
	host.Status.LastUpdated = &t

	return r.Status().Update(context.TODO(), host)
}

There is an edge case when saveHostStatus is triggered even when no actual objects changes are made, the only change to object is updating LastUpdated filed.

It would be better to have this field updated only if something in status was actually changed.

Current behavior adds unneeded reconciles for external watchers that follow BMH changes, this becomes noticeable on big clusters with lots for BMH.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

I am not sure what extra steps you need to reproduce this, the issue of NOP updates is there all the time, just check the code, updates are unconditional, every reconcile (in not provisioned states) time is getting updated.

This is referring to https://github.com/metal3-io/baremetal-operator/blob/release-0.3/controllers/metal3.io/baremetalhost_controller.go#L1538-L1541

However, I checked the code and as Dmitry said, we only call this if something else had changed: https://github.com/metal3-io/baremetal-operator/blob/release-0.3/controllers/metal3.io/baremetalhost_controller.go#L235-L245

Without even a single example of this NOP update happening - even a log would be helpful, we always log when we update the Status - there’s no way for us to tell if any change has actually had any effect.