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

rpm-ostree status –json and –booted do not work as expected together #2829

Closed
rugk opened this issue May 16, 2021 · 2 comments · Fixed by #4090
Closed

rpm-ostree status –json and –booted do not work as expected together #2829

rugk opened this issue May 16, 2021 · 2 comments · Fixed by #4090

Comments

@rugk
Copy link

rugk commented May 16, 2021

Host system details Fedora CoreOS 34.20210427.2.1

Provide the output of rpm-ostree status:

$ rpm-ostree status 
State: idle
AutomaticUpdatesDriver: Zincati
  DriverState: active; periodically polling for updates (last checked Sun 2021-05-16 21:07:38 UTC)
Deployments:
● ostree://fedora:fedora/x86_64/coreos/testing
                   Version: 34.20210427.2.1 (2021-05-12T22:58:03Z)
                BaseCommit: 518844c87b53985419e751481f379a0d808cd4693d93113150d06d9679f66103
              GPGSignature: Valid signature by 8C5BA6990BDB26E19F2A1A801161AE6945719A39
           LayeredPackages: nano

  ostree://fedora:fedora/x86_64/coreos/testing
                   Version: 34.20210427.2.1 (2021-05-12T22:58:03Z)
                BaseCommit: 518844c87b53985419e751481f379a0d808cd4693d93113150d06d9679f66103
              GPGSignature: Valid signature by 8C5BA6990BDB26E19F2A1A801161AE6945719A39
           LayeredPackages: nano

Expected vs actual behavior

rpm-ostree status --booted works as expected:

$ rpm-ostree status --booted
State: idle
AutomaticUpdatesDriver: Zincati
  DriverState: active; periodically polling for updates (last checked Sun 2021-05-16 21:07:38 UTC)
BootedDeployment:
● ostree://fedora:fedora/x86_64/coreos/testing
                   Version: 34.20210427.2.1 (2021-05-12T22:58:03Z)
                BaseCommit: 518844c87b53985419e751481f379a0d808cd4693d93113150d06d9679f66103
              GPGSignature: Valid signature by 8C5BA6990BDB26E19F2A1A801161AE6945719A39
           LayeredPackages: nano

However, when I add --json I get a totally different output, i.e. also the not-booted status:

