Skip to content

Coexistence of pbench-agent and pbench-server #2456

Open
@dbutenhof

Description

@dbutenhof

@webbnh and I spent a a fun hour or so debugging a problem he'd encountered in his unit test container experiments where server commands were failing, unable to import pbench.cli.server.user_management (and etc.) modules. (This was actually the second of two "intriguing" issues we discovered.)

The problem turns out to be that he'd installed both pbench-agent and pbench-server. The agent install creates /etc/profile.d/pbench-agent.sh, which constructs for all system logins a PYTHONPATH to run agent commands.

Looking at python3 -m site we can see that these paths are added to the front of the sys.path search path.

The root of the problem appears to be that when we look for pbench.cli.server.user_management, the Python module is pbench ... it doesn't matter that a path under that level (the "sub-module") isn't found: the search stops there. So we're trying to resolve all import pbench.* statements out of the agent pbench module, which obviously doesn't work.

In this case we were able to correct the issue with unset PYTHONPATH so it would use the implicit pbench account sys.path, which correctly finds the files in his local /home/pbench git copy; the legacy unit tests now run correctly.

Now normally we don't expect the agent and server to be installed together, but sharing the same Python module name remains problematic in several odd cases. One is this "one [container] to rule them all" unit testing model, but another is our planned 0.69 passthrough ("PUT shim") server, which requires both a 0.69 server install and a 0.7x agent install, with "server" code able to successfully invoke agent commands (or, should we choose to go that way, agent Python modules directly).

Here's the kicker: that means we need to be able to construct a sys.path which will satisfy both... and this is currently impossible.

  1. A simple hack might be for put-shim to re-define PYTHONPATH to the agent configuration (perhaps by running /etc/profile.e/pbench-agent.sh) in the subprocess that invokes the agent command to push the tarball. This is a bit ugly, but might be good enough to get us through this unusual situation.
  2. A cleaner (but also ugly) solution would be to completely separate the module names, e.g., pbench_agent.cli.* vs pbench_server.cli.* so the installations become truly independent.
  3. A neater (but difficult to manage) solution would be to be able to merge the libraries; for example instead of installing into /opt/pbench-agent/lib and /opt/pbench-server/lib, put them in /opt/pbench (maybe reflecting the git tree, with /opt/pbench/lib, /opt/pbench/server, and /opt/pbench/agent), so they share a single global "pbench" module. (But there's where it gets complicated, since we're talking about different versions in general, so the agent pbench.common may not be the same bits as the server pbench.common.)

It'd be very satisfying to simply say "don't do that" ... but we have motivation to do this for our testing containers, and our product plans include doing this for end-of-life 0.69. So ... we so it seems that we need to stick our collective fingers in that wall outlet and figure out the best way to deal with the pain.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions