Skip to content

Conversation

DerekFrank
Copy link
Contributor

@DerekFrank DerekFrank commented Oct 1, 2025

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug

/kind cleanup

/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

Following a discussion in the #csi channel of the k8s slack, folks generally support moving common sidecar flags into a shared package.

Example sidecar flags

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Oct 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: DerekFrank
Once this PR has been reviewed and has the lgtm label, please assign jsafrane 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

@k8s-ci-robot k8s-ci-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Oct 1, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 1, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @DerekFrank. Thanks for your PR.

I'm waiting for a kubernetes-csi 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 1, 2025
Copy link
Member

@mauriciopoppe mauriciopoppe left a comment

Choose a reason for hiding this comment

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

Please add a link to the conversation thread in Slack in the PR description.

Thanks for considering the monorepo sidecar design as an example on how to extract the flags! Hey Ge, could you please check that these params match your analysis in https://docs.google.com/document/d/1AKqJeAlBL8PkH8D9zABCZ82Bk1N46EygKPvVh5p4-qU/edit? cc @ConnorJC3.

/cc @mowangdk
/ok-to-test

@k8s-ci-robot k8s-ci-robot requested a review from mowangdk October 1, 2025 21:42
@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 Oct 1, 2025
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 2, 2025
config/config.go Outdated

logger := klog.Background()

// Prepare http endpoint for metrics + leader election healthz
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm honestly not sure if we want to move this into this function as well, I did it because we need access to mux for le.PrepareHealthCheck(mux, leaderelection.DefaultHealthCheckTimeout) and as far as I can tell nothing else in the sidecar's main.go files reference the mux.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it looks odd here. Get the mux from the callers, as an argument.

config/config.go Outdated
opts standardflags.SidecarConfiguration,
run func(context.Context),
driverName string,
metricsManager metrics.CSIMetricsManager) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turned out to be more args then I'd ideally want. We could move the mux creation out of the function and thus remove metricsManager, but that'd be a 1:1 exchange of args. The other option is to create config locally but some of the sidecars modify their config right after creating it (setting config.ContentType = runtime.ContentTypeProtobuf for an example)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think passing mux as a parameter would be better for now. Some other sidecars add more endpoints to it (e.g. the provisioner)

limitations under the License.
*/

package features
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this is standard across sidecars or if some sidecars have their own features. We only need ReleaseLeaderElectionOnExit but it seemed to make sense to move it all as long as its standard

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, each sidecar has its own feature gates and we need to keep them separated. RunWithLeaderElection needs to get ReleaseLeaderElectionOnExit as a parameter.

limitations under the License.
*/

package features
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, each sidecar has its own feature gates and we need to keep them separated. RunWithLeaderElection needs to get ReleaseLeaderElectionOnExit as a parameter.

config/config.go Outdated
opts standardflags.SidecarConfiguration,
run func(context.Context),
driverName string,
metricsManager metrics.CSIMetricsManager) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think passing mux as a parameter would be better for now. Some other sidecars add more endpoints to it (e.g. the provisioner)

config/config.go Outdated

logger := klog.Background()

// Prepare http endpoint for metrics + leader election healthz
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it looks odd here. Get the mux from the callers, as an argument.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2025
@mowangdk
Copy link

mowangdk commented Oct 7, 2025

/lgtm

Thank you for your PR. This will also help the CSI Sidecar AIO project~

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

@jsafrane Any other feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants