canonical / checkbox

Checkbox
https://checkbox.readthedocs.io
GNU General Public License v3.0
31 stars 45 forks source link

Can not get `$CHECKBOX_RUNTIME` if no `environ` #1101

Open LiaoU3 opened 4 months ago

LiaoU3 commented 4 months ago

Bug Description

Description

I found that $CHECKBOX_RUNTIME is having wierd behavior with the field environ and user in remote and local run, so I performed some experiment to check the outcome.

Note: I only observed this issue in the environment variable $CHECKBOX_RUNTIME , so it may not be the only one. But I could be sure that this issue does not happened on $PLAINBOX_SESSION_SHARE, I suspect it is because $CHECKBOX_RUNTIME is only visible by a root user.

Test Method

I test remote and local run indiviually, with or without environ and with or without user: root . To check if under the conditions below if a job could get $CHECKBOX_RUNTIME this variable.

Remote run

with 'environ' without 'environ'
user: root O O
regular user O X

Local run

with 'environ' without 'environ'
user: root O X
regular user O O

Conclusion

In remote run

According to this page in checkbox tutorial, environ should be optional. However, when it comes to $CHECKBOX_RUNTIME, it seems like this field becomes mandatory.

In local run

It is such a mess because a root user is not able to get $CHECKBOX_RUNTIME without environ provided.

My suspect

I suspect that $CHECKBOX_RUNTIME is only visible by root user. That's why we got the results in remote run. Nevertheless, in local run, I have completely no idea why this is happeneing.

Submission:

To Reproduce

  1. Clone the test jobs from my test-branch here.
  2. sideload the base provider
    • cp -r checkbox/providers/base /var/tmp/checkbox-providers
  3. Run checkbox
    • Try local: checkbox.checkbox-cli
    • Try remote: checkbox.checkbox-cli control 127.0.0.1
  4. Select this testplan
  5. Run it and review the result

Environment

Relevant log output

# local run
=========[ Running job 1 / 4. Estimated time left (at least): 0:00:00 ]=========
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-with-root-with-environ
Category: com.canonical.plainbox::uncategorised
... 8< -------------------------------------------------------------------------
CHECKBOX_RUNTIME: /snap/checkbox22/current
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/session_title-2024-03-22T10.23.19.session/session-share
------------------------------------------------------------------------- >8 ---
Outcome: job passed
=========[ Running job 2 / 4. Estimated time left (at least): 0:00:00 ]=========
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-with-root-without-environ
Category: com.canonical.plainbox::uncategorised
... 8< -------------------------------------------------------------------------
CHECKBOX_RUNTIME: 
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/session_title-2024-03-22T10.23.19.session/session-share
------------------------------------------------------------------------- >8 ---
Outcome: job passed
=========[ Running job 3 / 4. Estimated time left (at least): 0:00:00 ]=========
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-without-root-with-environ
Category: com.canonical.plainbox::uncategorised
... 8< -------------------------------------------------------------------------
CHECKBOX_RUNTIME: /snap/checkbox22/current
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/session_title-2024-03-22T10.23.19.session/session-share
------------------------------------------------------------------------- >8 ---
Outcome: job passed
=========[ Running job 4 / 4. Estimated time left (at least): 0:00:00 ]=========
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-without-root-without-environ
Category: com.canonical.plainbox::uncategorised
... 8< -------------------------------------------------------------------------
CHECKBOX_RUNTIME: /snap/checkbox22/current
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/session_title-2024-03-22T10.23.19.session/session-share
------------------------------------------------------------------------- >8 ---
Outcome: job passed

# Remote run
-----------------------------[ Running job 1 / 4 ]------------------------------
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-with-root-with-environ
Category: Uncategorised
--------------------------------------------------------------------------------
CHECKBOX_RUNTIME: /snap/checkbox22/current
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/remote-2024-03-22T10.24.33.session/session-share
--------------------------------------------------------------------------------
Outcome: job passed
-----------------------------[ Running job 2 / 4 ]------------------------------
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-with-root-without-environ
Category: Uncategorised
--------------------------------------------------------------------------------
CHECKBOX_RUNTIME: /snap/checkbox22/current
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/remote-2024-03-22T10.24.33.session/session-share
--------------------------------------------------------------------------------
Outcome: job passed
-----------------------------[ Running job 3 / 4 ]------------------------------
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-without-root-with-environ
Category: Uncategorised
--------------------------------------------------------------------------------
CHECKBOX_RUNTIME: /snap/checkbox22/current
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/remote-2024-03-22T10.24.33.session/session-share
--------------------------------------------------------------------------------
Outcome: job passed
-----------------------------[ Running job 4 / 4 ]------------------------------
---------------[ A job to print checkbox environment variables ]----------------
ID: com.canonical.certification::print-checkbox-env-without-root-without-environ
Category: Uncategorised
--------------------------------------------------------------------------------
CHECKBOX_RUNTIME: 
PLAINBOX_SESSION_SHARE: /var/tmp/checkbox-ng/sessions/remote-2024-03-22T10.24.33.session/session-share
--------------------------------------------------------------------------------
Outcome: job passed

Additional context

No response

syncronize-issues-to-jira[bot] commented 4 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CHECKBOX-1332.

This message was autogenerated

Hook25 commented 4 months ago

Upon initial analysis, this seems to be caused by plainbox.impl.execution.get_differential_execution_environment, if the user is switched all environment variables not explicitly set in the job env session or that don’t follow some arbitrary name are removed from the propagated environment. I don’t know why this is done, this needs more investigation.