Skip to content

Conversation

@davepacheco
Copy link
Collaborator

Related to #542. Do this for GitHub Actions too.

I haven't tested this yet.

@davepacheco
Copy link
Collaborator Author

Commit 09405d6 seems to work at least somewhat. I deliberately injected a test failure that would leave a log file around. We have this output from the upload action:
https://github.com/oxidecomputer/omicron/runs/4611646344?check_suite_focus=true#step:11:12

The artifact is hidden at the bottom of this page:
https://github.com/oxidecomputer/omicron/actions/runs/1613043963#artifacts

And although it's the zip analog of a tarbomb, it seems to contain the log files:

$ unzip test_outputs.zip 
Archive:  test_outputs.zip
   creating: tmp/
   creating: tmp/omicron_tmp/
  inflating: tmp/omicron_tmp/omicron_nexus-a72b03e79ad2e227-test_organization.51446.1.log  
  inflating: tmp/omicron_tmp/omicron_nexus-ec57cffaa26cd73c-test_organization.32761.1.log  
$ find tmp -type f
tmp/omicron_tmp/omicron_nexus-ec57cffaa26cd73c-test_organization.32761.1.log
tmp/omicron_tmp/omicron_nexus-a72b03e79ad2e227-test_organization.51446.1.log
 $ head tmp/omicron_tmp/omicron_nexus-ec57cffaa26cd73c-test_organization.32761.1.log | bunyan
[2021-12-22T21:25:22.533599235+00:00]  INFO: test_organization/32761 on fv-az32-596: cockroach temporary directory: /tmp/omicron_tmp/.tmplZdnMs
[2021-12-22T21:25:22.533735136+00:00]  INFO: test_organization/32761 on fv-az32-596: cockroach: copying from seed directory (/tmp/omicron_tmp/crdb-base) to storage directory (/tmp/omicron_tmp/.tmplZdnMs/data)
...

It does not appear to have picked up the database files though.

@davepacheco
Copy link
Collaborator Author

Some weird things about this:

  • Based on the output of the job, I think I put retention-days in the wrong place and it may have interpreted that as a path. I'm not sure if that messed anything else up, but...
  • It claims to have found and uploaded only one file. But as we saw, the zip file contained two files. (The zip file itself is not the thing that was uploaded per their own docs.)
  • I thought I'd follow the advice in the output and enable step-by-step debugging. This involves creating a repository level secret, and it sounds from the docs like this would work retroactively, but it doesn't seem to.

My real question at this point is: was the cockroachdb directory actually there at this phase? We'll see if the step-by-step debug output shows up for the next run. If not, I'll add a dummy step to print out everything in $OMICRON_TMP.

Update: I tried this locally and the directory wasn't there. We seem to clean this up even on unsuccessful tests.

@davepacheco
Copy link
Collaborator Author

The latest change preserves the database directory when the CockroachInstance gets dropped without calling cleanup(). This seems to work, except that on a full test suite run, it seems to leak two database directories. I haven't tracked this down yet.

Besides that, I still want to verify that the artifacts generated for the latest build include what they should.

@davepacheco
Copy link
Collaborator Author

davepacheco commented Dec 23, 2021

The artifact from the latest change looks like what I'd expect:

dap@zathras tmp $ mv ../test_outputs.zip .
dap@zathras tmp $ unzip test_outputs.zip 
Archive:  test_outputs.zip
   creating: .tmpQ3ul9z/
  inflating: omicron_nexus-ec57cffaa26cd73c-test_organization.516.1.log  
  inflating: .tmpQ3ul9z/cockroachdb_stderr  
  inflating: .tmpQ3ul9z/cockroachdb_stdout  
   creating: .tmpQ3ul9z/data/
  inflating: .tmpQ3ul9z/listen-url   
  inflating: .tmpQ3ul9z/data/000011.log  
  inflating: .tmpQ3ul9z/data/000014.sst  
  inflating: .tmpQ3ul9z/data/000015.log  
   creating: .tmpQ3ul9z/data/cockroach-temp352904754/
   creating: .tmpQ3ul9z/data/cockroach-temp524844115/
  inflating: .tmpQ3ul9z/data/cockroach.advertise-addr  
  inflating: .tmpQ3ul9z/data/cockroach.advertise-sql-addr  
  inflating: .tmpQ3ul9z/data/cockroach.http-addr  
  inflating: .tmpQ3ul9z/data/cockroach.listen-addr  
  inflating: .tmpQ3ul9z/data/cockroach.sql-addr  
  inflating: .tmpQ3ul9z/data/CURRENT  
 extracting: .tmpQ3ul9z/data/LOCK    
   creating: .tmpQ3ul9z/data/logs/
  inflating: .tmpQ3ul9z/data/MANIFEST-000012  
  inflating: .tmpQ3ul9z/data/OPTIONS-000013  
  inflating: .tmpQ3ul9z/data/temp-dirs-record.txt  
 extracting: .tmpQ3ul9z/data/cockroach-temp352904754/000002.log  
  inflating: .tmpQ3ul9z/data/cockroach-temp352904754/CURRENT  
 extracting: .tmpQ3ul9z/data/cockroach-temp352904754/LOCK  
  inflating: .tmpQ3ul9z/data/cockroach-temp352904754/MANIFEST-000001  
  inflating: .tmpQ3ul9z/data/cockroach-temp352904754/OPTIONS-000003  
 extracting: .tmpQ3ul9z/data/cockroach-temp352904754/TEMP_DIR.LOCK  
 extracting: .tmpQ3ul9z/data/cockroach-temp524844115/000002.log  
  inflating: .tmpQ3ul9z/data/cockroach-temp524844115/CURRENT  
 extracting: .tmpQ3ul9z/data/cockroach-temp524844115/LOCK  
  inflating: .tmpQ3ul9z/data/cockroach-temp524844115/MANIFEST-000001  
  inflating: .tmpQ3ul9z/data/cockroach-temp524844115/OPTIONS-000003  
 extracting: .tmpQ3ul9z/data/cockroach-temp524844115/TEMP_DIR.LOCK  
  inflating: .tmpQ3ul9z/data/logs/cockroach-pebble.fv-az87-780.runner.2021-12-23T01_18_07Z.024085.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach-pebble.fv-az87-780.runner.2021-12-23T01_28_00Z.000566.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach-pebble.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach-stderr.fv-az87-780.runner.2021-12-23T01_18_07Z.024085.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach-stderr.fv-az87-780.runner.2021-12-23T01_28_00Z.000566.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach-stderr.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach.fv-az87-780.runner.2021-12-23T01_18_07Z.024085.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach.fv-az87-780.runner.2021-12-23T01_28_00Z.000566.log  
  inflating: .tmpQ3ul9z/data/logs/cockroach.log  
dap@zathras tmp $ ls -a
total 568
drwxr-xr-x   5 dap  staff     160 Dec 23 08:47 ./
drwx------@ 14 dap  staff     448 Dec 23 08:47 ../
drwxr-xr-x@  6 dap  staff     192 Dec 23 01:28 .tmpQ3ul9z/
-rw-r--r--@  1 dap  staff    6261 Dec 23 01:28 omicron_nexus-ec57cffaa26cd73c-test_organization.516.1.log
-rw-rw-rw-@  1 dap  staff  279004 Dec 23 08:47 test_outputs.zip
$ bunyan omicron_nexus-ec57cffaa26cd73c-test_organization.516.1.log 
[2021-12-23T01:27:59.368290556+00:00]  INFO: test_organization/516 on fv-az87-780: cockroach temporary directory: /tmp/omicron_tmp/.tmpQ3ul9z
[2021-12-23T01:27:59.368447256+00:00]  INFO: test_organization/516 on fv-az87-780: cockroach: copying from seed directory (/tmp/omicron_tmp/crdb-base) to storage directory (/tmp/omicron_tmp/.tmpQ3ul9z/data)
...
$ ls .tmpQ3ul9z
total 24
-rw-r--r--@  1 dap  staff  710 Dec 23 01:28 cockroachdb_stderr
-rw-r--r--@  1 dap  staff  757 Dec 23 01:28 cockroachdb_stdout
drwxr-xr-x@ 18 dap  staff  576 Dec 23 01:28 data/
-rw-r--r--@  1 dap  staff   50 Dec 23 01:28 listen-url

It also doesn't have any extra database directories.

@davepacheco
Copy link
Collaborator Author

davepacheco commented Dec 23, 2021

Here are the remaining things I'd like to do on this PR:

  • make sure this doesn't save anything on a clean run (verified locally on commit a76cfcb, which fixed the two leaked databases)
  • change the artifact name to include the OS so that the Mac and Linux ones don't stomp on each other
    • the runs on 8a9c27d have different artifacts
  • look (probably briefly) into why the Mac job fails to upload anything
    • the last Mac job failed to build because of what look like external errors with crates.io. Given that, the "artifact upload" step did what I'd expect.
    • the runs on 8a9c27d did upload what we expected
  • remove the injected test failure (done in 69b3671)
  • confirm with the latest run that we didn't save anything
  • remove the repository-level secret that I added for debugging

@davepacheco
Copy link
Collaborator Author

Verifying the artifacts from the run on 8a9c27d:

$ unzip failed_test_outputs_Linux.zip 
Archive:  failed_test_outputs_Linux.zip
   creating: .tmplbGAvo/
  inflating: omicron_nexus-ec57cffaa26cd73c-test_organization.371.1.log  
  inflating: .tmplbGAvo/cockroachdb_stderr  
  inflating: .tmplbGAvo/cockroachdb_stdout  
   creating: .tmplbGAvo/data/
  inflating: .tmplbGAvo/listen-url   
  inflating: .tmplbGAvo/data/000011.log  
  inflating: .tmplbGAvo/data/000014.sst  
  inflating: .tmplbGAvo/data/000015.log  
   creating: .tmplbGAvo/data/cockroach-temp648917603/
   creating: .tmplbGAvo/data/cockroach-temp988361915/
  inflating: .tmplbGAvo/data/cockroach.advertise-addr  
  inflating: .tmplbGAvo/data/cockroach.advertise-sql-addr  
  inflating: .tmplbGAvo/data/cockroach.http-addr  
  inflating: .tmplbGAvo/data/cockroach.listen-addr  
  inflating: .tmplbGAvo/data/cockroach.sql-addr  
  inflating: .tmplbGAvo/data/CURRENT  
 extracting: .tmplbGAvo/data/LOCK    
   creating: .tmplbGAvo/data/logs/
  inflating: .tmplbGAvo/data/MANIFEST-000012  
  inflating: .tmplbGAvo/data/OPTIONS-000013  
  inflating: .tmplbGAvo/data/temp-dirs-record.txt  
 extracting: .tmplbGAvo/data/cockroach-temp648917603/000002.log  
  inflating: .tmplbGAvo/data/cockroach-temp648917603/CURRENT  
 extracting: .tmplbGAvo/data/cockroach-temp648917603/LOCK  
  inflating: .tmplbGAvo/data/cockroach-temp648917603/MANIFEST-000001  
  inflating: .tmplbGAvo/data/cockroach-temp648917603/OPTIONS-000003  
 extracting: .tmplbGAvo/data/cockroach-temp648917603/TEMP_DIR.LOCK  
 extracting: .tmplbGAvo/data/cockroach-temp988361915/000002.log  
  inflating: .tmplbGAvo/data/cockroach-temp988361915/CURRENT  
 extracting: .tmplbGAvo/data/cockroach-temp988361915/LOCK  
  inflating: .tmplbGAvo/data/cockroach-temp988361915/MANIFEST-000001  
  inflating: .tmplbGAvo/data/cockroach-temp988361915/OPTIONS-000003  
 extracting: .tmplbGAvo/data/cockroach-temp988361915/TEMP_DIR.LOCK  
  inflating: .tmplbGAvo/data/logs/cockroach-pebble.fv-az32-596.runner.2021-12-23T17_10_09Z.023961.log  
  inflating: .tmplbGAvo/data/logs/cockroach-pebble.fv-az32-596.runner.2021-12-23T17_18_24Z.000425.log  
  inflating: .tmplbGAvo/data/logs/cockroach-pebble.log  
  inflating: .tmplbGAvo/data/logs/cockroach-stderr.fv-az32-596.runner.2021-12-23T17_10_09Z.023961.log  
  inflating: .tmplbGAvo/data/logs/cockroach-stderr.fv-az32-596.runner.2021-12-23T17_18_24Z.000425.log  
  inflating: .tmplbGAvo/data/logs/cockroach-stderr.log  
  inflating: .tmplbGAvo/data/logs/cockroach.fv-az32-596.runner.2021-12-23T17_10_09Z.023961.log  
  inflating: .tmplbGAvo/data/logs/cockroach.fv-az32-596.runner.2021-12-23T17_18_24Z.000425.log  
  inflating: .tmplbGAvo/data/logs/cockroach.log  
dap@zathras tmp $ head -3 omicron_nexus-ec57cffaa26cd73c-test_organization.371.1.log | bunyan
[2021-12-23T17:18:24.092401935+00:00]  INFO: test_organization/371 on fv-az32-596: cockroach temporary directory: /tmp/omicron_tmp/.tmplbGAvo
[2021-12-23T17:18:24.092653237+00:00]  INFO: test_organization/371 on fv-az32-596: cockroach: copying from seed directory (/tmp/omicron_tmp/crdb-base) to storage directory (/tmp/omicron_tmp/.tmplbGAvo/data)
[2021-12-23T17:18:24.111069922+00:00]  INFO: test_organization/371 on fv-az32-596: cockroach command line: cockroach start-single-node --insecure --http-addr=:0 --store /tmp/omicron_tmp/.tmplbGAvo/data --listen-addr 127.0.0.1:0 --listening-url-file /tmp/omicron_tmp/.tmplbGAvo/listen-url

(namely, we have one log file at the root, and it names the temporary directory, which is the only other thing contained at the root, and that directory appears to look like a complete cockroachdb data directory)

Similarly for the MacOS artifact:

dap@zathras tmp $ unzip failed_test_outputs_macOS.zip 
Archive:  failed_test_outputs_macOS.zip
   creating: .tmpbeBYLV/
  inflating: omicron_nexus-a72b03e79ad2e227-test_organization.4856.1.log  
  inflating: .tmpbeBYLV/cockroachdb_stderr  
  inflating: .tmpbeBYLV/cockroachdb_stdout  
   creating: .tmpbeBYLV/data/
  inflating: .tmpbeBYLV/listen-url   
  inflating: .tmpbeBYLV/data/000011.log  
  inflating: .tmpbeBYLV/data/000014.sst  
  inflating: .tmpbeBYLV/data/000015.log  
   creating: .tmpbeBYLV/data/cockroach-temp782544245/
   creating: .tmpbeBYLV/data/cockroach-temp789004622/
  inflating: .tmpbeBYLV/data/cockroach.advertise-addr  
  inflating: .tmpbeBYLV/data/cockroach.advertise-sql-addr  
  inflating: .tmpbeBYLV/data/cockroach.http-addr  
  inflating: .tmpbeBYLV/data/cockroach.listen-addr  
  inflating: .tmpbeBYLV/data/cockroach.sql-addr  
  inflating: .tmpbeBYLV/data/CURRENT  
 extracting: .tmpbeBYLV/data/LOCK    
   creating: .tmpbeBYLV/data/logs/
  inflating: .tmpbeBYLV/data/MANIFEST-000012  
  inflating: .tmpbeBYLV/data/OPTIONS-000013  
  inflating: .tmpbeBYLV/data/temp-dirs-record.txt  
 extracting: .tmpbeBYLV/data/cockroach-temp782544245/000002.log  
  inflating: .tmpbeBYLV/data/cockroach-temp782544245/CURRENT  
 extracting: .tmpbeBYLV/data/cockroach-temp782544245/LOCK  
  inflating: .tmpbeBYLV/data/cockroach-temp782544245/MANIFEST-000001  
  inflating: .tmpbeBYLV/data/cockroach-temp782544245/OPTIONS-000003  
 extracting: .tmpbeBYLV/data/cockroach-temp782544245/TEMP_DIR.LOCK  
 extracting: .tmpbeBYLV/data/cockroach-temp789004622/000002.log  
  inflating: .tmpbeBYLV/data/cockroach-temp789004622/CURRENT  
 extracting: .tmpbeBYLV/data/cockroach-temp789004622/LOCK  
  inflating: .tmpbeBYLV/data/cockroach-temp789004622/MANIFEST-000001  
  inflating: .tmpbeBYLV/data/cockroach-temp789004622/OPTIONS-000003  
 extracting: .tmpbeBYLV/data/cockroach-temp789004622/TEMP_DIR.LOCK  
  inflating: .tmpbeBYLV/data/logs/cockroach-pebble.log  
  inflating: .tmpbeBYLV/data/logs/cockroach-pebble.Mac-1640277476072.runner.2021-12-23T17_12_58Z.004350.log  
  inflating: .tmpbeBYLV/data/logs/cockroach-pebble.Mac-1640277476072.runner.2021-12-23T17_21_20Z.004947.log  
  inflating: .tmpbeBYLV/data/logs/cockroach-stderr.log  
  inflating: .tmpbeBYLV/data/logs/cockroach-stderr.Mac-1640277476072.runner.2021-12-23T17_12_58Z.004350.log  
  inflating: .tmpbeBYLV/data/logs/cockroach-stderr.Mac-1640277476072.runner.2021-12-23T17_21_20Z.004947.log  
  inflating: .tmpbeBYLV/data/logs/cockroach.log  
  inflating: .tmpbeBYLV/data/logs/cockroach.Mac-1640277476072.runner.2021-12-23T17_12_58Z.004350.log  
  inflating: .tmpbeBYLV/data/logs/cockroach.Mac-1640277476072.runner.2021-12-23T17_21_20Z.004947.log  
dap@zathras tmp $ head -n 3 omicron_nexus-a72b03e79ad2e227-test_organization.4856.1.log | bunyan
[2021-12-23T17:21:19.729695+00:00]  INFO: test_organization/4856 on Mac-1640277476072.local: cockroach temporary directory: /tmp/omicron_tmp/.tmpbeBYLV
[2021-12-23T17:21:19.733962+00:00]  INFO: test_organization/4856 on Mac-1640277476072.local: cockroach: copying from seed directory (/tmp/omicron_tmp/crdb-base) to storage directory (/tmp/omicron_tmp/.tmpbeBYLV/data)
[2021-12-23T17:21:19.746304+00:00]  INFO: test_organization/4856 on Mac-1640277476072.local: cockroach command line: cockroach start-single-node --insecure --http-addr=:0 --store /tmp/omicron_tmp/.tmpbeBYLV/data --listen-addr 127.0.0.1:0 --listening-url-file /tmp/omicron_tmp/.tmpbeBYLV/listen-url

#[tokio::test]
async fn test_organization() {
let logctx = dev::test_setup_log("test_database");
let logctx = dev::test_setup_log("test_organization");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unrelated typo in the log file name that I found while doing this.

#[allow(unused_must_use)]
if let Some(temp_dir) = self.temp_dir.take() {
temp_dir.close();
/*
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is mentioned in the PR comments: we now deliberately save the database directory if you don't explicitly clean it up after a successful test.

assert_eq!(rows.len(), 0);
client2.cleanup().await.expect("second connection closed ungracefully");

db1.cleanup().await.expect("failed to clean up first database");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These tests always should have been cleaning up the database instead of relying on the best-effort Drop impl. Now that the Drop impl doesn't clean these up any more, they were leaking the directory without this fix.

@davepacheco davepacheco marked this pull request as ready for review December 23, 2021 17:56
@davepacheco davepacheco requested a review from smklein December 23, 2021 17:56
@davepacheco davepacheco changed the title try to save test outputs from GitHub Actions save test outputs from GitHub Actions Dec 23, 2021
Copy link
Contributor

@andrewjstone andrewjstone left a comment

Choose a reason for hiding this comment

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

AFAICT, this should work :)

- name: Archive any failed test results
if: ${{ failure() }}
# actions/upload-artifact@v2.3.1
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why the sha rather than a version (which requires a comment) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure how well-founded it is, but following the advice in https://julienrenaux.fr/2019/12/20/github-actions-security-risk/.

@davepacheco davepacheco merged commit 5d78307 into main Dec 23, 2021
@davepacheco davepacheco deleted the github-save-test-outputs branch December 23, 2021 19:40
@davepacheco davepacheco changed the title save test outputs from GitHub Actions save test outputs from failed GitHub Actions Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants