Skip to content

Commit c75dbbf

Browse files
authored
feat(cli): add package and node management commands with lifecycle controls (#123)
Add comprehensive CLI commands for managing Skyhook packages and nodes: Package Commands: - `package rerun`: Force re-execution of packages on specific nodes - Support for stage-specific re-runs (apply, config, interrupt, post-interrupt) - Node matching via exact names or regex patterns - `package status`: Query package status across the cluster - `package logs`: Retrieve package execution logs with follow/tail support Node Commands: - `node list`: List all nodes with Skyhook status - `node status`: Display detailed status for specific nodes - `node ignore`: Add/remove ignore label to pause operations on nodes - `node reset`: Reset node state for a Skyhook Lifecycle Commands: - `pause`: Pause Skyhook reconciliation temporarily - `resume`: Resume paused Skyhook operations - `disable`: Disable a Skyhook completely - `enable`: Re-enable a disabled Skyhook Also includes: - Comprehensive unit tests with K8s dynamic client mocks - CLI e2e test suite using chainsaw (lifecycle, node, package tests) - CI integration for CLI tests in operator-ci workflow - Shared utilities for node matching, label management, and patch-based updates
1 parent e363f2d commit c75dbbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+9338
-140
lines changed

.github/workflows/operator-ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ jobs:
6161
test-suite: deployment-policy
6262
kind-config: k8s-tests/chainsaw/deployment-policy/kind-config.yaml
6363
make-target: deployment-policy-tests
64+
# CLI e2e tests on K8s 1.34 only
65+
- k8s-version: "1.34.0"
66+
test-suite: cli-e2e
67+
make-target: cli-e2e-tests
6468
fail-fast: false # Continue testing other versions if one fails
6569
name: ${{ matrix.test-suite }}-tests (k8s-${{ matrix.k8s-version }})
6670
steps:
@@ -118,6 +122,9 @@ jobs:
118122
if [ "${{ matrix.test-suite }}" = "e2e" ]; then
119123
make setup-kind-cluster
120124
make test
125+
elif [ "${{ matrix.test-suite }}" = "cli-e2e" ]; then
126+
make setup-kind-cluster
127+
make ${{ matrix.make-target }}
121128
else
122129
make ${{ matrix.make-target }}
123130
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-lifecycle-test
21+
annotations:
22+
skyhook.nvidia.com/disable: "true"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-lifecycle-test
21+
# Note: Chainsaw will verify that disable annotation is NOT present
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-lifecycle-test
21+
annotations:
22+
skyhook.nvidia.com/pause: "true"
23+
skyhook.nvidia.com/disable: "true"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-lifecycle-test
21+
annotations:
22+
skyhook.nvidia.com/pause: "true"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-lifecycle-test
21+
# Note: Chainsaw will verify that pause annotation is NOT present
22+
# by checking the resource exists without that annotation
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-lifecycle-test
21+
annotations:
22+
# pause annotation should be removed, but disable should remain
23+
skyhook.nvidia.com/disable: "true"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
18+
apiVersion: chainsaw.kyverno.io/v1alpha1
19+
kind: Test
20+
metadata:
21+
name: cli-lifecycle
22+
spec:
23+
description: |
24+
Test all CLI lifecycle commands:
25+
- pause: pauses a Skyhook from processing
26+
- resume: resumes a paused Skyhook
27+
- disable: disables a Skyhook completely
28+
- enable: enables a disabled Skyhook
29+
timeouts:
30+
assert: 60s
31+
exec: 30s
32+
steps:
33+
# Step 1: Create a Skyhook
34+
- name: setup-skyhook
35+
try:
36+
- apply:
37+
file: skyhook.yaml
38+
- script:
39+
timeout: 30s
40+
content: |
41+
echo "Waiting for Skyhook to be created..."
42+
for i in $(seq 1 15); do
43+
if kubectl get skyhook cli-lifecycle-test 2>/dev/null; then
44+
echo "Skyhook created"
45+
exit 0
46+
fi
47+
sleep 2
48+
done
49+
echo "Timeout waiting for Skyhook"
50+
exit 1
51+
52+
# Step 2: Test pause command
53+
- name: test-pause
54+
try:
55+
- script:
56+
timeout: 30s
57+
content: |
58+
../../../../operator/bin/skyhook pause cli-lifecycle-test --confirm
59+
- assert:
60+
file: assert-paused.yaml
61+
62+
# Step 3: Test resume command
63+
- name: test-resume
64+
try:
65+
- script:
66+
timeout: 30s
67+
content: |
68+
../../../../operator/bin/skyhook resume cli-lifecycle-test
69+
- assert:
70+
file: assert-resumed.yaml
71+
72+
# Step 4: Test disable command
73+
- name: test-disable
74+
try:
75+
- script:
76+
timeout: 30s
77+
content: |
78+
../../../../operator/bin/skyhook disable cli-lifecycle-test --confirm
79+
- assert:
80+
file: assert-disabled.yaml
81+
82+
# Step 5: Test enable command
83+
- name: test-enable
84+
try:
85+
- script:
86+
timeout: 30s
87+
content: |
88+
../../../../operator/bin/skyhook enable cli-lifecycle-test
89+
- assert:
90+
file: assert-enabled.yaml
91+
92+
# Step 6: Test pause and disable together
93+
- name: test-pause-and-disable
94+
try:
95+
- script:
96+
timeout: 30s
97+
content: |
98+
../../../../operator/bin/skyhook pause cli-lifecycle-test --confirm
99+
../../../../operator/bin/skyhook disable cli-lifecycle-test --confirm
100+
- assert:
101+
file: assert-paused-and-disabled.yaml
102+
- script:
103+
timeout: 30s
104+
content: |
105+
# Resume should only remove pause, not disable
106+
../../../../operator/bin/skyhook resume cli-lifecycle-test
107+
- assert:
108+
file: assert-still-disabled.yaml
109+
- script:
110+
timeout: 30s
111+
content: |
112+
# Enable should remove disable
113+
../../../../operator/bin/skyhook enable cli-lifecycle-test
114+
115+
# Cleanup
116+
- name: cleanup
117+
try:
118+
- script:
119+
content: |
120+
kubectl delete skyhook cli-lifecycle-test 2>/dev/null || true
121+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: skyhook.nvidia.com/v1alpha1
18+
kind: Skyhook
19+
metadata:
20+
name: cli-lifecycle-test
21+
spec:
22+
nodeSelectors:
23+
matchLabels:
24+
skyhook.nvidia.com/test-node: skyhooke2e
25+
packages:
26+
test-package:
27+
version: "1.0.0"
28+
image: ghcr.io/nvidia/skyhook-packages/shellscript
29+
configMap:
30+
apply.sh: |
31+
#!/bin/bash
32+
echo "Lifecycle test apply"
33+
sleep 2
34+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
apiVersion: v1
18+
kind: Node
19+
metadata:
20+
labels:
21+
skyhook.nvidia.com/test-node: skyhooke2e
22+
skyhook.nvidia.com/ignore: "true"

0 commit comments

Comments
 (0)