Skip to content

Commit

Permalink
Merge pull request #2119 from wenwutang1/master
Browse files Browse the repository at this point in the history
add flag skip-dependency-check when upgrade cluster
  • Loading branch information
ks-ci-bot authored Feb 13, 2024
2 parents fa646fb + f47d36a commit fb2a8ce
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
35 changes: 19 additions & 16 deletions cmd/kk/cmd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ import (
)

type UpgradeOptions struct {
CommonOptions *options.CommonOptions
ClusterCfgFile string
Kubernetes string
EnableKubeSphere bool
KubeSphere string
SkipPullImages bool
DownloadCmd string
Artifact string
CommonOptions *options.CommonOptions
ClusterCfgFile string
Kubernetes string
EnableKubeSphere bool
KubeSphere string
SkipPullImages bool
SkipDependencyCheck bool
DownloadCmd string
Artifact string
}

func NewUpgradeOptions() *UpgradeOptions {
Expand Down Expand Up @@ -80,14 +81,15 @@ func (o *UpgradeOptions) Complete(cmd *cobra.Command, args []string) error {

func (o *UpgradeOptions) Run() error {
arg := common.Argument{
FilePath: o.ClusterCfgFile,
KubernetesVersion: o.Kubernetes,
KsEnable: o.EnableKubeSphere,
KsVersion: o.KubeSphere,
SkipPullImages: o.SkipPullImages,
Debug: o.CommonOptions.Verbose,
SkipConfirmCheck: o.CommonOptions.SkipConfirmCheck,
Artifact: o.Artifact,
FilePath: o.ClusterCfgFile,
KubernetesVersion: o.Kubernetes,
KsEnable: o.EnableKubeSphere,
KsVersion: o.KubeSphere,
SkipPullImages: o.SkipPullImages,
Debug: o.CommonOptions.Verbose,
SkipConfirmCheck: o.CommonOptions.SkipConfirmCheck,
Artifact: o.Artifact,
SkipDependencyCheck: o.SkipDependencyCheck,
}
return pipelines.UpgradeCluster(arg, o.DownloadCmd)
}
Expand All @@ -100,6 +102,7 @@ func (o *UpgradeOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&o.DownloadCmd, "download-cmd", "", "curl -L -o %s %s",
`The user defined command to download the necessary binary files. The first param '%s' is output path, the second param '%s', is the URL`)
cmd.Flags().StringVarP(&o.Artifact, "artifact", "a", "", "Path to a KubeKey artifact")
cmd.Flags().BoolVarP(&o.SkipDependencyCheck, "skip-dependency-check", "", false, "Skip kubernetes and kubesphere dependency version check")
}

func completionSetting(cmd *cobra.Command) (err error) {
Expand Down
29 changes: 21 additions & 8 deletions cmd/kk/pkg/bootstrap/precheck/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (n *NodePreCheckModule) Init() {

type ClusterPreCheckModule struct {
common.KubeModule
SkipDependencyCheck bool
}

func (c *ClusterPreCheckModule) Init() {
Expand Down Expand Up @@ -159,13 +160,25 @@ func (c *ClusterPreCheckModule) Init() {
Parallel: true,
}

c.Tasks = []task.Interface{
getKubeConfig,
getAllNodesK8sVersion,
calculateMinK8sVersion,
checkDesiredK8sVersion,
ksVersionCheck,
dependencyCheck,
getKubernetesNodesStatus,
if !c.SkipDependencyCheck {
c.Tasks = []task.Interface{
getKubeConfig,
getAllNodesK8sVersion,
calculateMinK8sVersion,
checkDesiredK8sVersion,
ksVersionCheck,
dependencyCheck,
getKubernetesNodesStatus,
}
} else {
c.Tasks = []task.Interface{
getKubeConfig,
getAllNodesK8sVersion,
calculateMinK8sVersion,
checkDesiredK8sVersion,
ksVersionCheck,
getKubernetesNodesStatus,
}
}

}
1 change: 1 addition & 0 deletions cmd/kk/pkg/common/kube_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Argument struct {
IgnoreErr bool
SkipPullImages bool
SkipPushImages bool
SkipDependencyCheck bool
SecurityEnhancement bool
DeployLocalStorage *bool
DownloadCommand func(path, url string) string
Expand Down
2 changes: 1 addition & 1 deletion cmd/kk/pkg/pipelines/upgrade_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewUpgradeClusterPipeline(runtime *common.KubeRuntime) error {
m := []module.Module{
&precheck.GreetingsModule{},
&precheck.NodePreCheckModule{},
&precheck.ClusterPreCheckModule{},
&precheck.ClusterPreCheckModule{SkipDependencyCheck: runtime.Arg.SkipDependencyCheck},
&confirm.UpgradeConfirmModule{Skip: runtime.Arg.SkipConfirmCheck},
&artifact.UnArchiveModule{Skip: noArtifact},
&kubernetes.SetUpgradePlanModule{Step: kubernetes.ToV121},
Expand Down

0 comments on commit fb2a8ce

Please sign in to comment.