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

issue 8649: host_pods should not be mandatory to node-agent #8774

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions changelogs/unreleased/8774-mpryc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
host_pods should not be mandatory to node-agent
14 changes: 11 additions & 3 deletions pkg/cmd/cli/nodeagent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
// files will be written to
defaultCredentialsDirectory = "/tmp/credentials"

defaultHostPodsPath = "/host_pods"

defaultResourceTimeout = 10 * time.Minute
defaultDataMoverPrepareTimeout = 30 * time.Minute
defaultDataPathConcurrentNum = 1
Expand Down Expand Up @@ -247,7 +249,13 @@
if err != nil {
return nil, err
}
if err := s.validatePodVolumesHostPath(s.kubeClient); err != nil {

exists, err := s.fileSystem.DirExists(defaultHostPodsPath)
if err != nil {
return nil, err
}

Check warning on line 256 in pkg/cmd/cli/nodeagent/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/cli/nodeagent/server.go#L253-L256

Added lines #L253 - L256 were not covered by tests

if exists && s.validatePodVolumesHostPath(s.kubeClient) != nil {

Check warning on line 258 in pkg/cmd/cli/nodeagent/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/cli/nodeagent/server.go#L258

Added line #L258 was not covered by tests
return nil, err
}

Expand Down Expand Up @@ -414,7 +422,7 @@
// validatePodVolumesHostPath validates that the pod volumes path contains a
// directory for each Pod running on this node
func (s *nodeAgentServer) validatePodVolumesHostPath(client kubernetes.Interface) error {
files, err := s.fileSystem.ReadDir("/host_pods/")
files, err := s.fileSystem.ReadDir(defaultHostPodsPath)
if err != nil {
return errors.Wrap(err, "could not read pod volumes host path")
}
Expand Down Expand Up @@ -446,7 +454,7 @@
valid = false
s.logger.WithFields(logrus.Fields{
"pod": fmt.Sprintf("%s/%s", pod.GetNamespace(), pod.GetName()),
"path": "/host_pods/" + dirName,
"path": defaultHostPodsPath + "/" + dirName,
}).Debug("could not find volumes for pod in host path")
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/nodeagent/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func Test_validatePodVolumesHostPath(t *testing.T) {
fs := testutil.NewFakeFileSystem()

for _, dir := range tt.dirs {
err := fs.MkdirAll(filepath.Join("/host_pods/", dir), os.ModePerm)
err := fs.MkdirAll(filepath.Join(defaultHostPodsPath, dir), os.ModePerm)
if err != nil {
t.Error(err)
}
Expand Down
Loading