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

Exec generator plugins do not work on Windows #4213

Closed
mprahl opened this issue Sep 28, 2021 · 6 comments
Closed

Exec generator plugins do not work on Windows #4213

mprahl opened this issue Sep 28, 2021 · 6 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@mprahl
Copy link

mprahl commented Sep 28, 2021

Describe the bug

I'm unable to use an exec Kustomize generator plugin on Windows. This works for me both on Linux and MacOS.

The error is as follows:

C:\Users\mprahl\Desktop\kustomize>kustomize build --enable-alpha-plugins
Error: failure in plugin configured via C:\Users\mprahl\AppData\Local\Temp\kust-plugin-config-171892711; exec: "C:\\Users\\mprahl\\kustomize\\plugin\\policy.open-cluster-management.io\\v1\\policygenerator\\PolicyGenerator": file does not exist: exec: "C:\\Users\\mprahl\\kustomize\\plugin\\policy.open-cluster-management.io\\v1\\policygenerator\\PolicyGenerator": file does not exist

However, the generator executable does exist:

C:\Users\mprahl\Desktop\kustomize>dir "C:\Users\mprahl\kustomize\plugin\policy.open-cluster-management.io\v1\policygenerator\PolicyGenerator"
 Volume in drive C has no label.
 Volume Serial Number is F848-3479
 
 Directory of C:\Users\mprahl\kustomize\plugin\policy.open-cluster-management.io\v1\policygenerator
 
09/28/2021  07:46 AM        18,222,080 PolicyGenerator
               1 File(s)     18,222,080 bytes
               0 Dir(s)   7,268,851,712 bytes free

Here is how I can reproduce it:

  1. Download the precompiled binary or compile it from source.
  2. Run the following PowerShell commands to get the plugin in the correct location:
    $pluginDir = Join-Path (Get-Item Env:\USERPROFILE).Value "kustomize\plugin\policy.open-cluster-management.io\v1\policygenerator"
    New-Item -Path $pluginDir -ItemType Directory
    $downloadPath = Join-Path (Get-Item Env:\USERPROFILE).Value "Downloads\windows-amd64-PolicyGenerator.exe"
    Move-Item $downloadPath (Join-Path $pluginDir "PolicyGenerator")
  3. Create the following files:
    • kustomization.yaml
      generators:
        - policyGenerator.yaml
    • policyGenerator.yaml
      apiVersion: policy.open-cluster-management.io/v1
      kind: PolicyGenerator
      metadata:
        name: policy-generator-name
      policyDefaults:
        namespace: my-policies
      policies:
        - name: policy-app-config-aliens 
          manifests:
             - path: configmap.yaml
    • configmap.yaml
      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: game-config-aliens
        namespace: default
      data:
        game.properties: |
          enemies=aliens
        ui.properties: |
          color.good=purple
  4. Run kustomize with kustomize build --enable-alpha-plugins

Expected output

apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
metadata:
  name: placement-policy-app-config-aliens
  namespace: my-policies
spec:
  clusterConditions:
  - status: "True"
    type: ManagedClusterConditionAvailable
  clusterSelector:
    matchExpressions: []
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
metadata:
  name: binding-policy-app-config-aliens
  namespace: my-policies
placementRef:
  apiGroup: apps.open-cluster-management.io
  kind: PlacementRule
  name: placement-policy-app-config-aliens
subjects:
- apiGroup: policy.open-cluster-management.io
  kind: Policy
  name: policy-app-config-aliens
---
apiVersion: policy.open-cluster-management.io/v1
kind: Policy
metadata:
  annotations:
    policy.open-cluster-management.io/categories: CM Configuration Management
    policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
    policy.open-cluster-management.io/standards: NIST SP 800-53
  name: policy-app-config-aliens
  namespace: my-policies
spec:
  disabled: false
  policy-templates:
  - objectDefinition:
      apiVersion: policy.open-cluster-management.io/v1
      kind: ConfigurationPolicy
      metadata:
        name: policy-app-config-aliens
      spec:
        object-templates:
        - complianceType: musthave
          objectDefinition:
            apiVersion: v1
            data:
              game.properties: |
                enemies=aliens
              ui.properties: |
                color.good=purple
            kind: ConfigMap
            metadata:
              name: game-config-aliens
              namespace: default
        remediationAction: inform
        severity: low

