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

Add ProviderConfig Controller #2792

Merged

Conversation

panslava
Copy link
Contributor

/assign @gauravkghildiyal

This will be the very last to review

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 13, 2025
@panslava panslava force-pushed the multi-project-cluster-slice-controller branch 2 times, most recently from 8ca2383 to 64a3448 Compare January 13, 2025 20:14
@panslava
Copy link
Contributor Author

/retest

@panslava panslava force-pushed the multi-project-cluster-slice-controller branch from 64a3448 to 63b6cbe Compare January 13, 2025 20:32
@panslava
Copy link
Contributor Author

/retest

@panslava panslava force-pushed the multi-project-cluster-slice-controller branch 2 times, most recently from 0c861ed to fd75ee7 Compare January 15, 2025 20:37
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 15, 2025
@panslava panslava force-pushed the multi-project-cluster-slice-controller branch 2 times, most recently from 6fde296 to 717f4c9 Compare January 16, 2025 21:20
@gauravkghildiyal
Copy link
Member

Thanks @panslava!

I'm yet to take a look, but glancing through: now that we've started making use of our libraries/packages, are there some useful unit / integration tests that we can add?

@panslava panslava force-pushed the multi-project-cluster-slice-controller branch from 12a0122 to 262703c Compare February 4, 2025 18:43
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 4, 2025
@panslava panslava force-pushed the multi-project-cluster-slice-controller branch from 00d673c to 013fb0a Compare February 4, 2025 19:18
@panslava
Copy link
Contributor Author

panslava commented Feb 4, 2025

Added unit tests

Ready for review

This PR has a bit too many commits now, integration tests will be done in next PR

@panslava panslava force-pushed the multi-project-cluster-slice-controller branch 3 times, most recently from f413eeb to 1a7e4d5 Compare February 4, 2025 21:30
- Introduced a new ProviderConfigController to track ProviderConfig resources and start NEG controllers.
- Added initialization and running the ProviderConfigController in multi-project mode in main.go.
@panslava panslava force-pushed the multi-project-cluster-slice-controller branch from 5fe5c23 to 3156e41 Compare February 11, 2025 21:12
@panslava panslava force-pushed the multi-project-cluster-slice-controller branch from 3156e41 to bc8909a Compare February 11, 2025 21:29
Copy link
Member

@gauravkghildiyal gauravkghildiyal left a comment

Choose a reason for hiding this comment

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

Looking good. Two comments.

Reviewing the tests separately.

}, rOption.wg)

// Wait for the multi-project syncer to finish.
waitWithTimeout(rOption.wg, rootLogger)
Copy link
Member

Choose a reason for hiding this comment

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

This is a very strange function. It just waits for 30 seconds and then stops waiting. Do we actually need such a behaviour for some reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added waiting for stopCh to close before this


// initializeInformers wraps the base SharedIndexInformers in a providerConfig filter
// and runs them.
func initializeInformers(
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it'd be better that initializeInformers also returns a hasSynced function. It minimizes potential for future issues where initializeInformers and createHasSyncedFunc diverge. Basically this helps establish the invariant that if you're Run()ing and informer, it needs a corresponding hasSynced invocation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added returning hasSynced from this func

@panslava
Copy link
Contributor Author

/hold

found some problems on integration tests

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 13, 2025
if err != nil {
t.Fatalf("failed to add ProviderConfig to indexer: %v", err)
}
time.Sleep(100 * time.Millisecond)
Copy link
Member

Choose a reason for hiding this comment

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

If these are helper functions, shouldn't waiting for any expected delays happen as part of the actual Test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved waiting to test body

}

// TestProcessUpdateFunc ensures UpdateFunc enqueues the item, triggers re-sync.
func TestProcessUpdateFunc(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

As far as being a unit test goes, I think this test is sufficient.

But this does make me wonder about the "immutability" of ProviderConfig. (Thanks to @swetharepakula for reminding me about this aspect a few days back)

  • We should assume that the ProviderConfig is immutable, in which case our current logic is correct. But if that is true, do we need a "UpdateFunc" handler for it? I'd say yes, it's good to have. But our actual code won't really do anything if the ProviderConfig is updated, and perhaps we should log it somewhere. The only kind of update which our code cares about is a DeletionEvent.

  • While assuming immutability is sufficient for now, if on the other hand you really did want to support an actual "Update" to the ProviderConfig, than perhaps the code still needs some work with how it will stop the previous ProviderConfig controller and start the new one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, maybe we just don't need this test for now, removed

Current implementation will not start any new controllers if providerConfig was updated, as we start only once per ProviderConfig key (which is namespace+name)

@panslava
Copy link
Contributor Author

/retest

- Remove Update Unit test
- Add waiting for stopCh to close
- Return HasSynced from initializeInformers
@panslava panslava force-pushed the multi-project-cluster-slice-controller branch from 5819664 to 663e98b Compare February 18, 2025 20:59
@gauravkghildiyal
Copy link
Member

Thanks!

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauravkghildiyal, panslava

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [gauravkghildiyal,panslava]

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

@panslava
Copy link
Contributor Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 18, 2025
@k8s-ci-robot k8s-ci-robot merged commit 499d76e into kubernetes:master Feb 18, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants