Skip to content

Commit

Permalink
operator: add sub-command rook restart
Browse files Browse the repository at this point in the history
this commit add sub-command `odf operator rook restart`
to restart the rook operator pod and related docs.

Signed-off-by: subhamkrai <[email protected]>
  • Loading branch information
subhamkrai committed Mar 5, 2024
1 parent 4fa67f3 commit 029d522
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The ODF CLI tool provides configuration and troubleshooting commands for OpenShi
- `odf operator`:
- `rook`:
- `set`: Set the property in the rook-ceph-operator-config configmap.
- `restart` : Restart the Rook-Ceph operator
- `odf help` : Display help text

## Documentation
Expand Down
7 changes: 4 additions & 3 deletions cmd/odf/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

// OperatorCmd represents the rook commands
var OperatorCmd = &cobra.Command{
Use: "operator",
Short: "Calls subcommands specific to various ODF operators",
Args: cobra.ExactArgs(1),
Use: "operator",
Short: "Calls subcommands specific to various ODF operators",
Args: cobra.ExactArgs(1),
Hidden: true,
}

func init() {
Expand Down
21 changes: 21 additions & 0 deletions cmd/odf/operator/rook/restart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package rook

import (
"github.com/red-hat-storage/odf-cli/cmd/odf/root"
"github.com/rook/kubectl-rook-ceph/pkg/k8sutil"
"github.com/spf13/cobra"
)

var restartCmd = &cobra.Command{
Use: "restart",
Short: "Restart rook-ceph-operator pod",
Args: cobra.NoArgs,
Example: "odf operator rook restart",
PreRun: func(cmd *cobra.Command, args []string) {
// verify operator pod is running
k8sutil.WaitForPodToRun(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "app=rook-ceph-operator")
},
Run: func(cmd *cobra.Command, _ []string) {
k8sutil.RestartDeployment(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "rook-ceph-operator")
},
}
1 change: 1 addition & 0 deletions cmd/odf/operator/rook/rook.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ var RookCmd = &cobra.Command{

func init() {
RookCmd.AddCommand(setCmd)
RookCmd.AddCommand(restartCmd)
}
17 changes: 16 additions & 1 deletion docs/operator.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Operator Commands

## Set
Operator is parent command which requires sub-command. Currently, operator supports these sub-commands:

- `set <property> <value>` : [set](#set) the property in the rook-ceph-operator-config configmap.
- `restart`: [restart](#restart) the Rook-Ceph operator

## set

Set the property in the rook-ceph-operator-config configmap

Expand All @@ -9,3 +14,13 @@ $ odf operator rook set ROOK_LOG_LEVEL DEBUG

configmap/rook-ceph-operator-config patched
```

## restart

Restart the Rook-Ceph operator.

``` bash
$ odf operator rook restart

deployment.apps/rook-ceph-operator restarted
```

0 comments on commit 029d522

Please sign in to comment.