Skip to content

Expose referSameObject function #2989

@keeganwitt

Description

@keeganwitt

If you are creating a new object, you may need a function to tie this new object to the lifecycle of the owners of the object being reconciled. For example, I have a controller that reconciles pods, which is writing secrets for the pods to use. In the case of a standalone pod, it's fine to just set the pod as an owner of this new secret using controllerutil.SetOwnerReference(). However, for pods which have an owner (ReplicaSets, DaemonSets, etc), the secret may be shared with all other related pods, as they are members of the same workload. This requires me to duplicate the logic of controllerutil.upsertOwnerRef() in my project, since I don't have the objects referred to by the pod's ownerReferences, only the references themselves and that function is not public. It would be useful in such cases to either make controllerutil.upsertOwnerRef() public, or expose that function through a new public function. If we add the ability to add an OwnerReference in this way, we should probably also add the ability to remove it as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions