Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
S slapos.core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 23
    • Merge requests 23
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • slapos.core
  • Merge requests
  • !373

Merged
Created Mar 31, 2022 by Xavier Thompson@xavier_thompsonOwner

slapgrid: Fix promise logging with instance python

  • Overview 14
  • Commits 3
  • Changes 2

In runpromise.py stderr outputs are redirected on stdout to reserve stderr for propagating error messages back to the parent process. However it turns out preexec_fn can log on stderr before this redirection is set up.

This can cause either unexpected warnings to appear in the logs (when the promises all succeed) or pollute the error message when a promise fails.

An example of such a warning:

[2022-03-29 16:52:42,933] INFO     Checking slappartXX promises...
[2022-03-29 16:52:42,934] INFO     Switching to slappartXX's python at /YYYY/python2.7/bin/python2.7
[2022-03-29 16:52:42,941] DEBUG    Succesfully dropped privileges to uid=965 gid=1038
...
[2022-03-29 16:52:47,620] WARNING  Promise runner unexpected output:
2022-03-29 16:52:42 slapos[15963] DEBUG Succesfully dropped privileges to uid=965 gid=1038

In this case this is caused by dropPrivileges issuing a logger.debug() call, and since dropPrivileges is executed as inside the child process with preexec_fn, the logger ends up writing to the child process's stderr before it is redirected to stdout.

To fix this issue, preexec_fn is modified to do the same redirection and then revert it. Reverting it avoids the need to communicate the new file descriptor for the original stderr stream to runpromise.py, which seems very hard do to from inside preexec_fn.

Edited Mar 31, 2022 by Xavier Thompson
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: fix_promise_logging_again
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7