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(k8s): respect pod selector in kubernetes-exec action type #6657

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

vvagaytsev
Copy link
Collaborator

What this PR does / why we need it:

Prior to this fix, the kubernetes-exec action type was not able to consider a specified podSelector as a valid resource query.

Reproducible example.

Click to expand
apiVersion: garden.io/v1
kind: Project
name: vote
environments:
  - name: local
providers:
  - name: local-kubernetes
    environments: [ local ]

---

kind: Run
name: test-run
type: kubernetes-exec
spec:
  command: [ "echo", "foo" ]
  resource:
    podSelector:
      name: "my-pod"

Which issue(s) this PR fixes:

Without this fix, the example above will crash with the following error:

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Encountered an unexpected Garden error. This is likely a bug 🍂

You can help by reporting this on GitHub: https://github.com/garden-io/garden/issues/new?labels=bug,crash&template=CRASH.md&title=Crash%3A%20Must%20specify%20name%20in%20resource%2Ftarget%20query

Please attach the following information to the bug report after making sure that the error message does not contain sensitive information:

Failed processing Run type=kubernetes-exec name=test-run (took 0.07 sec). This is what happened:
Error: Must specify name in resource/target query
    at readTargetResource (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/plugins/kubernetes/util.js:521:15)
    at readAndExec (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/plugins/kubernetes/kubernetes-type/kubernetes-exec.js:94:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Object.run (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/plugins/kubernetes/kubernetes-type/kubernetes-exec.js:52:28)
    at async Object.assign.handlerType.handlerType (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/router/base.js:215:28)
    at async Router.callHandler (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/router/base.js:186:24)
    at async run (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/router/run.js:46:28)
    at async RunTask.process (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/tasks/run.js:69:28)
    at async descriptor.value (file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/tasks/base.js:382:29)
    at async file:///Users/vladimirvagaytsev/Repositories/garden/core/build/src/util/open-telemetry/decorators.js:44:30
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 requested run action(s) failed!

Special notes for your reviewer:

@vvagaytsev vvagaytsev requested review from stefreak and 10ko November 20, 2024 10:09
10ko
10ko previously approved these changes Nov 20, 2024
@vvagaytsev vvagaytsev force-pushed the fix/pod-selector-in-kubernetes-exec branch from 65bf158 to a80868b Compare November 20, 2024 10:25
@vvagaytsev vvagaytsev requested a review from 10ko November 20, 2024 10:26
Copy link
Member

@stefreak stefreak left a comment

Choose a reason for hiding this comment

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

Nice! great bug fix

@vvagaytsev vvagaytsev added this pull request to the merge queue Nov 20, 2024
Merged via the queue into main with commit 3e680e0 Nov 20, 2024
40 checks passed
@vvagaytsev vvagaytsev deleted the fix/pod-selector-in-kubernetes-exec branch November 20, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants