Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rollouts: support repoSync option #3850

Merged
merged 1 commit into from
Mar 7, 2023

Conversation

natasha41575
Copy link
Contributor

@natasha41575 natasha41575 commented Feb 27, 2023

Fixes #3838.

#3858 contains name changes to make the function of RemoteRootSync object more obvious.

This PR takes the approach of reusing the RemoteRootSync controller to also support RepoSync objects (and renames the controller to RemoteSync.

Alternatives:

  • Have a separate RemoteRepoSync controller. I played around with this option for a little bit but it was a lot of duplicated code. Seems better to have it all in one code path. I briefly looked into seeing of go generics + a common library could help with deduping with this option but I didn't immediately see a solution there that was better than reusing the controller.

@natasha41575 natasha41575 force-pushed the rollouts/reposync branch 2 times, most recently from 1d324c0 to 41c62f2 Compare February 28, 2023 19:36
@natasha41575 natasha41575 force-pushed the rollouts/reposync branch 4 times, most recently from 03cf85e to 27a28e2 Compare March 1, 2023 21:44
@natasha41575
Copy link
Contributor Author

natasha41575 commented Mar 1, 2023

@droot I am separately working on making this code unit-testable and still want to do some more manual testing on this, but I think this PR is in decent shape for review.

@natasha41575 natasha41575 marked this pull request as ready for review March 1, 2023 21:47
@natasha41575 natasha41575 requested a review from a team as a code owner March 1, 2023 21:47
Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

Thank you for the change, looking good to me. I have some minor comments.

rollouts/api/v1alpha1/remotesync_types.go Outdated Show resolved Hide resolved
rollouts/api/v1alpha1/remotesync_types.go Outdated Show resolved Hide resolved
verbs:
- update
- apiGroups:
- gitops.kpt.dev
resources:
- remoterootsyncs/status
- remotesyncs/status
Copy link
Contributor

Choose a reason for hiding this comment

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

In our getting-started-guide, we setup the RBAC permissions on target clusters, we need to update it to include RepoSync resources as well.

Keep a note or issue somewhere for updating it once this is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like that getting started doc already has reposyncs under the rbac permissions.

rollouts/controllers/status.go Outdated Show resolved Hide resolved
rollouts/controllers/remotesync_controller.go Outdated Show resolved Hide resolved
rollouts/controllers/remotesync_controller.go Outdated Show resolved Hide resolved
rrs.Spec.Template.Metadata) {
rrs.Spec.Template.Spec.Git.Revision = pkg.Revision
rrs.Spec.Template.Metadata = rollout.Spec.SyncTemplate.RootSync.Metadata
metadata := getSpecMetadata(rollout)
Copy link
Contributor

Choose a reason for hiding this comment

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

You may want to get this change sooner since results in panic for existing rollout objects :)

@natasha41575
Copy link
Contributor Author

@droot This PR is now split up. The name change is in its own PR: #3858.

The first commit here is the same as the commit in #3858. Once that is merged, I will rebase. The second commit here contains the needed changes to support the RepoSync option.

rollouts/controllers/remotesync_controller.go Outdated Show resolved Hide resolved
rollouts/controllers/remotesync_controller.go Outdated Show resolved Hide resolved
}
_, err = client.Resource(rootSyncGVR).Namespace(rootSyncNamespace).Patch(ctx, name, types.ApplyPatchType, data, metav1.PatchOptions{FieldManager: name})
_, err = client.Resource(gvr).Namespace(namespace).Patch(ctx, name, types.ApplyPatchType, data, metav1.PatchOptions{FieldManager: name})
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for us (since this came up during implementation of metadata on RSync objects): Since this is a patch call, this explains why we don't overwrite the Remote RSync objects.

@droot
Copy link
Contributor

droot commented Mar 6, 2023

@droot This PR is now split up. The name change is in its own PR: #3858.

The first commit here is the same as the commit in #3858. Once that is merged, I will rebase. The second commit here contains the needed changes to support the RepoSync option.

I was wondering if we can get the second commit merged first (RemoteRootSync supporting both RootSync and RepoSync). PR with the renaming can be done second because I want to explore other names for it that is more neutral that will work well when we plan to support other gitops tools such as argocd, flux etc. ?

@natasha41575 natasha41575 merged commit 2c097c1 into kptdev:main Mar 7, 2023
@natasha41575 natasha41575 deleted the rollouts/reposync branch March 7, 2023 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rollouts should support RepoSyncs
2 participants