Skip to content

Commit

Permalink
issue 8649: host_pods should not be mandatory to node-agent
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Pryc <[email protected]>
  • Loading branch information
mpryc committed Mar 10, 2025
1 parent 1516e72 commit 6585719
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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 @@ const (
// 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 @@ func newNodeAgentServer(logger logrus.FieldLogger, factory client.Factory, confi
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
}

if exists && s.validatePodVolumesHostPath(s.kubeClient) != nil {
return nil, err
}

Expand Down Expand Up @@ -414,7 +422,7 @@ func (s *nodeAgentServer) waitCacheForResume() error {
// 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 @@ func (s *nodeAgentServer) validatePodVolumesHostPath(client kubernetes.Interface
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

0 comments on commit 6585719

Please sign in to comment.