Skip to content

Commit

Permalink
system_tests.py: Correctly handle case where no valid lxc command can…
Browse files Browse the repository at this point in the history
… be determined

Signed-off-by: Tobias Knöppler <[email protected]>
  • Loading branch information
theCalcaholic committed May 6, 2024
1 parent 6a93bb1 commit 9b66766
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build-lxd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ jobs:
env:
USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}"
run: |
LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" CI="$CI" ./build/build-LXD.sh
export CI
LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh
- name: Pack LXD image
id: pack-lxd
run: |
Expand Down Expand Up @@ -156,7 +157,8 @@ jobs:
# env:
# USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}"
# run: |
# LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" CI="$CI" ./build/build-LXD.sh
# export CI
# LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh
# - name: Pack LXD image
# id: pack-lxd
# run: |
Expand Down
17 changes: 11 additions & 6 deletions tests/system_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,19 @@ def set_cohorte_id(cohorte_id: int) -> CompletedProcess:
if lxc_test.returncode != 0:
raise Exception(f"failed to execute {lxc_command} info")
except:
lxc_test = run(['sudo'] + lxc_command + ['info'], stdout=PIPE, check='True')
lxc_command = ['sudo'] + lxc_command
try:
lxc_test = run(['sudo'] + lxc_command + ['info'], stdout=PIPE, check='True')
lxc_command = ['sudo'] + lxc_command
except:
lxc_command = None
lxc_running = False

# detect if we are running this in a LXC instance
try:
lxc_running = run(lxc_command + ['info', 'ncp'], stdout=PIPE, check = True)
except:
lxc_running = False
if lxc_command is not None:
try:
lxc_running = run(lxc_command + ['info', 'ncp'], stdout=PIPE, check = True)
except:
lxc_running = False

try:
systemd_container_running = run(['machinectl', 'show', 'ncp'], stdout=PIPE, check = True)
Expand Down

0 comments on commit 9b66766

Please sign in to comment.