tmt icon indicating copy to clipboard operation
tmt copied to clipboard

tmt clean last run of runs/guests doesn't work well with --workdir-root cli option

Open skycastlelily opened this issue 1 year ago • 3 comments

With current implement,tmt will remove last run of current workdir-root.But what  if users want to remove last run of another workdir-root? It seems that we could resolve it by creating sub-dirs of last-run,named with the workdir-root, instead of only create one general last-run. After all the merge requests for: https://github.com/teemtee/tmt/issues/2834 , are finished:)

skycastlelily avatar Apr 12 '24 10:04 skycastlelily

Looks like a duplicate of #2834. @skycastlelily, can you confirm? Or there anything specific here to be still covered?

psss avatar Sep 29 '25 09:09 psss

hmmm, #2834 is about having clean  guest support --workdir-root, while this issue is about supporting  last-run of  different workdir-root, following is how tmt works now:

(dev) lnie@192:~/tmt$ tmt run --workdir-root /var/tmp/we -vv --until provision plan --name plans/testcloud$
/var/tmp/we/run-004
    cmd: sudo -n true
....
    
        summary: 1 guest provisioned
(dev) lnie@192:~/tmt$ tmt clean guest -vv --workdir-root /var/tmp/tmt -l
clean
guests
workdir root: /var/tmp/tmt
    Stopping guests in run '/var/tmp/we/run-004' plan '/plans/testcloud'.
        cleanup
            summary: 0 tasks completed

though user wants to clean the guest  from  last run in  workdir-root /var/tmp/tmt,  the guest in /var/tmp/we workdir-root is cleaned.

That is what I was thinking when I reported back 1.5 years ago, now  I'm not sure it's a common use case.

However,  the following might be a common use case ,but tmt  does not support well 

 (dev) lnie@192:~/tmt$ tmt run --workdir-root /var/tmp/tmt --last execute/report 
/var/tmp/we/run-005
User does not have sudo access, we assume everything is pre-setup.
...
/plans/testcloud
    execute
        status: done
        summary: 1 test executed

total: 1 error

As you can see, though users want to report latest run in /var/tmp/tmt, but the latest run in /var/tmp/we is reported.

Both the issues could be covered by a same implement.

skycastlelily avatar Oct 28 '25 03:10 skycastlelily

The core issue is that the last-run is saved in the TMT_CONFIG_DIR which is shared between all workdir-root so the workdir-root is effectively a no-op in that case, or at least something that clashes between these. We need to investigate if we can move that symlink to the workdir-root instead, otherwise we should make the --last/--id conflict with the --workdir-root. In some cases like clean we need more explicit handling of this, since it can use either the info from workdir-root or --id/--last.

LecrisUT avatar Nov 19 '25 10:11 LecrisUT