Skip to content

Commit

Permalink
fix(installer): helm uninstall chart after helm install chart wrong (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wl-chen committed Mar 15, 2022
1 parent 531ecf2 commit 8c7a53b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
33 changes: 30 additions & 3 deletions cmd/tke-installer/app/installer/installer.go
Expand Up @@ -1583,12 +1583,21 @@ func (t *TKE) installTKEGatewayChart(ctx context.Context) error {
ReleaseName: "tke-gateway",
DependencyUpdate: false,
Values: values,
Timeout: 60 * time.Second,
Timeout: 10 * time.Minute,
ChartPathOptions: *chartPathOptions,
}

chartFilePath := constants.ChartDirName + "tke-gateway/"
if _, err := t.helmClient.InstallWithLocal(installOptions, chartFilePath); err != nil {
uninstallOptions := helmaction.UninstallOptions{
Timeout: 10 * time.Minute,
ReleaseName: "tke-gateway",
Namespace: t.namespace,
}
reponse, err := t.helmClient.Uninstall(&uninstallOptions)
if err != nil {
return fmt.Errorf("%s uninstall fail, err = %s", reponse.Release.Name, err.Error())
}
return err
}

Expand Down Expand Up @@ -1699,12 +1708,21 @@ func (t *TKE) installTKEAuthChart(ctx context.Context) error {
ReleaseName: "tke-auth",
DependencyUpdate: false,
Values: values,
Timeout: 60 * time.Second,
Timeout: 10 * time.Minute,
ChartPathOptions: *chartPathOptions,
}

chartFilePath := constants.ChartDirName + "tke-auth/"
if _, err := t.helmClient.InstallWithLocal(installOptions, chartFilePath); err != nil {
uninstallOptions := helmaction.UninstallOptions{
Timeout: 10 * time.Minute,
ReleaseName: "tke-auth",
Namespace: t.namespace,
}
reponse, err := t.helmClient.Uninstall(&uninstallOptions)
if err != nil {
return fmt.Errorf("%s uninstall fail, err = %s", reponse.Release.Name, err.Error())
}
return err
}

Expand Down Expand Up @@ -1811,12 +1829,21 @@ func (t *TKE) installTKEPlatformChart(ctx context.Context) error {
ReleaseName: "tke-platform",
DependencyUpdate: false,
Values: values,
Timeout: 60 * time.Second,
Timeout: 10 * time.Minute,
ChartPathOptions: *chartPathOptions,
}

chartFilePath := constants.ChartDirName + "tke-platform/"
if _, err := t.helmClient.InstallWithLocal(installOptions, chartFilePath); err != nil {
uninstallOptions := helmaction.UninstallOptions{
Timeout: 10 * time.Minute,
ReleaseName: "tke-platform",
Namespace: t.namespace,
}
reponse, err := t.helmClient.Uninstall(&uninstallOptions)
if err != nil {
return fmt.Errorf("%s uninstall fail, err = %s", reponse.Release.Name, err.Error())
}
return err
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/platform/provider/baremetal/phases/kubeadm/kubeadm.go
Expand Up @@ -86,7 +86,8 @@ func Install(s ssh.Interface, option *Option) error {
cmd := "tar -C %s -xvaf %s %s --strip-components=3"
_, stderr, exit, err := s.Execf(cmd, constants.DstBinDir, dstFile, constants.KubeadmPathInNodePackge)
if err != nil || exit != 0 {
return fmt.Errorf("exec %q failed:exit %d:stderr %s:error %s", cmd, exit, stderr, err)
cmdStr := fmt.Sprintf(cmd, constants.DstBinDir, dstFile, constants.KubeadmPathInNodePackge)
return fmt.Errorf("exec %q failed:exit %d:stderr %s:error %s", cmdStr, exit, stderr, err.Error())
}

data, err := template.ParseFile(path.Join(constants.ConfDir, "kubeadm/10-kubeadm.conf"), option)
Expand Down

0 comments on commit 8c7a53b

Please sign in to comment.