Skip to content

How to selectively define the fields to reconcile with DependentResources #1474

Closed

Description

@andreaTP

Bug Report

Defining a DependenResource of type e.g. Job is slightly problematic at a first attempt.
The reason is that the Job .spec.template field is immutable and any update operation slightly changing it result in an error.

Here I'm tentatively disabling all the update methods:
https://github.com/andreaTP/bink8s/blob/0177a66e4b31225c0b5a91e5694e80a3d3127df4/src/main/java/io/bink8s/controller/workflow/ImageBuildJobDependentResource.java#L85-L97

I'm not sure what would be the best course of action here, e.g. Labels can still be updated/reconciled, but we should make sure the .spec.template remains untouched.
The problematic bit is that .spec.template contains elements that are filled after the object is created e.g.:

spec:
  template:
    metadata:
      creationTimestamp: null
      labels:
        controller-uid: 7ec0fb0f-d0fa-4795-b051-233d8d40f19c

I'm looking for guidance on how to handle this situation properly 🙏

Activity

  1. csviri commented on Sep 19, 2022

    @csviri
    Collaborator

    We don't have a Job specific matcher yet, but this can be probably just fixed if you override the matcher.

    What is your exact use case?

    Asking because recreating a use case is not supported, what might be an use case some times.

  2. andreaTP commented on Sep 19, 2022

    @andreaTP
    CollaboratorAuthor

    I would like to simply skip the update if .spec.template differ, and, to make sure I never update that subpath (as it will result in an error all the time).

  3. csviri commented on Sep 19, 2022

    @csviri
    Collaborator

    Ahh ok, this is defintely should be possible to do even now, just overriding the match and the update function.

    However might be easier if the desired would receive the actual resource too if present. cc @metacosm - will prepare a PR for this.

  4. linked a pull request that will close this issuefeat: desired method aware of actual resource #1482on Sep 19, 2022
  5. csviri commented on Sep 19, 2022

    @csviri
    Collaborator

    @andreaTP I linked a PR, we can discuss that. Basically now this is possible just more hacky, with that it should be doable much more elegantly. Probably the best would be to add to the same branch an integration test for this use case.

  6. github-actions commented on Nov 19, 2022

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

  7. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Nov 19, 2022
  8. github-actions commented on Dec 4, 2022

    @github-actions

    This issue was closed because it has been stalled for 14 days with no activity.

  9. removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Jan 31, 2023
  10. reopened this on Jan 31, 2023
  11. added this to the 4.3 milestone on Jan 31, 2023
  12. csviri commented on Jan 31, 2023

    @csviri
    Collaborator

    I was updating the API for this use case, see related PR. But realized that getSecondaryResource always can be called. So you can just call that set the spec.template part from there if present. In this case it is not changed.
    Not sure if we should still change the API of desired. Will create an example at least.

  13. csviri commented on Jan 31, 2023

    @csviri
    Collaborator

    See sample here:
    #1746

    I think this is good enough, no need to explicitly put the resource in to desrire(...) api. Unless you think otherwise @andreaTP or @metacosm

  14. self-assigned this
    on Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions