From a3ad4c4a85677b1e6126faaf94a80f5a96a385d9 Mon Sep 17 00:00:00 2001 From: aby913 Date: Tue, 10 Sep 2024 12:21:44 +0800 Subject: [PATCH] fix: uninstall certs file --- pkg/certs/module.go | 19 +++++++++++++++++++ pkg/certs/tasks.go | 15 +++++++++++++++ pkg/phase/cluster/delete_cluster.go | 1 + 3 files changed, 35 insertions(+) diff --git a/pkg/certs/module.go b/pkg/certs/module.go index 5955e7c..67decff 100644 --- a/pkg/certs/module.go +++ b/pkg/certs/module.go @@ -214,3 +214,22 @@ func (u *UninstallAutoRenewCertsModule) Init() { uninstall, } } + +type UninstallCertsFilesModule struct { + common.KubeModule +} + +func (m *UninstallCertsFilesModule) Init() { + m.Name = "UninstallCertsFilesModule" + + uninstall := &task.RemoteTask{ + Name: "UninstallCertsFiles", + Hosts: m.Runtime.GetHostsByRole(common.Master), + Action: new(UninstallCertsFiles), + Parallel: true, + } + + m.Tasks = []task.Interface{ + uninstall, + } +} diff --git a/pkg/certs/tasks.go b/pkg/certs/tasks.go index 5e4e632..d2b9865 100644 --- a/pkg/certs/tasks.go +++ b/pkg/certs/tasks.go @@ -20,6 +20,7 @@ import ( "encoding/base64" "fmt" "os" + "path" "path/filepath" "strings" "text/tabwriter" @@ -27,7 +28,9 @@ import ( "bytetrade.io/web3os/installer/pkg/certs/templates" "bytetrade.io/web3os/installer/pkg/common" + cc "bytetrade.io/web3os/installer/pkg/core/common" "bytetrade.io/web3os/installer/pkg/core/connector" + "bytetrade.io/web3os/installer/pkg/core/util" "bytetrade.io/web3os/installer/pkg/utils" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/runtime/schema" @@ -414,3 +417,15 @@ func (u *UninstallAutoRenewCerts) Execute(runtime connector.Runtime) error { return nil } + +type UninstallCertsFiles struct { + common.KubeAction +} + +func (t *UninstallCertsFiles) Execute(runtime connector.Runtime) error { + var p = path.Join(runtime.GetBaseDir(), cc.Cli) + if util.IsExist(p) { + return util.RemoveDir(p) + } + return nil +} diff --git a/pkg/phase/cluster/delete_cluster.go b/pkg/phase/cluster/delete_cluster.go index f611029..e848e5a 100644 --- a/pkg/phase/cluster/delete_cluster.go +++ b/pkg/phase/cluster/delete_cluster.go @@ -94,6 +94,7 @@ func (p *phaseBuilder) phaseInstall() *phaseBuilder { &os.ClearOSEnvironmentModule{}, &certs.UninstallAutoRenewCertsModule{}, &container.KillContainerdProcessModule{}, + &certs.UninstallCertsFilesModule{}, &storage.DeleteUserDataModule{}, &storage.DeletePhaseFlagModule{ PhaseFile: ".installed",