kubectl-gadget: Manage filtering by non-exisitent node
@@ -136,10 +136,12 @@ func GenericTraceCommand(
contextLogger.Fatalf("Error while getting trace rest client: %s", err)
}
+ nodeFound := false
for _, node := range nodes.Items {
if params.Node != "" && node.Name != params.Node {
continue
}
+ nodeFound = true
trace := &gadgetv1alpha1.Trace{
ObjectMeta: metav1.ObjectMeta{
@@ -179,6 +181,10 @@ func GenericTraceCommand(
}
}
+ if params.Node != "" && !nodeFound {
+ contextLogger.Fatalf("Invalid filter: Node %q does not exist", params.Node)
+ }
+
var listTracesOptions = metav1.ListOptions{
LabelSelector: fmt.Sprintf("trace-template-hash=%s", traceID),
FieldSelector: fields.Everything().String(),
