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

Separate the logic of applying resources from syncer and make it reusable #400

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

saza-ku
Copy link
Contributor

@saza-ku saza-ku commented Dec 16, 2024

What type of PR is this?

/area simulator
/kind cleanup

What this PR does / why we need it:

syncer and oneshotimporter have their own logic of applying resources. They can be generalized and the replaying feature (#395) can use it.

This PR separates that of syncer and makes it a module resourceapplier.

Which issue(s) this PR fixes:

Part of #395

Special notes for your reviewer:

I'll create another PR to refactor oneshotimporter to use resourceapplier.

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added area/simulator Issues or PRs related to the simulator. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 16, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @saza-ku. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 16, 2024
@sanposhiho
Copy link
Member

/ok-to-test
/cc @utam0k @ordovicia

@k8s-ci-robot k8s-ci-robot requested a review from utam0k December 16, 2024 11:26
@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 16, 2024
@k8s-ci-robot
Copy link
Contributor

@sanposhiho: GitHub didn't allow me to request PR reviews from the following users: ordovicia.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/ok-to-test
/cc @utam0k @ordovicia

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@saza-ku
Copy link
Contributor Author

saza-ku commented Dec 16, 2024

/retest

Copy link
Contributor

@ordovicia ordovicia left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@saza-ku saza-ku requested a review from utam0k January 6, 2025 00:02
@saza-ku saza-ku force-pushed the modularize-applying branch from eb4b4a0 to a51cdd9 Compare January 6, 2025 08:58
@utam0k
Copy link
Member

utam0k commented Jan 14, 2025

/lgtm

@sanposhiho Would you mind checking this PR because this PR needs /approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2025
Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

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

This PR doesn't change oneshotimporter, did you mean you're gonna create another PR to refactor that to use resourceapplier?

@saza-ku
Copy link
Contributor Author

saza-ku commented Jan 14, 2025

@sanposhiho

This PR doesn't change oneshotimporter, did you mean you're gonna create another PR to refactor that to use resourceapplier?

Yes. This is because oneshotimporter was under revision when I created this PR. (#395 (comment))
I'll add the intention to the PR description.

@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ordovicia, saza-ku
Once this PR has been reviewed and has the lgtm label, please assign sanposhiho for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@saza-ku saza-ku force-pushed the modularize-applying branch from f7c7c29 to 14cbcd3 Compare January 14, 2025 07:10
@saza-ku saza-ku force-pushed the modularize-applying branch from 14cbcd3 to 8aae944 Compare January 14, 2025 07:11
type Service struct {
gvrs []schema.GroupVersionResource
srcDynamicClient dynamic.Interface
resourceApplierService *resourceapplier.Service
}

type Options struct {
// GVRsToSync is a list of GroupVersionResource that will be synced.
// If GVRsToSync is nil, defaultGVRs are used.
GVRsToSync []schema.GroupVersionResource
Copy link
Member

Choose a reason for hiding this comment

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

Can we somehow move it to the resourceapplier option as well so that we can unify the interface of the option regardless of whether users want to use oneshot or syncer?

Copy link
Contributor Author

@saza-ku saza-ku Jan 14, 2025

Choose a reason for hiding this comment

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

We could just make resourceapplier have GVRsToSync and syncer refer to resouceApplierService.GRVsToSync.

	// in syncer service
	infFact := dynamicinformer.NewFilteredDynamicSharedInformerFactory(s.srcDynamicClient, 0, metav1.NamespaceAll, nil)
	for _, gvr := range s.resourceApplierService.GVRsToSync { // syncer itself doesn't have gvrs
		inf := infFact.ForResource(gvr).Informer()

oneshotimporter would just ignore it.

Is it okay?

Copy link
Member

Choose a reason for hiding this comment

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

oneshotimporter would just ignore it.

Well, can't we make oneshotimporter also configurable about which resource to import with the same option of resourceapplyer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. So we could make a PR that makes it configurable after this PR.

For now, I'll just implement as I wrote in the last comment.

Copy link
Member

@sanposhiho sanposhiho Jan 15, 2025

Choose a reason for hiding this comment

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

Ah, got what you meant. Yes, I'm fine with it if oneshotimporter would also follow the option later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/simulator Issues or PRs related to the simulator. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants