--node-collector-namespace: Do not delete existing namespace #6538
Closed
codinux-gmbh
started this conversation in
Bugs
Replies: 3 comments 2 replies
-
@chen-keinan can you take a look? |
Beta Was this translation helpful? Give feedback.
0 replies
-
@codinux-gmbh thanks for the input, just to clarify the The namespace should not include other resources in it. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Related issue #6558 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
When using
trivy kubernetes --node-collector-namespace <namespace> ...
, then the namespace<namespace>
gets deleted after the operation even if it's an existing namespace that contains resources.That deleted almost our whole (for sake test) cluster.
(Scanning the whole cluster for misconfiguration ran into a timeout, so we decided to automatically scan namespace per namespace. But then jobs sometimes failed as the previous job in the
trivy-temp
namespace was still running, so we decided to run each job in the namespace to scan via--node-collector-namespace
flag.)The issue is in
pkg/jobs/collector.go
:Desired Behavior
First check if Trivy created that namespace before deleting it.
Actual Behavior
The namespace passed with
--node-collector-namespace
gets deleted regardless if Trivy created that namespace or if it's an existing namespace that contains resources.Reproduction Steps
Target
Kubernetes
Scanner
None
Output Format
None
Mode
None
Debug Output
The output doesn't matter, the clean up behavior is the issue.
Operating System
Arch Linux, but also the OS doesn't matter
Version
Checklist
trivy image --reset
Beta Was this translation helpful? Give feedback.
All reactions