Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support to run ops forcibly #289

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ kbcli cluster configure NAME --set key=value[,key=value] [--components=component
--config-file string Specify the name of the configuration file to be updated (e.g. for mysql: --config-file=my.cnf). For available templates and configs, refer to: 'kbcli cluster describe-config'.
--config-spec string Specify the name of the configuration template to be updated (e.g. for apecloud-mysql: --config-spec=mysql-3node-tpl). For available templates and configs, refer to: 'kbcli cluster describe-config'.
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
--force-restart Boolean flag to restart component. Default with false.
-h, --help help for configure
--local-file string Specify the local configuration file to be updated.
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--replace Boolean flag to enable replacing config file. Default with false.
--set strings Specify parameters list to be updated. For more details, refer to 'kbcli cluster describe-config'.
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_custom-ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ kbcli cluster custom-ops OpsDef --cluster <clusterName> <your custom params> [fl
--cluster string Specify the cluster name
--component string Specify the component name of the cluster. if not specified, using the first component which referenced the defined componentDefinition.
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for custom-ops
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
```
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_edit-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ kbcli cluster edit-config NAME [--component=component-name] [--config-spec=confi
--config-spec string Specify the name of the configuration template to be updated (e.g. for apecloud-mysql: --config-spec=mysql-3node-tpl). For available templates and configs, refer to: 'kbcli cluster describe-config'.
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--enable-delete Boolean flag to enable delete configuration. Default with false.
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
--force-restart Boolean flag to restart component. Default with false.
-h, --help help for edit-config
--local-file string Specify the local configuration file to be updated.
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--replace Boolean flag to enable replacing config file. Default with false.
--set strings Specify parameters list to be updated. For more details, refer to 'kbcli cluster describe-config'.
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_expose.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ kbcli cluster expose NAME --enable=[true|false] --type=[vpc|internet] [flags]
--components strings Component names to this operations
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--enable string Enable or disable the expose, values can be true or false
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for expose
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
--type string Expose type, currently supported types are 'vpc', 'internet'
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_hscale.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ kbcli cluster hscale NAME [flags]
--auto-approve Skip interactive approval before horizontally scaling the cluster
--components strings Component names to this operations
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for hscale
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--replicas int Replicas with the specified components
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
Expand Down
4 changes: 2 additions & 2 deletions docs/user_docs/cli/kbcli_cluster_promote.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ kbcli cluster promote NAME [--component=<comp-name>] [--instance <instance-name>
--auto-approve Skip interactive approval before promote the instance
--component string Specify the component name of the cluster, if the cluster has multiple components, you need to specify a component
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force force switchover if failed
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for promote
--instance string Specify the instance name as the new primary or leader of the cluster, you can get the instance name by running "kbcli cluster list-instances"
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
```
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_restart.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ kbcli cluster restart NAME [flags]
--auto-approve Skip interactive approval before restarting the cluster
--components strings Component names to this operations
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for restart
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
```
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ kbcli cluster start NAME [flags]

```
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for start
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
```
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ kbcli cluster stop NAME [flags]
```
--auto-approve Skip interactive approval before stopping the cluster
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for stop
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
```
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ kbcli cluster upgrade NAME [flags]
--auto-approve Skip interactive approval before upgrading the cluster
--cluster-version string Reference cluster version (required)
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for upgrade
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
```
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_volume-expand.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ kbcli cluster volume-expand NAME [flags]
--auto-approve Skip interactive approval before expanding the cluster volume
--components strings Component names to this operations
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for volume-expand
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--storage string Volume storage size (required)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
Expand Down
3 changes: 2 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_vscale.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ kbcli cluster vscale NAME [flags]
--components strings Component names to this operations
--cpu string Request and limit size of component cpu
--dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none")
--force skip the pre-checks of the opsRequest to run the opsRequest forcibly
-h, --help help for vscale
--memory string Request and limit size of component memory
--name string OpsRequest name. if not specified, it will be randomly generated
--name string OpsRequest name. if not specified, it will be randomly generated
-o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml)
--ttlSecondsAfterSucceed int Time to live after the OpsRequest succeed
```
Expand Down
2 changes: 2 additions & 0 deletions pkg/action/template/cluster_operations_template.cue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ options: {
cfgTemplateName: string
cfgFile: string
forceRestart: bool
force: bool
services: [
...{
name: string
Expand Down Expand Up @@ -81,6 +82,7 @@ content: {
clusterRef: options.name
type: options.type
ttlSecondsAfterSucceed: options.ttlSecondsAfterSucceed
force: options.force
if options.type == "Upgrade" {
upgrade: #upgrade
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/action/template/opsrequest_template.cue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ options: {
opsType: string
backupSpec: {}
restoreSpec: {}
force: bool
}

// required, k8s api resource content
Expand All @@ -36,6 +37,7 @@ content: {
spec: {
clusterRef: options.clusterRef
type: options.opsType
force: options.force
if options.opsType == "Backup" {
backupSpec: options.backupSpec
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/cluster/dataprotection.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type CreateBackupOptions struct {
ClusterRef string `json:"clusterRef"`
OpsType string `json:"opsType"`
OpsRequestName string `json:"opsRequestName"`
Force bool `json:"force"`

action.CreateOptions `json:"-"`
}
Expand Down Expand Up @@ -501,6 +502,7 @@ type CreateRestoreOptions struct {
ClusterRef string `json:"clusterRef"`
OpsType string `json:"opsType"`
OpsRequestName string `json:"opsRequestName"`
Force bool `json:"force"`

action.CreateOptions `json:"-"`
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/cmd/cluster/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type OperationsOptions struct {
ComponentNames []string `json:"componentNames,omitempty"`
OpsRequestName string `json:"opsRequestName"`
TTLSecondsAfterSucceed int `json:"ttlSecondsAfterSucceed"`
Force bool `json:"force"`

// OpsType operation type
OpsType appsv1alpha1.OpsType `json:"type"`
Expand Down Expand Up @@ -108,7 +109,6 @@ type OperationsOptions struct {
Component string `json:"component"`
Instance string `json:"instance"`
Primary string `json:"-"`
Force bool `json:"-"`
CharacterType string `json:"-"`
LorryHAEnabled bool `json:"-"`
ExecPod *corev1.Pod `json:"-"`
Expand Down Expand Up @@ -148,8 +148,8 @@ func newBaseOperationsOptions(f cmdutil.Factory, streams genericiooptions.IOStre
func (o *OperationsOptions) addCommonFlags(cmd *cobra.Command, f cmdutil.Factory) {
// add print flags
printer.AddOutputFlagForCreate(cmd, &o.Format, false)

cmd.Flags().StringVar(&o.OpsRequestName, "name", "", "OpsRequest name. if not specified, it will be randomly generated ")
cmd.Flags().BoolVar(&o.Force, "force", false, " skip the pre-checks of the opsRequest to run the opsRequest forcibly")
cmd.Flags().StringVar(&o.OpsRequestName, "name", "", "OpsRequest name. if not specified, it will be randomly generated")
cmd.Flags().IntVar(&o.TTLSecondsAfterSucceed, "ttlSecondsAfterSucceed", 0, "Time to live after the OpsRequest succeed")
cmd.Flags().StringVar(&o.DryRun, "dry-run", "none", `Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent.`)
cmd.Flags().Lookup("dry-run").NoOptDefVal = "unchanged"
Expand Down Expand Up @@ -1034,7 +1034,6 @@ func NewPromoteCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra
flags.AddComponentFlag(f, cmd, &o.Component, "Specify the component name of the cluster, if the cluster has multiple components, you need to specify a component")
cmd.Flags().StringVar(&o.Instance, "instance", "", "Specify the instance name as the new primary or leader of the cluster, you can get the instance name by running \"kbcli cluster list-instances\"")
cmd.Flags().BoolVar(&o.AutoApprove, "auto-approve", false, "Skip interactive approval before promote the instance")
cmd.Flags().BoolVar(&o.Force, "force", false, "force switchover if failed")
o.addCommonFlags(cmd, f)
return cmd
}
Expand Down
Loading