Skip to content

Add system-version to omdb db #10481

Open
emunn13 wants to merge 5 commits into
mainfrom
emunn/omdb-db-system-version
Open

Add system-version to omdb db #10481
emunn13 wants to merge 5 commits into
mainfrom
emunn/omdb-db-system-version

Conversation

@emunn13
Copy link
Copy Markdown

@emunn13 emunn13 commented May 22, 2026

Add system-version subcommand to omdb db to print the current system version and when this version update was requested.
Also add --all, to print all system versions and their requested dates.

Copy link
Copy Markdown
Contributor

@karencfv karencfv left a comment

Choose a reason for hiding this comment

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

This is great! Thanks for working on this command.

Comment thread dev-tools/omdb/src/bin/omdb/db.rs Outdated
Comment on lines +409 to +410
/// Print the current target system release and the update date (print all of the releases when `--all` is present)
SystemVersion(system_version::SystemVersionArgs),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not all components may be at the target release version at any given time. Having a "system-version" command could be confusing. It's probably more accurate to call it "target-release" :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks so much for the review, appreciate it :) I've changed it to target-release.

Comment thread dev-tools/omdb/src/bin/omdb/db.rs Outdated
Sleds(SledsArgs),
/// Show instances grouped by the sled they are running on
SledInstances(SledInstancesArgs),
/// Print the current target system release and the update date (print all of the releases when `--all` is present)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We typically don't mention command flags in the doc string.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you! Addressed in commit 1746781

@emunn13
Copy link
Copy Markdown
Author

emunn13 commented May 22, 2026

Tested the generated binary on dogfood:

omdb db target-release

root@oxz_switch0:/tmp# ./omdb-test db target-release
note: database URL not specified.  Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
WARN: found schema version 257.0.0, expected 261.0.0
It's possible the database is running a version that's different from what this
tool understands.  This may result in errors or incorrect output.
 SYSTEM_VERSION              TIME_REQUESTED
 20.0.0-0.ci+git8ca64d81e70  2026-05-15T19:02:14.696Z

omdb db target-release --all

root@oxz_switch0:/tmp# ./omdb-test db target-release --all
note: database URL not specified.  Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
WARN: found schema version 257.0.0, expected 261.0.0
It's possible the database is running a version that's different from what this
tool understands.  This may result in errors or incorrect output.
 SYSTEM_VERSION              TIME_REQUESTED
 20.0.0-0.ci+git8ca64d81e70  2026-05-15T19:02:14.696Z
 19.4.0-0.ci+gitbae719a3bdb  2026-05-13T15:11:13.005Z
 19.3.0-0.ci+gitd4a126e8cc3  2026-05-05T23:45:46.284Z
 19.2.0-0.ci+gite4b75dde134  2026-04-21T23:11:22.248Z
 19.1.0-0.ci+gitc7312331b08  2026-04-14T21:02:48.258Z
 19.1.0-0.ci+gitbc696216ef5  2026-04-13T23:24:19.034Z
 19.1.0-0.ci+git073b1306678  2026-04-11T03:25:49.438Z
 19.0.0-0.ci+git42726ecbb1b  2026-04-08T00:25:34.431Z
 19.0.0-0.ci+gitefa6443bdeb  2026-04-07T22:17:32.562Z
 19.0.0-0.ci+git19d83513171  2026-04-05T04:32:40.595Z
 19.0.0-0.ci+gitd41bfa5af31  2026-04-03T04:54:04.617Z
 19.0.0-0.ci+git09c8c584ee4  2026-03-31T22:43:14.138Z
 19.0.0-0.ci+gite2fe4014825  2026-03-30T19:40:42.138Z
 19.0.0-0.ci+git10b9f2fb872  2026-03-17T20:03:56.652Z
 19.0.0-0.ci+git6409f6a4bd2  2026-03-12T22:15:37.278Z
 19.0.0-0.ci+git9dd23096de9  2026-03-06T17:53:51.816Z
 19.0.0-0.ci+git328ba48fdf8  2026-03-03T16:17:40.390Z
 19.0.0-0.ci+git1d6977056c6  2026-02-25T21:19:42.918Z
 19.0.0-0.ci+gitd3ef1db023b  2026-02-23T20:11:11.484Z
 18.1.0-0.ci+git550f05cd523  2026-02-19T22:01:07.520Z
 18.1.0-0.ci+git1003e128ad7  2026-02-19T03:50:33.288Z
 18.0.0-0.ci+gitd211c40e1e5  2026-02-19T03:44:48.239Z
 18.0.0-0.ci+git4a456c99797  2026-02-14T05:50:48.190Z
 18.0.0-0.ci+gitcfc181ba02d  2026-02-13T19:05:06.745Z
 18.0.0-0.ci+git56926cd1982  2026-02-12T20:57:17.714Z
 18.0.0-0.ci+git0ee7d730282  2026-02-11T17:36:22.522Z
 18.0.0-0.ci+gita728a7f63fa  2026-02-11T03:51:16.313Z
 18.0.0-0.ci+gitc643ed39da8  2026-02-10T13:49:51.601Z
 18.0.0-0.ci+git6d17d64ce6d  2026-02-09T23:15:31.775Z
 18.0.0-0.ci+git687f721a7c9  2026-02-09T21:52:51.151Z
 18.0.0-0.ci+git4b3cdb4e30b  2026-02-06T03:54:34.703Z
 18.0.0-0.ci+git360801b804e  2026-02-05T12:46:26.621Z
 18.0.0-0.ci+git52e04b3b26e  2026-02-03T11:39:03.606Z
 18.0.0-0.ci+git5292c0d21f9  2026-02-03T04:04:06.323Z
 18.0.0-0.ci+git17cf00dbf0a  2026-01-31T18:43:00.741Z
 18.0.0-0.ci+git1c0f2b3c24c  2026-01-28T21:11:01.168Z
 18.0.0-0.ci+git92e0ae0c98d  2026-01-27T04:58:08.255Z
 18.0.0-0.ci+git5eb13372380  2026-01-24T22:42:41.788Z
 18.0.0-0.ci+git5eb13372380  2026-01-24T18:34:49.860Z
 18.0.0-0.ci+git5eb13372380  2026-01-22T00:31:36.716Z
 18.0.0-0.ci+git4175bf66d6c  2026-01-18T22:36:09.037Z
 18.0.0-0.ci+gitf507a3057c7  2026-01-14T23:32:11.568Z
 18.0.0-0.ci+git8ae817f7284  2026-01-08T19:37:04.637Z
 18.0.0-0.ci+git3b3f937d05f  2026-01-01T00:52:08.783Z
 18.0.0-0.ci+gitc298def0b9f  2025-12-24T16:27:48.945Z
 18.0.0-0.ci+git99c3f3ef97f  2025-12-13T01:01:20.744Z
 18.0.0-0.ci+git474c1588c05  2025-12-12T20:50:16.012Z
 18.0.0-0.ci+git078382f5d9c  2025-12-08T23:28:55.326Z
 18.0.0-0.ci+git6601b8ec8a4  2025-12-02T01:55:46.374Z
 17.0.0-0.ci+git01bb8750d9c  2025-11-11T05:13:20.575Z
 17.0.0-0.ci+git27b3ef9b9d0  2025-11-07T00:30:58.541Z
 17.0.0-0.ci+gitf83a43dbb42  2025-11-05T23:19:16.749Z
 17.0.0-0.ci+gite980820e5b5  2025-11-04T23:19:00.573Z
 17.0.0-0.ci+git81d822614e1  2025-11-04T22:18:06.948Z
 17.0.0-0.ci+git495eab19cfc  2025-11-01T00:01:17.962Z
 17.0.0-0.ci+gitcf97c145a6e  2025-10-30T05:32:40.451Z
 17.0.0-0.ci+gitc5c0834b174  2025-10-30T00:45:03.409Z
 17.0.0-0.ci+git56225535f8e  2025-10-29T19:46:33.164Z
 17.0.0-0.ci+git6510e87da6a  2025-10-27T20:50:15.701Z
 17.0.0-0.ci+git7bc5275729c  2025-10-24T18:02:19.767Z
 17.0.0-0.ci+gitaf3b89ffce6  2025-10-23T06:09:22.810Z
 17.0.0-0.ci+git3a90a985264  2025-10-22T23:59:21.609Z
 17.0.0-0.ci+git2a1d8548932  2025-10-22T18:07:59.734Z
 17.0.0-0.ci+git34818139bb2  2025-10-21T22:40:59.317Z
 17.0.0-0.ci+git27a65080e1b  2025-10-19T00:32:07.040Z
 17.0.0-0.ci+gita3bf7ea02ce  2025-10-18T03:29:05.318Z
 17.0.0-0.ci+gitd17fb154c39  2025-10-17T16:06:06.951Z
 17.0.0-0.ci+git529ba64ee28  2025-10-10T21:20:54.455Z
 17.0.0-0.ci+git8c683c74af9  2025-10-10T16:10:29.091Z
 17.0.0-0.ci+git76ec1fa523c  2025-10-09T16:21:21.378Z
 17.0.0-0.ci+git063828b53e7  2025-10-09T16:07:34.772Z
 17.0.0-0.ci+gitb8efb9a08b3  2025-10-08T20:38:25.697Z
 17.0.0-0.ci+git178c3c1ae84  2025-10-08T20:00:04.115Z
 <unspecified>               2025-03-08T04:05:05.028Z

@emunn13
Copy link
Copy Markdown
Author

emunn13 commented May 22, 2026

Tested latest commit (dd347a4) on dogfood. Newest record at the bottom.

omdb db target-release --all

root@oxz_switch0:/tmp# ./omdb-em-test db target-release --all
note: database URL not specified.  Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
WARN: found schema version 257.0.0, expected 261.0.0
It's possible the database is running a version that's different from what this
tool understands.  This may result in errors or incorrect output.
 SYSTEM_VERSION              TIME_REQUESTED
 <unspecified>               2025-03-08T04:05:05.028Z
 17.0.0-0.ci+git178c3c1ae84  2025-10-08T20:00:04.115Z
 17.0.0-0.ci+gitb8efb9a08b3  2025-10-08T20:38:25.697Z
 17.0.0-0.ci+git063828b53e7  2025-10-09T16:07:34.772Z
 17.0.0-0.ci+git76ec1fa523c  2025-10-09T16:21:21.378Z
 17.0.0-0.ci+git8c683c74af9  2025-10-10T16:10:29.091Z
 17.0.0-0.ci+git529ba64ee28  2025-10-10T21:20:54.455Z
 17.0.0-0.ci+gitd17fb154c39  2025-10-17T16:06:06.951Z
 17.0.0-0.ci+gita3bf7ea02ce  2025-10-18T03:29:05.318Z
 17.0.0-0.ci+git27a65080e1b  2025-10-19T00:32:07.040Z
 17.0.0-0.ci+git34818139bb2  2025-10-21T22:40:59.317Z
 17.0.0-0.ci+git2a1d8548932  2025-10-22T18:07:59.734Z
 17.0.0-0.ci+git3a90a985264  2025-10-22T23:59:21.609Z
 17.0.0-0.ci+gitaf3b89ffce6  2025-10-23T06:09:22.810Z
 17.0.0-0.ci+git7bc5275729c  2025-10-24T18:02:19.767Z
 17.0.0-0.ci+git6510e87da6a  2025-10-27T20:50:15.701Z
 17.0.0-0.ci+git56225535f8e  2025-10-29T19:46:33.164Z
 17.0.0-0.ci+gitc5c0834b174  2025-10-30T00:45:03.409Z
 17.0.0-0.ci+gitcf97c145a6e  2025-10-30T05:32:40.451Z
 17.0.0-0.ci+git495eab19cfc  2025-11-01T00:01:17.962Z
 17.0.0-0.ci+git81d822614e1  2025-11-04T22:18:06.948Z
 17.0.0-0.ci+gite980820e5b5  2025-11-04T23:19:00.573Z
 17.0.0-0.ci+gitf83a43dbb42  2025-11-05T23:19:16.749Z
 17.0.0-0.ci+git27b3ef9b9d0  2025-11-07T00:30:58.541Z
 17.0.0-0.ci+git01bb8750d9c  2025-11-11T05:13:20.575Z
 18.0.0-0.ci+git6601b8ec8a4  2025-12-02T01:55:46.374Z
 18.0.0-0.ci+git078382f5d9c  2025-12-08T23:28:55.326Z
 18.0.0-0.ci+git474c1588c05  2025-12-12T20:50:16.012Z
 18.0.0-0.ci+git99c3f3ef97f  2025-12-13T01:01:20.744Z
 18.0.0-0.ci+gitc298def0b9f  2025-12-24T16:27:48.945Z
 18.0.0-0.ci+git3b3f937d05f  2026-01-01T00:52:08.783Z
 18.0.0-0.ci+git8ae817f7284  2026-01-08T19:37:04.637Z
 18.0.0-0.ci+gitf507a3057c7  2026-01-14T23:32:11.568Z
 18.0.0-0.ci+git4175bf66d6c  2026-01-18T22:36:09.037Z
 18.0.0-0.ci+git5eb13372380  2026-01-22T00:31:36.716Z
 18.0.0-0.ci+git5eb13372380  2026-01-24T18:34:49.860Z
 18.0.0-0.ci+git5eb13372380  2026-01-24T22:42:41.788Z
 18.0.0-0.ci+git92e0ae0c98d  2026-01-27T04:58:08.255Z
 18.0.0-0.ci+git1c0f2b3c24c  2026-01-28T21:11:01.168Z
 18.0.0-0.ci+git17cf00dbf0a  2026-01-31T18:43:00.741Z
 18.0.0-0.ci+git5292c0d21f9  2026-02-03T04:04:06.323Z
 18.0.0-0.ci+git52e04b3b26e  2026-02-03T11:39:03.606Z
 18.0.0-0.ci+git360801b804e  2026-02-05T12:46:26.621Z
 18.0.0-0.ci+git4b3cdb4e30b  2026-02-06T03:54:34.703Z
 18.0.0-0.ci+git687f721a7c9  2026-02-09T21:52:51.151Z
 18.0.0-0.ci+git6d17d64ce6d  2026-02-09T23:15:31.775Z
 18.0.0-0.ci+gitc643ed39da8  2026-02-10T13:49:51.601Z
 18.0.0-0.ci+gita728a7f63fa  2026-02-11T03:51:16.313Z
 18.0.0-0.ci+git0ee7d730282  2026-02-11T17:36:22.522Z
 18.0.0-0.ci+git56926cd1982  2026-02-12T20:57:17.714Z
 18.0.0-0.ci+gitcfc181ba02d  2026-02-13T19:05:06.745Z
 18.0.0-0.ci+git4a456c99797  2026-02-14T05:50:48.190Z
 18.0.0-0.ci+gitd211c40e1e5  2026-02-19T03:44:48.239Z
 18.1.0-0.ci+git1003e128ad7  2026-02-19T03:50:33.288Z
 18.1.0-0.ci+git550f05cd523  2026-02-19T22:01:07.520Z
 19.0.0-0.ci+gitd3ef1db023b  2026-02-23T20:11:11.484Z
 19.0.0-0.ci+git1d6977056c6  2026-02-25T21:19:42.918Z
 19.0.0-0.ci+git328ba48fdf8  2026-03-03T16:17:40.390Z
 19.0.0-0.ci+git9dd23096de9  2026-03-06T17:53:51.816Z
 19.0.0-0.ci+git6409f6a4bd2  2026-03-12T22:15:37.278Z
 19.0.0-0.ci+git10b9f2fb872  2026-03-17T20:03:56.652Z
 19.0.0-0.ci+gite2fe4014825  2026-03-30T19:40:42.138Z
 19.0.0-0.ci+git09c8c584ee4  2026-03-31T22:43:14.138Z
 19.0.0-0.ci+gitd41bfa5af31  2026-04-03T04:54:04.617Z
 19.0.0-0.ci+git19d83513171  2026-04-05T04:32:40.595Z
 19.0.0-0.ci+gitefa6443bdeb  2026-04-07T22:17:32.562Z
 19.0.0-0.ci+git42726ecbb1b  2026-04-08T00:25:34.431Z
 19.1.0-0.ci+git073b1306678  2026-04-11T03:25:49.438Z
 19.1.0-0.ci+gitbc696216ef5  2026-04-13T23:24:19.034Z
 19.1.0-0.ci+gitc7312331b08  2026-04-14T21:02:48.258Z
 19.2.0-0.ci+gite4b75dde134  2026-04-21T23:11:22.248Z
 19.3.0-0.ci+gitd4a126e8cc3  2026-05-05T23:45:46.284Z
 19.4.0-0.ci+gitbae719a3bdb  2026-05-13T15:11:13.005Z
 20.0.0-0.ci+git8ca64d81e70  2026-05-15T19:02:14.696Z

omdb db target-release

root@oxz_switch0:/tmp# ./omdb-em-test db target-release
note: database URL not specified.  Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
WARN: found schema version 257.0.0, expected 261.0.0
It's possible the database is running a version that's different from what this
tool understands.  This may result in errors or incorrect output.
 SYSTEM_VERSION              TIME_REQUESTED
 20.0.0-0.ci+git8ca64d81e70  2026-05-15T19:02:14.696Z

@emunn13 emunn13 marked this pull request as ready for review May 22, 2026 22:18
@emunn13 emunn13 requested review from jgallagher and karencfv May 22, 2026 22:18
Copy link
Copy Markdown
Contributor

@karencfv karencfv left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comment! I took a closer look and have some questions. Thanks again for adding this command!

Comment on lines +7 to +8
//! Shows the current target release and date when update was requested.
//! When `--all` option is used, lists all target release records.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Taking a closer look, we may want to change the functionality of the command a bit. Right now we only have two options right? All or one. What if the user wants to see just the latest 5?

In this scenario, it's probably a simpler user experience to have a command that always shows a list of target releases with a limit of records shown. Something like omdb target-release list or omdb target-releases with an optional fetch-limit or --limit flag. This way a user can say I want to see the latest one, or the last 10, or 100 or whatever.

We already have this implemented for several endpoints (DbFetchOptions), see cmd_db_blueprints, cmd_db_physical_disks etc. If DbFetchOptions doesn't make sense for this command, you can also look at how cmd_reconfigurator_config_history implements a --limit flag.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We already have a --fetch-limit flag on omdb db that applies to any subcommand that respects it (which this one does AFAICT, but it would be good to test / confirm).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I re-added the DbFetchOptions to respect this.

root@oxz_switch0:/tmp# ./omdb-em db --fetch-limit 8 target-release --all
note: database URL not specified.  Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
WARN: found schema version 257.0.0, expected 261.0.0
It's possible the database is running a version that's different from what this
tool understands.  This may result in errors or incorrect output.
WARN: listing target releases: found 8 items (the limit).  There may be more items that were ignored.  Consider overriding with --fetch-limit.
 TARGET_RELEASE              TIME_REQUESTED
 19.0.0-0.ci+git42726ecbb1b  2026-04-08T00:25:34.431Z
 19.1.0-0.ci+git073b1306678  2026-04-11T03:25:49.438Z
 19.1.0-0.ci+gitbc696216ef5  2026-04-13T23:24:19.034Z
 19.1.0-0.ci+gitc7312331b08  2026-04-14T21:02:48.258Z
 19.2.0-0.ci+gite4b75dde134  2026-04-21T23:11:22.248Z
 19.3.0-0.ci+gitd4a126e8cc3  2026-05-05T23:45:46.284Z
 19.4.0-0.ci+gitbae719a3bdb  2026-05-13T15:11:13.005Z
 20.0.0-0.ci+git8ca64d81e70  2026-05-15T19:02:14.696Z

.release_source()
.context("interpreting target release source")?
{
TargetReleaseSource::Unspecified => "<unspecified>".to_string(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unspecified means no target release has been set yet, is it useful to have this as part of the list or target releases?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is printing rows from the db - what would you do instead of printing a sentinel like this? Neither skipping nor failing seems great to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was thinking of skipping, but yeah, it would be useful to know when there have been unspecified target releases


#[derive(Debug, Args, Clone)]
pub(super) struct TargetReleaseArgs {
/// List of target releases sorted from oldest to newest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking at the sample, isn't it the other way around?


let mut rows = Vec::with_capacity(releases.len());
for release in releases {
let system_version = match release
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: we are adding unspecified here too, so the variable isn't really system_version, but rather target_release.

Comment thread dev-tools/omdb/src/bin/omdb/db/target_release.rs
Copy link
Copy Markdown
Contributor

@jgallagher jgallagher left a comment

Choose a reason for hiding this comment

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

+1 to Karen's comments about stale comments and switching everything over to "target release". Everything else LGTM - thanks!

Copy link
Copy Markdown
Contributor

@karencfv karencfv left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! There are a couple of things we may want to think about. With the current implementation if we run omdb db target-release --help which should only return a single row we get the following information

$ ./target/debug/omdb db target-release --help
Print the current target release and the update date

Usage: omdb db target-release [OPTIONS]

Options:
      --all                    List the most recent target releases, sorted from oldest to newest
      --log-level <LOG_LEVEL>  log level filter [env: LOG_LEVEL=] [default: warn]
      --color <COLOR>          Color output [default: auto] [possible values: auto, always, never]
  -h, --help                   Print help

Connection Options:
      --db-url <DB_URL>          URL of the database SQL interface [env: OMDB_DB_URL=]
      --dns-server <DNS_SERVER>  [env: OMDB_DNS_SERVER=]

Database Options:
      --fetch-limit <FETCH_LIMIT>  limit to apply to queries that fetch rows [env: OMDB_FETCH_LIMIT=] [default: 500]
      --include-deleted            whether to include soft-deleted records when enumerating objects that can be soft-deleted

...

As you can see this includes --fetch-limit which feels a little strange since you're only expecting a single entry. We only really want the --fetch-limit when we're returning many rows with the --all flag.

Another thing to think about, is that you can set the fetch limit via an environment variable OMDB_FETCH_LIMIT. omdb sets this to 500 automatically, so technically we're never really returning "all" which might catch some people off-guard if they're using a flag called "--all".

To not make this command extremely complex we could simplify it by just having a single omdb db target-releases or omdb db target-release list command that lists all the target releases up to the maximum amount set by --fetch-limit.

This way, if you only want the latest target release you can do

$ omdb db target-releases --fetch-limit 1

If you want all of them you can set a bogus amount

$ omdb db target-releases --fetch-limit 100000000000000

If you want a subset

$ omdb db target-releases --fetch-limit 5

If you want as many rows as the default fetch limit has

$ omdb db target-releases 

What do you think?


#[derive(Debug, Args, Clone)]
pub(super) struct TargetReleaseArgs {
/// List the most recent target releases, sorted from oldest to newest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's newest to oldest?

args: &TargetReleaseArgs,
) -> Result<(), anyhow::Error> {
let releases = if args.all {
let limit = fetch_opts.fetch_limit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

&DbFetchOptions also has an --include-deleted flag. We should probably handle that no? I don't think we soft delete target releases. We can either just print out a warning about that if someone uses that flag, or return an error saying that flag is invalid here.

I would probably lean towards returning an error in case someone wishes to parse the output of this command.

.release_source()
.context("interpreting target release source")?
{
TargetReleaseSource::Unspecified => "<unspecified>".to_string(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was thinking of skipping, but yeah, it would be useful to know when there have been unspecified target releases

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.

4 participants