Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the rhts-report-result alias for reporting beakerlib subresults #3372

Merged
merged 7 commits into from
Dec 10, 2024

Conversation

seberm
Copy link
Collaborator

@seberm seberm commented Nov 20, 2024

I was troubleshooting why the logs for beakerlib phases (aka tmt subresults) are not saved by tmt-report-result script and the reason is the following.

The beakerlib calls the command in BEAKERLIB_COMMAND_REPORT_RESULT variable in the following way:

$BEAKERLIB_COMMAND_REPORT_RESULT "$testname" "$result" "$logfile" "$score"

See the implementation of rlReport here:

Suppose we use tmt-report-result as the value for BEAKERLIB_COMMAND_REPORT_RESULT (as a script name). In that case, the script will not be compatible with the third $logfile positional argument - it will just ignore it because it accepts the logfile provided only by the -o/--outputFile option by default.

We want to use the rhts-report-result alias because of a compatibility layer implemented by the tmt-report-result script itself. If the script gets called with rhts-report-result name, it will accept the third positional argument as a logfile:

Related to:

Pull Request Checklist

  • implement the feature
  • extend the test coverage

@seberm seberm added step | execute Stuff related to the execute step area | results Related to how tmt stores and shares results ci | full test Pull request is ready for the full test execution labels Nov 20, 2024
@seberm seberm added this to the 1.40 milestone Nov 20, 2024
@seberm seberm marked this pull request as ready for review November 20, 2024 15:13
tmt/frameworks/beakerlib.py Outdated Show resolved Hide resolved
@seberm seberm requested a review from happz November 20, 2024 16:01
@seberm seberm force-pushed the feature/use-rhts-report-result-in-rlreport branch from 0f0f860 to aa236b4 Compare November 22, 2024 20:39
@seberm seberm force-pushed the feature/use-rhts-report-result-in-rlreport branch from aa236b4 to d91cd76 Compare December 2, 2024 08:42
@seberm
Copy link
Collaborator Author

seberm commented Dec 2, 2024

/packit test

@seberm seberm force-pushed the feature/use-rhts-report-result-in-rlreport branch from d91cd76 to 1d1a817 Compare December 5, 2024 13:29
Copy link
Collaborator

@martinhoyer martinhoyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know much about rhts stuff, but lgtm.

Copy link
Collaborator

@skycastlelily skycastlelily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM:)

@psss psss changed the title Use rhts-report-result alias instead of tmt-report-result for reporting beakerlib subresults Use the rhts-report-result alias for reporting beakerlib subresults Dec 6, 2024
Copy link
Collaborator

@psss psss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@psss psss force-pushed the feature/use-rhts-report-result-in-rlreport branch from c584153 to 0a2b30e Compare December 6, 2024 13:37
@psss psss added the status | ready for merge The only missing piece is to do the rebase the current 'main' and let the CI finish. label Dec 6, 2024
@psss psss self-assigned this Dec 6, 2024
@psss
Copy link
Collaborator

psss commented Dec 6, 2024

Seems that /tests/provision/become fails after the change. The problem is that guest pull is not able to fetch the newly created logs:

rsync: [sender] send_files failed to open "/var/tmp/tmt/run-001/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/Cleanup_tmp.3KTaRskP64": Permission denied (13)
rsync: [sender] send_files failed to open "/var/tmp/tmt/run-001/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/Setup_tmp.7HHUBr6cCD": Permission denied (13)
rsync: [sender] send_files failed to open "/var/tmp/tmt/run-001/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/Test_tmp.vkwk0eUY8N": Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1852) [generator=3.3.0]

Easy steps to reproduce locally:

cd tests/provision/become/data
tmt --context provisiontest=virtual run -rvvv plan --name /umask

@seberm seberm force-pushed the feature/use-rhts-report-result-in-rlreport branch from 0a2b30e to 2fe50b8 Compare December 7, 2024 21:35
@psss psss force-pushed the feature/use-rhts-report-result-in-rlreport branch from 2fe50b8 to cc93761 Compare December 8, 2024 19:30
@psss psss removed the status | ready for merge The only missing piece is to do the rebase the current 'main' and let the CI finish. label Dec 9, 2024
@seberm
Copy link
Collaborator Author

seberm commented Dec 9, 2024

Seems that /tests/provision/become fails after the change. The problem is that guest pull is not able to fetch the newly created logs:

rsync: [sender] send_files failed to open "/var/tmp/tmt/run-001/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/Cleanup_tmp.3KTaRskP64": Permission denied (13)
rsync: [sender] send_files failed to open "/var/tmp/tmt/run-001/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/Setup_tmp.7HHUBr6cCD": Permission denied (13)
rsync: [sender] send_files failed to open "/var/tmp/tmt/run-001/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/Test_tmp.vkwk0eUY8N": Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1852) [generator=3.3.0]

Easy steps to reproduce locally:

cd tests/provision/become/data
tmt --context provisiontest=virtual run -rvvv plan --name /umask

Hello @psss @happz ,

