Skip to content

Commit

Permalink
fix(platform): only validate ha for mater scale case (tkestack#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxiaoliang committed Nov 26, 2020
1 parent d7b7a46 commit f033396
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions api/platform/validation/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ func ValidateClusterUpdate(cluster *types.Cluster, oldCluster *types.Cluster) fi

// ValidateClusterScale tests if master scale up/down to a cluster is valid.
func ValidateClusterScale(cluster *platform.Cluster, oldCluster *platform.Cluster, fldPath *field.Path) field.ErrorList {

allErrs := field.ErrorList{}
if len(cluster.Spec.Machines) == len(oldCluster.Spec.Machines) {
return allErrs
}
ha := cluster.Spec.Features.HA
if ha == nil {
allErrs = append(allErrs, field.Invalid(fldPath, cluster.Spec.Machines, "tkestack HA should enabled for master scale"))
allErrs = append(allErrs, field.Invalid(fldPath, cluster.Spec.Machines, "HA configuration should enabled for master scale"))
return allErrs
}
if ha.TKEHA == nil && ha.ThirdPartyHA == nil {
allErrs = append(allErrs, field.Invalid(fldPath, cluster.Spec.Machines, "tkestack HA should enabled for master scale"))
allErrs = append(allErrs, field.Invalid(fldPath, cluster.Spec.Machines, "tkestack HA or third party HA should enabled for master scale"))
return allErrs
}
_, err := clusterutil.PrepareClusterScale(cluster, oldCluster)
Expand Down
4 changes: 2 additions & 2 deletions pkg/platform/controller/cluster/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,13 @@ func (c *Controller) ensureSyncClusterMachineNodeLabel(ctx context.Context, clus

clusterWrapper, err := typesv1.GetCluster(ctx, c.platformClient, cluster)
if err != nil {
log.FromContext(ctx).Error(err, "sync ClusterMachine node label error")
log.FromContext(ctx).Error(err, "Get cluster error")
return
}

client, err := clusterWrapper.Clientset()
if err != nil {
log.FromContext(ctx).Error(err, "sync ClusterMachine node label error")
log.FromContext(ctx).Error(err, "get client set error")
return
}

Expand Down

0 comments on commit f033396

Please sign in to comment.