Skip to content

CreateOrUpdate performs Updates even if the object is unchanged #3191

Closed
@ian-howell

Description

@ian-howell

The controllerutil.CreateOrUpdate does not correctly handle updates.

Given the same resource multiple times, CreateOrUpdate will always perform an UPDATE api call, and report that it did so, even if there were no updates to the resource. This can be easily verified by making the following modifcation to the unit test

Image

This diff results in the following error:

Image

This is problematic:

  1. It result in unnecessary API calls,
  2. It reduces visibility into what a controller is doing. The function suggests that it will return OperationNone if no changes were made, however controller authors still need to manually check if their resource changed. This reduces the ability to properly log and emit metrics, as well as other problems such as those offered in CreateOrUpdate falsely claiming its updating resources  #847 (comment)

Root Cause in this comment:

#3191 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions