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

Fix exec plugins on windows #3269

Closed

Conversation

jaysonsantos
Copy link

The exec plugin implementation checks if an executable file exists but
on windows it won't check for files with .exe suffix thus falling back
to go plugin implementation

The exec plugin implementation checks if an executable file exists but
on windows it won't check for files with .exe suffix thus falling back
to go plugin implementation
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 24, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @jaysonsantos!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @jaysonsantos. 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.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 24, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jaysonsantos
To complete the pull request process, please assign liujingfang1 after the PR has been reviewed.
You can assign the PR to them by writing /assign @liujingfang1 in a comment when ready.

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

@jaysonsantos
Copy link
Author

You can see it breaking here jaysonsantos/kustomize-sops-rs#5
I am not sure on how and where to add the tests cases, could you point me out?

@Shell32-Natsu
Copy link
Contributor

Doesn't #3027 resolve this problem?

@jaysonsantos
Copy link
Author

Hey there, it does not. The only way to make it work is to have a file called Kind and then another one call Kind.exe so the file exists check works on the first one and then the exec call on windows, they try files with suffix exe, ps1, and bat and executes the last one

@Shell32-Natsu
Copy link
Contributor

What if you add .exe suffix to the Kind in transformer config?

@jaysonsantos
Copy link
Author

I guess it would work but should break if you run the same kustomize on non-windows machines

@jaysonsantos
Copy link
Author

/check-cla

1 similar comment
@jaysonsantos
Copy link
Author

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 26, 2020
@monopole monopole removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 30, 2020
@monopole
Copy link
Contributor

The code you're trying to work with is a bit of a mess.

Suggest adding a free standing function in the loader.go file like

func LookForExecutable(partialPath string) (fullPath string, err error) {
  // In here have all the os dependent stuff.
  // Try to confirm file existence and if it's executable, as a function of operating system.
  // If on windows, add the .exe extension, maybe .bat too, and see if the file exists.
  //   On windows, there's no exec bit, so just assume that if on windows and
  //   the file ends in .exe that it's executable. 
  // else (If not on windows)
  //   test the exec bit.
  // If everything works (the file exists, and appears to be executable) return path, nil.
  // if not, return "", error.
}

The above would totally replace the use of p.ErrIfNotExecutable, so delete it. It's best
to not even create the ExecPlugin object unless it's known that an exec file exists.

The new flow would be just:

func (l *Loader) loadExecOrGoPlugin(resId resid.ResId) (resmap.Configurable, error) {
  path, err:= LookForExecutable(l.absolutePluginPath(resId))
  if err != nil {
    return execplugin.NewExecPlugin(path), nil
  }
  return l.loadGoPlugin(resId)
}

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 9, 2020
@jaysonsantos
Copy link
Author

Hey there @monopole, could you check again?
I chose not to check the executable bit on the loader as the exec plugin already does it. Do you think that it makes sense to move out from exec plugin to loader?

@jaysonsantos
Copy link
Author

Also, lookForExecutables error is being ignored because it fallbacks to go plugin

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 9, 2021
@jaysonsantos
Copy link
Author

Hey there folks, do you think this is useful?

@Shell32-Natsu
Copy link
Contributor

@monopole

@k8s-ci-robot
Copy link
Contributor

@jaysonsantos: PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 6, 2021
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 6, 2021
@jaysonsantos
Copy link
Author

I am giving up on this.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants