Skip to content

integrations/operator: propagate revision + fix tests#34265

Merged
hugoShaka merged 2 commits intomasterfrom
hugo/operator-propagate-revision
Nov 7, 2023
Merged

integrations/operator: propagate revision + fix tests#34265
hugoShaka merged 2 commits intomasterfrom
hugo/operator-propagate-revision

Conversation

@hugoShaka
Copy link
Copy Markdown
Contributor

@hugoShaka hugoShaka commented Nov 6, 2023

Depends on #34263

This PR does two things:

  • ensure revision is properly propagated (this is required in v15, tests will fail if it is not. No additional coverage required, this will be covered when we'll revert Temporarily disable conditional updates for users #34255)
  • fix tests causing definitive failures instead of temporary ones (failing instead of returning false in Eventually)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 6, 2023

The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with changelog: followed by the changelog entries for the PR.

@hugoShaka hugoShaka requested a review from rosstimothy November 6, 2023 19:21
@hugoShaka hugoShaka added the no-changelog Indicates that a PR does not require a changelog entry label Nov 6, 2023
Comment thread integrations/operator/controllers/resources/role_controller_test.go Outdated
@hugoShaka hugoShaka force-pushed the hugo/operator-propagate-revision branch from 94d04e3 to f837efe Compare November 6, 2023 20:42
@hugoShaka hugoShaka removed the request for review from marcoandredinis November 6, 2023 20:52
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use Upsert instead of create/update?
Upsert doesn't care about the revision which is more or less what we need here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked @rosstimothy, and we likely want to propagate revision even when Upserting. IIRC Update and Upsert have different behaviours for User, and both endpoints are not implemented for all resources. We might want to support both endpoints with the same generic controller.

I don't see an issue with propagating the revision. Worst case scenario, it is not used. In the best case scenario, this prevents a conflict. For some resources we are propagating information from the existing resource, the whole process is not 100% stateless. This happens in the optional Mutate() function. For example, the "CreatedBy" field of the user spec. In this case, opportunistic locking makes sense.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Upsert directly could lead to the operator overwriting any manual changes made to a resource, I'm not sure how likely that scenario is. It is generally preferred to use Create/Update where possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we must improve documentation.
When using IaC tools, it's not clear if users can change using other tools (web, tctl).

If they can't change, then the upsert is, imo, a better approach.
Even if they change the resource just to test something out, they can always go back to IaC flow.

If they can change the resource, the update will fail and they need to manually change the resource to merge any potential diff.

Have we decided on this?

Copy link
Copy Markdown
Contributor Author

@hugoShaka hugoShaka Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they can change the resource, the update will fail and they need to manually change the resource to merge any potential diff.

With the current implementation, if a conflict happens, the operator update/upsert will fail and the resource reconciliation will be requeued. The operator will perform the update in the next reconciliation cycle, a few milliseconds later. The second reconciliation should succeed.

When using IaC tools, it's not clear if users can change using other tools (web, tctl).

We do have an origin label we are not using enough. The UI/tctl could display a warning if you are attempting to edit a resource whose origin is IaC. Things become even more confusing with resources like AccessLists where some of the information can and should be edited by users in the UI even if some parts of the resource are managed via IaC.

If they can't change, then the upsert is, imo, a better approach.
Even if they change the resource just to test something out, they can always go back to IaC flow.

AFAIK, if you do a change, TF/operator will erase it the next time, which is the intended behaviour.
My biggest issue today is not caused by users editing resources managed by IaC but caused by Teleport updating fields in the spec (which should not happen according to Kube's design, the status is here for computed values). Regardless if we use update or upsert, we need to propagate those dynamic fields that appear in the spec, or else we lose information.

Have we decided on this?

I don't think and can create an issue for this. AFAIK this PR doesn't change the current state of things, it only propagates the revision.

@hugoShaka hugoShaka force-pushed the hugo/operator-propagate-revision branch from 69d626c to bb54a43 Compare November 7, 2023 16:11
@hugoShaka hugoShaka added this pull request to the merge queue Nov 7, 2023
Merged via the queue into master with commit 3a8a07f Nov 7, 2023
@hugoShaka hugoShaka deleted the hugo/operator-propagate-revision branch November 7, 2023 18:08
@public-teleport-github-review-bot
Copy link
Copy Markdown

@hugoShaka See the table below for backport results.

Branch Result
branch/v12 Failed
branch/v13 Create PR
branch/v14 Create PR

rosstimothy added a commit that referenced this pull request Nov 7, 2023
#34255 temporarily
reverted users to blind update since the operator didn't handle
revisions properly. Now that #34265
has been merged to update the operator to support revisions, the
conditional updates for users can be restored.
github-merge-queue Bot pushed a commit that referenced this pull request Nov 7, 2023
#34255 temporarily
reverted users to blind update since the operator didn't handle
revisions properly. Now that #34265
has been merged to update the operator to support revisions, the
conditional updates for users can be restored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants