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

🐛 (API - External Plugins): Fix external plugin discovery on Linux #3247

Merged

Conversation

em-r
Copy link
Contributor

@em-r em-r commented Feb 23, 2023

This PR aims to fix a bug that's causing external plugin discovery to fail in Linux systems when XDG_CONFIG_HOME environment variable is set.

fixes: #3224

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 23, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @em-r. 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/test-infra repository.

@em-r
Copy link
Contributor Author

em-r commented Feb 23, 2023

/cc @camilamacedo86

if err != nil {
return "", fmt.Errorf("error retrieving home dir: %v", err)
}
pluginsRoot = filepath.Join(userHomeDir, pluginsRoot)

return pluginsRoot, nil
Copy link
Member

Choose a reason for hiding this comment

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

This method expects a return (pluginsRoot string, err error) I think it is missing return it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason I have replaced return pluginsRoot, nil with just return is because the function uses named returns so I think specifying the variables in the return is redundant, but I can add it back (maybe because of a style convention?) just let me know.
thank you!

Copy link
Member

Choose a reason for hiding this comment

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

If we do not return this values then we should remove them from the signature.
Could you please change that?

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@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 Feb 23, 2023
@camilamacedo86 camilamacedo86 changed the title 🐛 Fix external plugin discovery on Linux 🐛 (API - External Plugins): Fix external plugin discovery on Linux Feb 23, 2023
@@ -171,26 +171,44 @@ func parseExternalPluginArgs() (args []string) {
return args
Copy link
Member

Choose a reason for hiding this comment

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

@evansheng @rashmigottipati could you please give a hand to review this one?

@em-r
Copy link
Contributor Author

em-r commented Feb 23, 2023

I can see the coverage check failed, I'll add more tests to fix this as well.
edit: added a test on f883680 which should hopefully increase the coverage.
edit 2: nope, the test actually failed in the ci somehow, will look into it and prepare a fix.

@em-r
Copy link
Contributor Author

em-r commented Feb 27, 2023

coverage drop has been fixed. I'm seeing a failure in k8s-1-24-7 build, however, based on its logs I don't think it's related to the changes in this PR, it seems like some sort of missing file issue in the machine where the build ran. will keep looking into it.
cc @camilamacedo86

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution @em-r , these changes look great!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2023
@everettraven
Copy link
Contributor

/retest

@everettraven
Copy link
Contributor

The test failure seems like some weird kustomize errors. I'm not sure off the top of my head what the problem here is

@em-r
Copy link
Contributor Author

em-r commented Mar 3, 2023

thanks @everettraven for the review!
I'll try to look into the build errors over the weekend, and hopefully, figure out a way to resolve them. I'll keep you posted.

@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-24-7

@em-r
Copy link
Contributor Author

em-r commented Mar 6, 2023

thanks @camilamacedo86 for re-running the failing build.
seems to be passing now @everettraven

}
return false
}

// getPluginsRoot detects the host system and gets the plugins root based on the host.
func getPluginsRoot(host string) (pluginsRoot string, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

/hold

Suggested change
func getPluginsRoot(host string) (pluginsRoot string, err error) {
func getPluginsRoot(host string) {

Can we first remove the return since it is not used?
https://github.com/kubernetes-sigs/kubebuilder/pull/3247/files#r1126146318

Copy link
Contributor Author

@em-r em-r Mar 6, 2023

Choose a reason for hiding this comment

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

@camilamacedo86 this function is assigned to retrievePluginsRoot, and then called by DiscoverExternalPlugins. the output of the function is indeed used then to lookup external plugins in pluginsRoot.
to elaborate as to why I've changed return pluginsRoot, nil to just return: it's because the function uses named returns, so while using return pluginsRoot, nil as a return expression would work, specifying the variables would be redundant, so essentially, just using a "void" return will have the same outcome (because of the named return in the signature).
but either way, I can revert it back to the old style as it would work fine as well. what do you think?
thank you!

Copy link
Member

Choose a reason for hiding this comment

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

I think that is fine as it is . We can re-check in a follow up either.
Thank you a lot for your help to address those ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you @camilamacedo86, always happy to help!

@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 Mar 6, 2023
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/hold cancel

/lgtm

@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 Mar 6, 2023
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 6, 2023
@camilamacedo86
Copy link
Member

/approved

Copy link
Contributor

@rashmigottipati rashmigottipati left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, em-r, everettraven, rashmigottipati

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:

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

@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-26-0

@k8s-ci-robot k8s-ci-robot merged commit 6adce22 into kubernetes-sigs:master Mar 6, 2023
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

External plugins discovery fails when XDG_CONFIG_HOME is set
5 participants