So, if I understand this correctly, the tmt together with guest.pull() (the rsync) is running under the fedora user and that's why the rsync cannot read phase logs (they are readable only by root user):

[fedora@default-0 data]$ pwd
/var/tmp/tmt/run-054/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data
[fedora@default-0 data]$ ls -alh
total 20K
drwxr-xr-x+ 1 fedora fedora  190 Dec  9 11:56 .
drwxr-xr-x+ 1 fedora fedora  376 Dec  9 11:29 ..
-rw-------. 1 root   root    482 Dec  9 11:29 Cleanup_tmp.0xUJHxkmKJ
-rw-r--r--. 1 root   root   2.7K Dec  9 11:30 journal.xml
-rw-------. 1 root   root    580 Dec  9 11:29 Setup_tmp.LRb5CQS4dv
-rw-------. 1 root   root    472 Dec  9 11:29 Test_tmp.lRXdeF2tWd
-rw-r--r--. 1 root   root    383 Dec  9 11:29 tmt-report-results.yaml

The strange thing is that files created by tmt are always owned by fedora:fedora but files created by beakerlib (e.g. journal.xml, TestResults, ...) are owned by root:root. Is this expected? All these beakerlib files are readable by group and others, except the phase logs.

It seems like the ACLs are not applied when the tmt-report-result script uses cp -f "$outputFile" "${TMT_TEST_DATA}/${fileprefix}_${filename}" to copy phase log to TMT_TEST_DATA directory. What do you think?

[root@default-0 ]# getfacl /var/tmp/tmt/run-054/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data
getfacl: Removing leading '/' from absolute path names
# file: var/tmp/tmt/run-054/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data
# owner: fedora
# group: fedora
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::r-x
default:other::r-x

I tried to reproduce it like the following:

[root@default-0 tmp]# pwd
/tmp
[root@default-0 tmp]# touch mytest
[root@default-0 tmp]# chmod 600 mytest
[root@default-0 tmp]# ls -alh mytest
-rw-------. 1 root root 0 Dec  9 12:20 mytest
[root@default-0 tmp]# cp mytest /var/tmp/tmt/run-054/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/
[root@default-0 tmp]# ls -alh /var/tmp/tmt/run-054/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/mytest
-rw-------. 1 root root 0 Dec  9 12:20 /var/tmp/tmt/run-054/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data/mytest

Edit:
After setting chmod 0600 to all files in /var/tmp/tmt/run-054/umask/execute/data/guest/default-0/Beakerlib-test-to-generate-report-files-on-guest-1/data, the virtual test completed without permission errors:

[root@default-0 data]# chmod 644 ./*
[root@default-0 data]# ls -alh
total 20K
drwxr-xr-x+ 1 fedora fedora  190 Dec  9 12:27 .
drwxr-xr-x+ 1 fedora fedora  376 Dec  9 11:29 ..
-rw-r--r--. 1 root   root    482 Dec  9 11:29 Cleanup_tmp.0xUJHxkmKJ
-rw-r--r--. 1 root   root   2.7K Dec  9 11:30 journal.xml
-rw-r--r--. 1 root   root    580 Dec  9 11:29 Setup_tmp.LRb5CQS4dv
-rw-r--r--. 1 root   root    472 Dec  9 11:29 Test_tmp.lRXdeF2tWd
-rw-r--r--. 1 root   root    383 Dec  9 11:29 tmt-report-results.yaml

@seberm seberm added the status | need help Extra attention is needed label Dec 9, 2024
@psss
Copy link
Collaborator

psss commented Dec 9, 2024

I believe that f157ae7 should fix the problem.

@psss psss force-pushed the feature/use-rhts-report-result-in-rlreport branch from f157ae7 to d4d1694 Compare December 9, 2024 19:05
@psss
Copy link
Collaborator

psss commented Dec 9, 2024

Trying with a less intrusive approach proposed by @happz: d4d1694.

@psss psss added status | ready for merge The only missing piece is to do the rebase the current 'main' and let the CI finish. and removed status | need help Extra attention is needed labels Dec 9, 2024
@psss
Copy link
Collaborator

psss commented Dec 10, 2024

/packit test --id provision

2 similar comments
@psss
Copy link
Collaborator

psss commented Dec 10, 2024

/packit test --id provision

@psss
Copy link
Collaborator

psss commented Dec 10, 2024

/packit test --id provision

@psss
Copy link
Collaborator

psss commented Dec 10, 2024

Important tests passed in at least one of the recent provision jobs, merging.

@psss psss merged commit 789b604 into main Dec 10, 2024
18 of 20 checks passed
@psss psss deleted the feature/use-rhts-report-result-in-rlreport branch December 10, 2024 12:28
@seberm
Copy link
Collaborator Author

seberm commented Dec 10, 2024

@happz @psss Thanks for helping me finish this up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area | results Related to how tmt stores and shares results ci | full test Pull request is ready for the full test execution status | ready for merge The only missing piece is to do the rebase the current 'main' and let the CI finish. step | execute Stuff related to the execute step
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants