Skip to content

Refactor updating workload via PatchAdmissionStatus to make sure update is not saved on error #7753

@mimowo

Description

@mimowo

What would you like to be cleaned:

Calling PatchAdmissionStatus can currently lead to subtle bugs, when the function fails on error, because the object passed to the function is modified.

To achieve that we could have a new helper dedicated to Workloads which, say workload.PatchStatus:

  1. takes an internal DeepCopy of the workload
  2. calls PatchAdmissionStatus or another helper
  3. updates the workload pointer pass to invoke the function on success
  4. discards the changes in case of failure

Alternatively, return the new version of the object on succeessful request (but this is more code changes).

Why is this needed:

To avoid modifying the cached valued of the Workload in case the update fails. This inconsistency may result in subtle issues.

Metadata

Metadata

Assignees

Labels

kind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions