Comment 0 for bug 1298166

Revision history for this message
Daniel Manrique (roadmr) wrote :

I was looking at why when using canonical-certification-server, the environment variables aren't read from the /etc/xdg/*.conf files (in the environ section). I created a very simple job that just prints "env", to ensure that the environment is set in the simplest of cases.

Variables I set in the config file didn't show up in env output. Interestingly this happened both with canonical-certification-server and with plainbox run.

So I went looking at the difference between canonical-certification-server and checkbox sru, since I know this mechanism is working fine for SRU (and mini-ci).

I found that sru has a _run_single_job method that uses the applogic.run_job_if_possible method, to which it passes the config object:

        job_state, job_result = run_job_if_possible(
            self.session, self.runner, self.config, job)

Then, run_job_if_possible does pass the config object to the runner's run_job:
    if job_state.can_start():
        job_result = runner.run_job(job, config)

However, CliInvocation (from cli.py) has a _run_single_job_with_session method which encapsulates all the job running logic, and has this:

    if job_state.can_start():
        job_result = runner.run_job(job)

SO it's not passing the config object (which at this point is similarly available in self.config) and thus the settings, particularly the environment, are ignored.

Just to verify, I modified the call to this:
        job_result = runner.run_job(job)

In this case my dummy job did print the variables correctly (although they're not uppercased as they should be).

This appears to also be the case with "plainbox run", as plainbox/impl/commands/run.py has this:

            job_result = runner.run_job(job)

The code section where this is is nearly identical to the one from checkbox_ng cli.py.

Finally I found another instance of run_job() with no config passed in plainbox's analyze.py file.