Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/kk/pkg/core/connector/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ func (c *connection) session() (*ssh.Session, error) {
}

if err := sess.Setenv("LANG", "en_US.UTF-8"); err != nil { // try make sure work with english language environments
return nil, err
logger.Log.Debugf("Failed to enforce LANG=en_US.UTF-8. (Error: %v)", err)
}

return sess, nil
}

Expand Down
9 changes: 8 additions & 1 deletion cmd/kk/pkg/filesystem/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package filesystem
import (
"fmt"
"os/exec"

"os"
"github.com/pkg/errors"

"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/action"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger"
)

type ChownFileAndDir struct {
Expand Down Expand Up @@ -64,6 +65,12 @@ type LocalTaskChown struct {

func (l *LocalTaskChown) Execute(runtime connector.Runtime) error {
if exist := util.IsExist(l.Path); exist {
// Check environment variables first
if os.Getenv("SUDO_UID") == "" || os.Getenv("SUDO_GID") == "" {
logger.Log.Infof("Skip chown for %s: SUDO_UID/GID missing (not using sudo)", l.Path)
return nil
}

if err := exec.Command("/bin/sh", "-c", fmt.Sprintf("chown -R ${SUDO_UID}:${SUDO_GID} %s", l.Path)).Run(); err != nil {
return errors.Wrapf(errors.WithStack(err), "chown %s failed", l.Path)
}
Expand Down