mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
Merge pull request #1197 from yinheli/yinheli/develop
fix sudo not work expected
This commit is contained in:
commit
0886e69e99
|
|
@ -19,6 +19,10 @@ package confirm
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/kubesphere/kubekey/pkg/common"
|
||||
"github.com/kubesphere/kubekey/pkg/core/action"
|
||||
"github.com/kubesphere/kubekey/pkg/core/connector"
|
||||
|
|
@ -28,9 +32,6 @@ import (
|
|||
"github.com/modood/table"
|
||||
"github.com/pkg/errors"
|
||||
versionutil "k8s.io/apimachinery/pkg/util/version"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PreCheckResults defines the items to be checked.
|
||||
|
|
@ -82,11 +83,23 @@ func (i *InstallationConfirm) Execute(runtime connector.Runtime) error {
|
|||
|
||||
if i.KubeConf.Arg.Artifact == "" {
|
||||
for _, host := range results {
|
||||
if host.Sudo == "" {
|
||||
fmt.Printf("%s: sudo is required. \n", host.Name)
|
||||
logger.Log.Errorf("%s: sudo is required. \n", host.Name)
|
||||
stopFlag = true
|
||||
}
|
||||
|
||||
if host.Conntrack == "" {
|
||||
fmt.Printf("%s: conntrack is required. \n", host.Name)
|
||||
logger.Log.Errorf("%s: conntrack is required. \n", host.Name)
|
||||
stopFlag = true
|
||||
}
|
||||
|
||||
if host.Socat == "" {
|
||||
fmt.Printf("%s: socat is required. \n", host.Name)
|
||||
logger.Log.Errorf("%s: socat is required. \n", host.Name)
|
||||
stopFlag = true
|
||||
}
|
||||
}
|
||||
|
||||
if stopFlag {
|
||||
|
|
|
|||
|
|
@ -18,15 +18,16 @@ package precheck
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/kubesphere/kubekey/pkg/common"
|
||||
"github.com/kubesphere/kubekey/pkg/core/connector"
|
||||
"github.com/kubesphere/kubekey/pkg/version/kubernetes"
|
||||
"github.com/kubesphere/kubekey/pkg/version/kubesphere"
|
||||
"github.com/pkg/errors"
|
||||
versionutil "k8s.io/apimachinery/pkg/util/version"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type NodePreCheck struct {
|
||||
|
|
@ -50,7 +51,14 @@ func (n *NodePreCheck) Execute(runtime connector.Runtime) error {
|
|||
cmd = fmt.Sprintf("which %s", software)
|
||||
}
|
||||
|
||||
res, err := runtime.GetRunner().SudoCmd(cmd, false)
|
||||
switch software {
|
||||
case sudo:
|
||||
// sudo skip sudo prefix
|
||||
default:
|
||||
cmd = connector.SudoPrefix(cmd)
|
||||
}
|
||||
|
||||
res, err := runtime.GetRunner().Cmd(cmd, false)
|
||||
switch software {
|
||||
case showmount:
|
||||
software = nfs
|
||||
|
|
@ -62,10 +70,13 @@ func (n *NodePreCheck) Execute(runtime connector.Runtime) error {
|
|||
if err != nil || strings.Contains(res, "not found") {
|
||||
results[software] = ""
|
||||
} else {
|
||||
if strings.HasPrefix(cmd, "which") {
|
||||
res = "y"
|
||||
// software in path
|
||||
if strings.Contains(res, "bin/") {
|
||||
results[software] = "y"
|
||||
} else {
|
||||
// get software version, e.g. docker, containerd, etc.
|
||||
results[software] = res
|
||||
}
|
||||
results[software] = res
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue