Skip to content

Commit

Permalink
refactor(autok3s): ensure that the '.state' file is written after the…
Browse files Browse the repository at this point in the history
… process executes correctly

Signed-off-by: Jason-ZW <zhenyang@rancher.com>
  • Loading branch information
rancher-sy-bot committed Aug 28, 2020
1 parent 24aa1fa commit 9f5640a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func InitK3sCluster(cluster *types.Cluster) error {
}

for _, master := range cluster.MasterNodes {
if strings.Contains(masterExtraArgs, "--docker") {
if strings.Contains(masterExtraArgs, "--docker" ) {
if _, err := execute(&hosts.Host{Node: master},
fmt.Sprintf(dockerCommand, dockerMirror), false); err != nil {
return err
Expand Down Expand Up @@ -121,16 +121,6 @@ func InitK3sCluster(cluster *types.Cluster) error {
return err
}

// merge current cluster to kube config.
if err := saveCfg(cfg, publicIP, cluster.Name); err != nil {
return err
}

// write current cluster to state file.
if err := saveState(cluster); err != nil {
return err
}

// deploy additional Terway manifests.
if terway != nil {
tmpl := fmt.Sprintf(terwayTmpl, terway.AccessKey, terway.AccessSecret, terway.SecurityGroup, terway.CIDR, terway.VSwitches, terway.MaxPoolSize)
Expand All @@ -154,6 +144,16 @@ func InitK3sCluster(cluster *types.Cluster) error {
}
}

// merge current cluster to kube config.
if err := saveCfg(cfg, publicIP, cluster.Name); err != nil {
return err
}

// write current cluster to state file.
if err := saveState(cluster); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 9f5640a

Please # to comment.