Actual output

C:\Users\mprahl\Desktop\kustomize>kustomize build --enable-alpha-plugins
Error: failure in plugin configured via C:\Users\mprahl\AppData\Local\Temp\kust-plugin-config-171892711; exec: "C:\\Users\\mprahl\\kustomize\\plugin\\policy.open-cluster-management.io\\v1\\policygenerator\\PolicyGenerator": file does not exist: exec: "C:\\Users\\mprahl\\kustomize\\plugin\\policy.open-cluster-management.io\\v1\\policygenerator\\PolicyGenerator": file does not exist

Kustomize version

  • I used the latest v4 compiled from source as of September 28th, 2021
  • I also tried a precompiled v4.1.3

Platform

Windows

Additional context

It seems that Kustomize finds the binary before executing the generator plugin because the following error is printed when the binary is just flat out missing:

Error: loading generator plugins: expected file with Go object code at: C:\Users\mprahl\kustomize\plugin\policy.open-cluster-management.io\v1\policygenerator\PolicyGenerator.so

It seems that the code actually executing the binary has an issue on Windows.

@mprahl mprahl added the kind/bug Categorizes issue or PR as related to a bug. label Sep 28, 2021
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 28, 2021
@KnVerey KnVerey self-assigned this Sep 29, 2021
@KnVerey
Copy link
Contributor

KnVerey commented Sep 30, 2021

Thank you for the detailed report! We are currently looking for a contributor to help us with Windows issues like this one, #4001 and #4028. Do you think this case might be the same as the one reported in #3269, where the problem was not handling Windows executable extensions? If so, I think the approach in that PR is good, though it needs tests.

That said, we have an open KEP proposing deprecating this style of Exec plugin in favor of the newer KRM Functions Specification style (example / example--more docs coming soon) that specifies the executable in the config itself using a relative path from the invoking Kustomization. I suspect that it also has this issue, and would favor fixing it there (i.e. in api/internal/plugins/execplugin/execplugin.go) given the planned deprecation.

/unassign
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 30, 2021
mprahl added a commit to mprahl/kustomize that referenced this issue Oct 4, 2021
On Windows, the exec plugin script/binary must have an executable file
extension (e.g. .exe). This is so that Windows knows how to run it.
When the Start method of the Cmd type in the os/exec package strategy
is given a path without an extension, it attempts to discover it. This
commit adds this behavior to the AbsolutePluginPath method.

Resolves:
kubernetes-sigs#4213

Signed-off-by: mprahl <[email protected]>
mprahl added a commit to mprahl/kustomize that referenced this issue Oct 4, 2021
On Windows, the exec plugin script/binary must have an executable file
extension (e.g. .exe). This is so that Windows knows how to run it.
When the Start method of the Cmd type in the os/exec package strategy
is given a path without an extension, it attempts to discover it. This
commit adds this behavior to the AbsolutePluginPath method.

Resolves:
kubernetes-sigs#4213

Signed-off-by: mprahl <[email protected]>
mprahl added a commit to mprahl/kustomize that referenced this issue Oct 4, 2021
On Windows, the exec plugin script/binary must have an executable file
extension (e.g. .exe). This is so that Windows knows how to run it.
When the Start method of the Cmd type in the os/exec package strategy
is given a path without an extension, it attempts to discover it. This
commit adds this behavior to the AbsolutePluginPath method.

Resolves:
kubernetes-sigs#4213

Signed-off-by: mprahl <[email protected]>
mprahl added a commit to mprahl/kustomize that referenced this issue Oct 4, 2021
On Windows, the exec plugin script/binary must have an executable file
extension (e.g. .exe). This is so that Windows knows how to run it.
When the Start method of the Cmd type in the os/exec package strategy
is given a path without an extension, it attempts to discover it. This
commit adds this behavior to the AbsolutePluginPath method.

Resolves:
kubernetes-sigs#4213

Signed-off-by: mprahl <[email protected]>
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please 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 Jan 2, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please 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 Feb 1, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

@Jaland
Copy link

Jaland commented Apr 24, 2023

In case anyone finds this issue in the future the workaround is just also including the PolicyGenerator.exe windows file in the config directory i.e. kustomize\plugin\policy.open-cluster-management.io\v1\policygenerator\PolicyGenerator.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

5 participants