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 KRM functions with relative paths don't resolve when base kustomization is in use #4350

Closed
seh opened this issue Dec 21, 2021 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/duplicate Indicates an issue is a duplicate of other open issue.

Comments

@seh
Copy link
Contributor

seh commented Dec 21, 2021

Description

Following up from #4117, while #4125 made it possible to use relative paths to specify the location of an exec KRM function, that resolution only works correctly when the kustomization containing the KRM function does not use any bases, and instead includes only resources—specifically, references to files below that kustomization root.

The following kustomization.yaml files demonstrate the possibilities:

No resources

Relative KRM function paths work as expected.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:

Only resources

Relative KRM function paths work as expected.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
- pdb.yaml

Only bases

Relative KRM function paths do not work as expected.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base

Bases and resources

Relative KRM function paths do not work as expected.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base
- hpa.yaml

Reproduction

Please consult the archive of a base kustomization and an overlay kustomization, where the overlay includes a KRM function.

kustomize-fn-defect.tar.gz

Preparation

mkdir -p /tmp/kustomize-demo
cd /tmp/kustomize-demo
tar zxf ~/Downloads/kustomize-fn-defect.tar.gz
kustomize build ./overlays/fn --enable-exec --enable-alpha-plugins

Expected Output

apiVersion: v1
data:
  color: red
kind: ConfigMap
metadata:
  name: settings

Actual Output

Error: couldn't execute function: fork/exec ./plugins/change-color: no such file or directory 

Environment

Kustomize Version

{Version:kustomize/v4.4.1 GitCommit:b2d65ddc98e09187a8e38adc27c30bab078c1dbf BuildDate:2021-11-11T23:27:14Z GoOs:darwin GoArch:amd64}

Platform

macOS 11.6 (Darwin Kernel Version 20.6.0)

Additional Context

If you change the "exec.path" field (embedded in the "config.kubernetes.io/function" annotation) in the krm-functions.yaml file to the absolute path to the change-color program (e.g. /tmp/kustomize-demo/overlays/fn/plugins/change-color), then kustomize build works as expected. Likewise, if you use a relative path to the change-color file and comment out the resource ../../base in the overlay kustomization.yaml file and instead include the ConfigMap content in a file within the overlay's directory (effectively changing the overlay into a base), then kustomize build works as expected.

@seh seh added the kind/bug Categorizes issue or PR as related to a bug. label Dec 21, 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 Dec 21, 2021
@k8s-ci-robot
Copy link
Contributor

@seh: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@seh
Copy link
Contributor Author

seh commented Dec 21, 2021

I confirmed that if you specify a relative path to the exec KRM function file from the base kustomization root, it works. That is, in the example introduced here, if the "exec.path" field's value is ../overlays/fn/plugins/change-color, then kustomize finds the change-color file. Clearly it's using the base kustomization directory as its working directory. Instead, it should use the directory of the overlay kustomization that includes the function.

@seh
Copy link
Contributor Author

seh commented Dec 22, 2021

See #4347 for a similar complaint.

@KnVerey
Copy link
Contributor

KnVerey commented Dec 23, 2021

/triage duplicate
/close

Thank you for the detailed report. Since this was opened slightly after #4347 (crazy timing!), let's continue there.

@k8s-ci-robot k8s-ci-robot added the triage/duplicate Indicates an issue is a duplicate of other open issue. label Dec 23, 2021
@k8s-ci-robot
Copy link
Contributor

@KnVerey: Closing this issue.

In response to this:

/triage duplicate
/close

Thank you for the detailed report. Since this was opened slightly after #4347 (crazy timing!), let's continue there.

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.

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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

No branches or pull requests

3 participants