Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add User=root to systemd, this will set the HOME=/root #349

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhangguanzhang
Copy link
Contributor

@zhangguanzhang zhangguanzhang commented Apr 11, 2024

It will help find the docker configuration file and pull the pause image that requires auth.

Fixes # #232

Proposed Changes

debug info

(dlv) c
> k8s.io/kubernetes/pkg/credentialprovider.ReadDockerConfigJSONFile() ./vendor/k8s.io/kubernetes/pkg/credentialprovider/config.go:138 (hits goroutine(677):1 total:1) (PC: 0x2285942)
   133:	// if searchPaths is empty, the default paths are used.
   134:	func ReadDockerConfigJSONFile(searchPaths []string) (cfg DockerConfig, err error) {
   135:		if len(searchPaths) == 0 {
   136:			searchPaths = DefaultDockerConfigJSONPaths()
   137:		}
=> 138:		for _, configPath := range searchPaths {
   139:			absDockerConfigFileLocation, err := filepath.Abs(filepath.Join(configPath, configJSONFileName))
   140:			if err != nil {
   141:				klog.Errorf("while trying to canonicalize %s: %v", configPath, err)
   142:				continue
   143:			}
(dlv) p searchPaths
[]string len: 4, cap: 4, [
	"",
	"",
	".docker",
	"/.docker",
]
(dlv) p homeJSONDirPath
".docker"
(dlv) call os.UserHomeDir()
> k8s.io/kubernetes/pkg/credentialprovider.ReadDockerConfigJSONFile() ./vendor/k8s.io/kubernetes/pkg/credentialprovider/config.go:138 (PC: 0x2285942)
Values returned:
	~r0: ""
	~r1: error(*errors.errorString) *{
		s: "$HOME is not defined",}

find there is no HOME onder systemd:

$ xargs -0 -n1 < /proc/$(pgrep cri-dockerd)/environ
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
NOTIFY_SOCKET=/run/systemd/notify
LISTEN_PID=5894
LISTEN_FDS=1

after set User=root will set HOME=/root

 xargs -0 -n1 < /proc/$(pgrep cri-dockerd)/environ
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
NOTIFY_SOCKET=/run/systemd/notify
LISTEN_PID=13491
LISTEN_FDS=1
HOME=/root  #<---------- here
LOGNAME=root
USER=root
SHELL=/bin/sh

@zhangguanzhang
Copy link
Contributor Author

@neersighted PTAL

@zhangguanzhang
Copy link
Contributor Author

@nwneisen PTAL

It will help find the docker configuration file and pull the pause image that requires certification.

Signed-off-by: zhangguanzhang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant