diff --git a/pkg/bootstrap/os/module.go b/pkg/bootstrap/os/module.go index a0d34f2..af87998 100644 --- a/pkg/bootstrap/os/module.go +++ b/pkg/bootstrap/os/module.go @@ -40,9 +40,10 @@ func (p *PvePatchModule) Init() { p.Name = "PvePatch" removePveCNDomain := &task.LocalTask{ - Name: "RemovePveCNDomain", - Action: new(RemoveCNDomain), - Retry: 1, + Name: "RemovePveCNDomain", + Action: new(RemoveCNDomain), + Prepare: new(IsPve), + Retry: 1, } patchLxcInitScript := &task.LocalTask{ diff --git a/pkg/bootstrap/os/prepares.go b/pkg/bootstrap/os/prepares.go index 732a2fa..0afdcb1 100644 --- a/pkg/bootstrap/os/prepares.go +++ b/pkg/bootstrap/os/prepares.go @@ -96,3 +96,15 @@ func (r *IsPveLxc) PreCheck(runtime connector.Runtime) (bool, error) { } return false, nil } + +type IsPve struct { + common.KubePrepare +} + +func (r *IsPve) PreCheck(runtime connector.Runtime) (bool, error) { + sys := runtime.GetSystemInfo() + if sys.IsPve() { + return true, nil + } + return false, nil +} diff --git a/pkg/bootstrap/patch/tasks.go b/pkg/bootstrap/patch/tasks.go index e29fb37..a19c376 100644 --- a/pkg/bootstrap/patch/tasks.go +++ b/pkg/bootstrap/patch/tasks.go @@ -74,7 +74,7 @@ func (t *PatchTask) Execute(runtime connector.Runtime) error { fallthrough case common.Ubuntu: if systemInfo.IsUbuntu() { - if !systemInfo.IsPve() && !systemInfo.IsRaspbian() { + if !systemInfo.IsPveOrPveLxc() && !systemInfo.IsRaspbian() { if _, err := runtime.GetRunner().Host.SudoCmd("add-apt-repository universe -y", false, true); err != nil { logger.Errorf("add os repo error %v", err) return err diff --git a/pkg/core/connector/system.go b/pkg/core/connector/system.go index f09ff4f..4405ccc 100644 --- a/pkg/core/connector/system.go +++ b/pkg/core/connector/system.go @@ -224,7 +224,7 @@ func (s *SystemInfo) IsDarwin() bool { } func (s *SystemInfo) IsPve() bool { - return strings.Contains(s.HostInfo.OsKernel, "-pve") + return s.HostInfo.OsPlatform == common.PVE } func (s *SystemInfo) IsPveLxc() bool {