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

Only warn when chcon fails #912

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 5 additions & 5 deletions pkg/cmd/server/kubernetes/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ func (c *NodeConfig) initializeVolumeDir(ce commandExecutor, path string) (strin
}

if _, err := os.Stat(rootDirectory); os.IsNotExist(err) {
if mkdirErr := os.MkdirAll(rootDirectory, 0750); mkdirErr != nil {
return "", fmt.Errorf("Couldn't create kubelet volume root directory '%s': %s", rootDirectory, mkdirErr)
if err := os.MkdirAll(rootDirectory, 0750); err != nil {
return "", fmt.Errorf("Couldn't create kubelet volume root directory '%s': %s", rootDirectory, err)
}
if chconPath, chconLookupErr := ce.LookPath("chcon"); chconLookupErr != nil {
glog.V(2).Infof("Couldn't locate 'chcon' to set the kubelet volume root directory context: %s", chconLookupErr)
if chconPath, err := ce.LookPath("chcon"); err != nil {
glog.V(2).Infof("Couldn't locate 'chcon' to set the kubelet volume root directory SELinux context: %s", err)
} else {
if err := ce.Run(chconPath, "-t", "svirt_sandbox_file_t", rootDirectory); err != nil {
return "", fmt.Errorf("Error running 'chcon' to set the kubelet volume root directory context: %s", err)
glog.Warning("Error running 'chcon' to set the kubelet volume root directory SELinux context: %s", err)
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/server/kubernetes/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ func TestInitializeVolumeDir(t *testing.T) {
if testCase.chconFound && !ce.runCalled {
t.Fatalf("%d: expected chcon run", i)
}
haveErr := err != nil
expectErr := testCase.chconRunErr != nil
if expectErr != haveErr {
t.Fatalf("%d: expected chcon run err: %t, got: %t, %s", i, expectErr, haveErr, err)
if err != nil {
t.Fatalf("%d: unexpected err: %s", i, err)
}
if !haveErr && path != nc.VolumeDir {
if path != nc.VolumeDir {
t.Fatalf("%d:, expected path(%s) == nc.VolumeDir(%s)", i, path, nc.VolumeDir)
}
} else {
Expand Down