$ $ rpm-ostree status --booted --json
{
  "deployments" : [
    {
      "unlocked" : "none",
      "base-commit-meta" : {
        "coreos-assembler.config-gitrev" : "1cc333f1b36d2f06165741b8b0865aebb4dfdd0d",
        "coreos-assembler.config-dirty" : "false",
        "rpmostree.inputhash" : "00fe23ffde9e959683a7ccf578af8ef684317e49c0488f20b39dabd73c214077",
        "coreos-assembler.basearch" : "x86_64",
        "fedora-coreos.stream" : "testing",
        "version" : "34.20210427.2.1",
        "rpmostree.initramfs-args" : [
          "--add=ignition",
          "--no-hostonly",
          "--omit=nfs",
          "--omit=lvm",
          "--omit=iscsi"
        ],
        "rpmostree.rpmmd-repos" : [
          {
            "id" : "fedora-coreos-pool",
            "timestamp" : -8044945848213176320
          }
        ]
      },
      "requested-local-packages" : [],
      "base-removals" : [],
      "gpg-enabled" : true,
      "pinned" : false,
      "osname" : "fedora-coreos",
      "origin" : "fedora:fedora/x86_64/coreos/testing",
      "requested-base-local-replacements" : [],
      "checksum" : "df60db90c753b4c767fb41e4d2a36d9b34cc96d62e42a5e2cd90016f57bdf52a",
      "regenerate-initramfs" : false,
      "id" : "fedora-coreos-df60db90c753b4c767fb41e4d2a36d9b34cc96d62e42a5e2cd90016f57bdf52a.0",
      "version" : "34.20210427.2.1",
      "base-version" : "34.20210427.2.1",
      "base-checksum" : "518844c87b53985419e751481f379a0d808cd4693d93113150d06d9679f66103",
      "signatures" : [
        [
          true,
          false,
          false,
          false,
          false,
          "8C5BA6990BDB26E19F2A1A801161AE6945719A39",
          1620860478,
          0,
          "RSA",
          "SHA256",
          "Fedora",
          "fedora-34-primary@fedoraproject.org",
          "8C5BA6990BDB26E19F2A1A801161AE6945719A39",
          0,
          0
        ]
      ],
      "requested-packages" : [
        "nano"
      ],
      "base-timestamp" : 1620860283,
      "serial" : 0,
      "timestamp" : 1621192644,
      "booted" : true,
      "layered-commit-meta" : {
        "rpmostree.clientlayer" : true,
        "rpmostree.removed-base-packages" : [],
        "version" : "34.20210427.2.1",
        "rpmostree.packages" : [
          "nano"
        ],
        "rpmostree.clientlayer_version" : 4,
        "rpmostree.replaced-base-packages" : [],
        "rpmostree.state-sha512" : "dd0ec984d22f34fbb317740a3e0d538c206652db03d9486c8ff3583528cb26d11bdb424edb361e6be2233f6c8bea5e82489686f9f5be2ab6dbcc2fda96e2da0f",
        "rpmostree.rpmmd-repos" : []
      },
      "packages" : [
        "nano"
      ],
      "base-local-replacements" : [],
      "requested-base-removals" : [],
      "initramfs-etc" : []
    },
    {
      "unlocked" : "none",
      "base-commit-meta" : {
        "coreos-assembler.config-gitrev" : "1cc333f1b36d2f06165741b8b0865aebb4dfdd0d",
        "coreos-assembler.config-dirty" : "false",
        "rpmostree.inputhash" : "00fe23ffde9e959683a7ccf578af8ef684317e49c0488f20b39dabd73c214077",
        "coreos-assembler.basearch" : "x86_64",
        "fedora-coreos.stream" : "testing",
        "version" : "34.20210427.2.1",
        "rpmostree.initramfs-args" : [
          "--add=ignition",
          "--no-hostonly",
          "--omit=nfs",
          "--omit=lvm",
          "--omit=iscsi"
        ],
        "rpmostree.rpmmd-repos" : [
          {
            "id" : "fedora-coreos-pool",
            "timestamp" : -8044945848213176320
          }
        ]
      },
      "requested-local-packages" : [],
      "base-removals" : [],
      "gpg-enabled" : true,
      "pinned" : false,
      "osname" : "fedora-coreos",
      "origin" : "fedora:fedora/x86_64/coreos/testing",
      "requested-base-local-replacements" : [],
      "checksum" : "eb8d3e95353b2177ddc7215ac8fa48fe770a9f3456af138c324431bc69218033",
      "regenerate-initramfs" : false,
      "id" : "fedora-coreos-eb8d3e95353b2177ddc7215ac8fa48fe770a9f3456af138c324431bc69218033.0",
      "version" : "34.20210427.2.1",
      "base-version" : "34.20210427.2.1",
      "base-checksum" : "518844c87b53985419e751481f379a0d808cd4693d93113150d06d9679f66103",
      "signatures" : [
        [
          true,
          false,
          false,
          false,
          false,
          "8C5BA6990BDB26E19F2A1A801161AE6945719A39",
          1620860478,
          0,
          "RSA",
          "SHA256",
          "Fedora",
          "fedora-34-primary@fedoraproject.org",
          "8C5BA6990BDB26E19F2A1A801161AE6945719A39",
          0,
          0
        ]
      ],
      "requested-packages" : [
        "nano"
      ],
      "base-timestamp" : 1620860283,
      "serial" : 0,
      "timestamp" : 1621192323,
      "booted" : false,
      "layered-commit-meta" : {
        "rpmostree.clientlayer" : true,
        "rpmostree.removed-base-packages" : [],
        "version" : "34.20210427.2.1",
        "rpmostree.packages" : [
          "nano"
        ],
        "rpmostree.clientlayer_version" : 4,
        "rpmostree.replaced-base-packages" : [],
        "rpmostree.state-sha512" : "dd0ec984d22f34fbb317740a3e0d538c206652db03d9486c8ff3583528cb26d11bdb424edb361e6be2233f6c8bea5e82489686f9f5be2ab6dbcc2fda96e2da0f",
        "rpmostree.rpmmd-repos" : []
      },
      "packages" : [
        "nano"
      ],
      "base-local-replacements" : [],
      "requested-base-removals" : [],
      "initramfs-etc" : []
    }
  ],
  "transaction" : null,
  "cached-update" : null,
  "update-driver" : {
    "driver-name" : "Zincati",
    "driver-sd-unit" : "zincati.service"
  }

Expected:

Only the booted deployment should be shown/included in the --json output.

This is unexpected, because the help page does not mention the two options are exclusive/”incompatible”:

$ rpm-ostree status --help
Usage:
  rpm-ostree status [OPTION…]

Get the version of the booted system

Help Options:
  -h, --help                    Show help options

Application Options:
  -v, --verbose                 Print additional fields (e.g. StateRoot); implies -a
  -a, --advisories              Expand advisories listing
  --json                        Output JSON
  -J, --jsonpath=EXPRESSION     Filter JSONPath expression
  -b, --booted                  Only print the booted deployment
  --pending-exit-77             If pending deployment available, exit 77
  --sysroot=SYSROOT             Use system root SYSROOT (default: /)
  --peer                        Force a peer-to-peer connection instead of using the system message bus
  --version                     Print version information and exit

And there is also no error as when you e.g. try this:

$ rpm-ostree status --booted --json --jsonpath=".deployments"
error: Cannot specify both --json and --jsonpath

Steps to reproduce it

see above

Would you like to work on the issue?
rather not, unless it's doc-only

@jlebon
Copy link
Member

jlebon commented May 17, 2021

I suppose.

Right now, when you use --json, it's more of a "bypass everything and just dump all the state in JSON" type of switch. We don't really curate the JSON output much. Wouldn't be opposed to a patch though which trims the deployments array to just the booted one when --booted is provided.

@rugk
Copy link
Author

rugk commented May 17, 2021

Yeah, I guess it depends on how you want to “API”-design your CLI. Another idea would be to have a rpm-ostree status-json command, if it is really supposed to bypass all other switches.

Otherwise, if it’s the same command, you should expect stupid users like me to just combine the flags and expect them to work. If they don’t work together, show an error, at least. (As you do with --json and --jsonpath, that is good, as explained.)

cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Oct 13, 2022
Unfortunately the implement involves some ugly grubbing through
GVariant...really need to port this stuff to Rust.

Closes: coreos#2829
cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Oct 13, 2022
Unfortunately the implement involves some ugly grubbing through
GVariant...really need to port this stuff to Rust.

Closes: coreos#2829
cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Oct 15, 2022
Unfortunately the implement involves some ugly grubbing through
GVariant...really need to port this stuff to Rust.

Closes: coreos#2829
cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Oct 15, 2022
Unfortunately the implement involves some ugly grubbing through
GVariant...really need to port this stuff to Rust.

Closes: coreos#2829
cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Oct 21, 2022
Unfortunately the implement involves some ugly grubbing through
GVariant...really need to port this stuff to Rust.

Closes: coreos#2829
cgwalters added a commit to cgwalters/rpm-ostree that referenced this issue Oct 22, 2022
Unfortunately the implement involves some ugly grubbing through
GVariant...really need to port this stuff to Rust.

Closes: coreos#2829
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 a pull request may close this issue.

2 participants