• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NVIDIA / skyhook / 20174212535

12 Dec 2025 05:08PM UTC coverage: 76.44%. First build
20174212535

Pull #127

github

t0mmylam
feat(cli): Add lifecycle management commands (pause, resume, disable, enable)
Pull Request #127: feat(cli): Add lifecycle management commands (pause, resume, disable, enable)

1159 of 1462 new or added lines in 17 files covered. (79.27%)

5798 of 7585 relevant lines covered (76.44%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.76
/operator/internal/cli/pause.go
1
/*
2
 * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
 * SPDX-License-Identifier: Apache-2.0
4
 *
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18

19
package cli
20

21
import (
22
        "fmt"
23

24
        "github.com/spf13/cobra"
25

26
        "github.com/NVIDIA/skyhook/operator/internal/cli/client"
27
        cliContext "github.com/NVIDIA/skyhook/operator/internal/cli/context"
28
        "github.com/NVIDIA/skyhook/operator/internal/cli/utils"
29
)
30

31
// pauseOptions holds the options for the pause command
32
type pauseOptions struct {
33
        confirm bool
34
}
35

36
// BindToCmd binds the options to the command flags
37
func (o *pauseOptions) BindToCmd(cmd *cobra.Command) {
1✔
38
        cmd.Flags().BoolVarP(&o.confirm, "confirm", "y", false, "Skip confirmation prompt")
1✔
39
}
1✔
40

41
// NewPauseCmd creates the pause command
42
func NewPauseCmd(ctx *cliContext.CLIContext) *cobra.Command {
1✔
43
        opts := &pauseOptions{}
1✔
44

1✔
45
        cmd := &cobra.Command{
1✔
46
                Use:   "pause <skyhook-name>",
1✔
47
                Short: "Pause a Skyhook from processing",
1✔
48
                Long: `Pause a Skyhook by setting the pause annotation.
1✔
49

1✔
50
When a Skyhook is paused, the operator will stop processing new nodes
1✔
51
but will not interrupt any currently running operations.`,
1✔
52
                Example: `  # Pause a Skyhook
1✔
53
  kubectl skyhook pause gpu-init
1✔
54

1✔
55
  # Pause without confirmation
1✔
56
  kubectl skyhook pause gpu-init --confirm`,
1✔
57
                Args: cobra.ExactArgs(1),
1✔
58
                RunE: func(cmd *cobra.Command, args []string) error {
1✔
NEW
59
                        skyhookName := args[0]
×
NEW
60

×
NEW
61
                        if !opts.confirm {
×
NEW
62
                                _, _ = fmt.Fprintf(cmd.OutOrStdout(), "This will pause Skyhook %q. Continue? [y/N]: ", skyhookName)
×
NEW
63
                                var response string
×
NEW
64
                                if _, err := fmt.Scanln(&response); err != nil || (response != "y" && response != "Y") {
×
NEW
65
                                        _, _ = fmt.Fprintln(cmd.OutOrStdout(), "Aborted.")
×
NEW
66
                                        return nil
×
NEW
67
                                }
×
68
                        }
69

NEW
70
                        clientFactory := client.NewFactory(ctx.GlobalFlags.ConfigFlags)
×
NEW
71
                        kubeClient, err := clientFactory.Client()
×
NEW
72
                        if err != nil {
×
NEW
73
                                return fmt.Errorf("initializing kubernetes client: %w", err)
×
NEW
74
                        }
×
75

NEW
76
                        if err := utils.SetSkyhookAnnotation(cmd.Context(), kubeClient.Dynamic(), skyhookName, utils.PauseAnnotation, "true"); err != nil {
×
NEW
77
                                return err
×
NEW
78
                        }
×
NEW
79
                        _, _ = fmt.Fprintf(cmd.OutOrStdout(), "Skyhook %q paused\n", skyhookName)
×
NEW
80
                        return nil
×
81
                },
82
        }
83

84
        opts.BindToCmd(cmd)
1✔
85

1✔
86
        return cmd
1✔
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc