Skip to content

Commit

Permalink
fix: ensure no containerd already exists before preparing (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkeven authored Dec 16, 2024
1 parent 7098d92 commit ee3ab00
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
12 changes: 12 additions & 0 deletions pkg/bootstrap/precheck/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ func (m *PreCheckOsModule) Init() {
Action: new(PreCheckSupport),
}

preCheckPortsBindable := &task.LocalTask{
Name: "PreCheckPortsBindable",
Action: new(PreCheckPortsBindable),
}

preCheckNoConflictingContainerd := &task.LocalTask{
Name: "PreCheckNoConflictingContainerd",
Action: new(PreCheckNoConflictingContainerd),
}

patchAppArmor := &task.RemoteTask{
Name: "PatchAppArmor",
Hosts: m.Runtime.GetAllHosts(),
Expand Down Expand Up @@ -125,6 +135,8 @@ func (m *PreCheckOsModule) Init() {

m.Tasks = []task.Interface{
preCheckSupport,
preCheckPortsBindable,
preCheckNoConflictingContainerd,
patchAppArmor,
raspbianCheck,
correctHostname,
Expand Down
38 changes: 38 additions & 0 deletions pkg/bootstrap/precheck/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package precheck
import (
"context"
"fmt"
"net"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -51,6 +52,43 @@ func (t *PreCheckSupport) Execute(runtime connector.Runtime) error {
return nil
}

type PreCheckPortsBindable struct {
common.KubeAction
}

func (t *PreCheckPortsBindable) Execute(runtime connector.Runtime) error {
ports := []int{80, 443, 444, 2444, 30180}
var unbindablePorts []int
for _, port := range ports {
l, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
unbindablePorts = append(unbindablePorts, port)
continue
}
defer l.Close()
}
if len(unbindablePorts) > 0 {
return fmt.Errorf("port(s): %v are required but unbindable", unbindablePorts)
}
return nil
}

type PreCheckNoConflictingContainerd struct {
common.KubeAction
}

func (t *PreCheckNoConflictingContainerd) Execute(runtime connector.Runtime) error {
containerdBin, err := util.GetCommand("containerd")
if err == nil && containerdBin != "" {
return fmt.Errorf("found existing containerd binary: %s, please uninstall containerd first to avoid conflicts", containerdBin)
}
containerdSocket := "/run/containerd/containerd.sock"
if util.IsExist(containerdSocket) {
return fmt.Errorf("detected existing containerd socket: %s, please uninstall containerd first to avoid conflicts", containerdSocket)
}
return nil
}

type CorrectHostname struct {
common.KubeAction
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/terminus/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ func (s *GetUserInfo) Execute(runtime connector.Runtime) error {
if err != nil {
return err
}
logger.Infof("using domain name: %s", s.KubeConf.Arg.User.DomainName)
logger.Infof("using Domain Name: %s", s.KubeConf.Arg.User.DomainName)
}
if len(s.KubeConf.Arg.User.UserName) == 0 {
s.KubeConf.Arg.User.UserName, err = s.getUserName()
if err != nil {
return err
}
logger.Infof("using user name: %s", s.KubeConf.Arg.User.UserName)
logger.Infof("using Olares Local Name: %s", s.KubeConf.Arg.User.UserName)
}
s.KubeConf.Arg.User.Email, err = s.getUserEmail()
if err != nil {
return err
}
logger.Infof("using email: %s", s.KubeConf.Arg.User.Email)
logger.Infof("using Olares ID: %s", s.KubeConf.Arg.User.Email)
s.KubeConf.Arg.User.Password, err = s.getUserPassword()
if err != nil {
return err
Expand Down

0 comments on commit ee3ab00

Please sign in to comment.