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

Add user defined labels to snapshot info #2175

Merged

Conversation

anmazzotti
Copy link
Contributor

Part of #2172

@anmazzotti anmazzotti force-pushed the add_user_defined_labels_to_snapshots branch 2 times, most recently from 75d1e86 to d8b2a8f Compare September 6, 2024 12:19
@anmazzotti anmazzotti self-assigned this Sep 6, 2024
@anmazzotti anmazzotti force-pushed the add_user_defined_labels_to_snapshots branch from d8b2a8f to fd434a9 Compare September 6, 2024 13:25
@anmazzotti
Copy link
Contributor Author

After install: elemental install --debug --snapshot-labels myLabel=foo,myOtherLabel=bar

# Autogenerated file by elemental client, do not edit

date: "2024-09-09T08:43:38Z"
snapshotter:
    type: btrfs
    max-snaps: 4
    config: {}
efi:
    label: COS_GRUB
oem:
    label: COS_OEM
persistent:
    label: COS_PERSISTENT
recovery:
    label: COS_RECOVERY
    recovery:
        source: dir:///run/rootfsbase
        fs: squashfs
        labels:
            myLabel: foo
            myOtherLabel: bar
        date: "2024-09-09T08:43:38Z"
        fromAction: install
state:
    label: COS_STATE
    snapshots:
        1:
            source: dir:///run/rootfsbase
            active: true
            labels:
                myLabel: foo
                myOtherLabel: bar
            date: "2024-09-09T08:43:38Z"
            fromAction: install

After upgrade: ELEMENTAL_UPGRADE_SNAPSHOT_LABELS="myLabel=bar,myOtherLabel=foo" elemental upgrade --debug --system oci://192.168.122.10:30000/elemental-os:dev-next

# Autogenerated file by elemental client, do not edit

date: "2024-09-09T08:45:57Z"
snapshotter:
    type: btrfs
    max-snaps: 4
    config: {}
efi:
    label: COS_GRUB
oem:
    label: COS_OEM
persistent:
    label: COS_PERSISTENT
recovery:
    label: COS_RECOVERY
    recovery:
        source: dir:///run/rootfsbase
        fs: squashfs
        labels:
            myLabel: foo
            myOtherLabel: bar
        date: "2024-09-09T08:43:38Z"
        fromAction: install
state:
    label: COS_STATE
    snapshots:
        1:
            source: dir:///run/rootfsbase
            labels:
                myLabel: foo
                myOtherLabel: bar
            date: "2024-09-09T08:43:38Z"
            fromAction: install
        2:
            source: oci://192.168.122.10:30000/elemental-os:dev-next
            digest: sha256:248b22b3dc24b730d1487df31c32fb527c40a95c74ea69c2d233d877a4e81d67
            active: true
            date: "2024-09-09T08:45:57Z"
            fromAction: upgrade

After upgrade+recovery: ELEMENTAL_UPGRADE_SNAPSHOT_LABELS="myLabel=bar,myOtherLabel=foo" elemental upgrade --debug --system oci://192.168.122.10:30000/elemental-os:dev-next --recovery

# Autogenerated file by elemental client, do not edit

date: "2024-09-09T08:50:48Z"
snapshotter:
    type: btrfs
    max-snaps: 4
    config: {}
efi:
    label: COS_GRUB
oem:
    label: COS_OEM
persistent:
    label: COS_PERSISTENT
recovery:
    label: COS_RECOVERY
    recovery:
        source: dir:///run/rootfsbase
        fs: squashfs
        date: "2024-09-09T08:50:48Z"
        fromAction: upgrade
state:
    label: COS_STATE
    snapshots:
        1:
            source: dir:///run/rootfsbase
            labels:
                myLabel: foo
                myOtherLabel: bar
            date: "2024-09-09T08:43:38Z"
            fromAction: install
        2:
            source: oci://192.168.122.10:30000/elemental-os:dev-next
            digest: sha256:248b22b3dc24b730d1487df31c32fb527c40a95c74ea69c2d233d877a4e81d67
            date: "2024-09-09T08:45:57Z"
            fromAction: upgrade
        3:
            source: oci://192.168.122.10:30000/elemental-os:dev-next
            digest: sha256:248b22b3dc24b730d1487df31c32fb527c40a95c74ea69c2d233d877a4e81d67
            active: true
            date: "2024-09-09T08:50:48Z"
            fromAction: upgrade

After upgrade recovery only: elemental upgrade-recovery --debug --snapshot-labels myLabel=foobar --recovery-system.uri oci://192.168.122.10:30000/elemental-os:dev-next

# Autogenerated file by elemental client, do not edit

date: "2024-09-09T08:54:49Z"
snapshotter:
    type: btrfs
    max-snaps: 4
    config: {}
efi:
    label: COS_GRUB
oem:
    label: COS_OEM
persistent:
    label: COS_PERSISTENT
recovery:
    label: COS_RECOVERY
    recovery:
        source: dir:///run/rootfsbase
        fs: squashfs
        labels:
            myLabel: foobar
        date: "2024-09-09T08:54:49Z"
        fromAction: upgrade-recovery
state:
    label: COS_STATE
    snapshots:
        1:
            source: dir:///run/rootfsbase
            labels:
                myLabel: foo
                myOtherLabel: bar
            date: "2024-09-09T08:43:38Z"
            fromAction: install
        2:
            source: oci://192.168.122.10:30000/elemental-os:dev-next
            digest: sha256:248b22b3dc24b730d1487df31c32fb527c40a95c74ea69c2d233d877a4e81d67
            date: "2024-09-09T08:45:57Z"
            fromAction: upgrade
        3:
            source: oci://192.168.122.10:30000/elemental-os:dev-next
            digest: sha256:248b22b3dc24b730d1487df31c32fb527c40a95c74ea69c2d233d877a4e81d67
            active: true
            date: "2024-09-09T08:50:48Z"
            fromAction: upgrade

After reset (from recovery partition): elemental reset --debug --snapshot-labels myLabel=foobar,myOtherLabel=barfoo

# Autogenerated file by elemental client, do not edit

date: "2024-09-09T08:56:44Z"
snapshotter:
    type: btrfs
    max-snaps: 4
    config: {}
oem:
    label: COS_OEM
persistent:
    label: COS_PERSISTENT
recovery:
    label: COS_RECOVERY
    recovery:
        source: dir:///run/rootfsbase
        fs: squashfs
        labels:
            myLabel: foobar
        date: "2024-09-09T08:54:49Z"
        fromAction: upgrade-recovery
state:
    label: COS_STATE
    snapshots:
        1:
            source: dir:///run/rootfsbase
            active: true
            labels:
                myLabel: foobar
                myOtherLabel: barfoo
            date: "2024-09-09T08:56:44Z"
            fromAction: reset

@anmazzotti anmazzotti force-pushed the add_user_defined_labels_to_snapshots branch from 455bc4d to 883c8d6 Compare September 9, 2024 09:11
@anmazzotti anmazzotti marked this pull request as ready for review September 9, 2024 09:11
@anmazzotti anmazzotti requested a review from a team as a code owner September 9, 2024 09:11
@anmazzotti
Copy link
Contributor Author

FYI the documentation regarding labels is missing, since the end-user is not going to be able to conveniently use them.
I'll add full documentation about labels with the elemental state feature.

@anmazzotti anmazzotti force-pushed the add_user_defined_labels_to_snapshots branch from 3e202aa to c80daa8 Compare September 9, 2024 12:43
@anmazzotti
Copy link
Contributor Author

Noticed a bit late the environment variables were always empty, that needed a custom decoder, it's better now:

ELEMENTAL_UPGRADE_SNAPSHOT_LABELS="myLabel=bar,myOtherLabel=foo" elemental upgrade --debug --system oci://192.168.122.10:30000/elemental-os:dev-next

# Autogenerated file by elemental client, do not edit

date: "2024-09-09T12:33:25Z"
snapshotter:
    type: btrfs
    max-snaps: 4
    config: {}
efi:
    label: COS_GRUB
oem:
    label: COS_OEM
persistent:
    label: COS_PERSISTENT
recovery:
    label: COS_RECOVERY
    recovery:
        source: dir:///run/rootfsbase
        fs: squashfs
        labels:
            myLabel: foo
            myOtherLabel: bar
        date: "2024-09-09T12:31:50Z"
        fromAction: install
state:
    label: COS_STATE
    snapshots:
        1:
            source: dir:///run/rootfsbase
            labels:
                myLabel: foo
                myOtherLabel: bar
            date: "2024-09-09T12:31:50Z"
            fromAction: install
        2:
            source: oci://192.168.122.10:30000/elemental-os:dev-next
            digest: sha256:11cb5c6f7b6b9e4daff67ec3ec7fa4a028c24445f2e4834a78e93c75d73eb5c3
            active: true
            labels:
                myLabel: bar
                myOtherLabel: foo
            date: "2024-09-09T12:33:25Z"
            fromAction: upgrade

@anmazzotti anmazzotti force-pushed the add_user_defined_labels_to_snapshots branch from c80daa8 to 7c18ecb Compare September 10, 2024 09:44
Copy link
Contributor

@frelon frelon left a comment

Choose a reason for hiding this comment

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

Just a small nit, looks good!

cmd/flags.go Outdated Show resolved Hide resolved
anmazzotti and others added 6 commits September 12, 2024 14:17
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
Co-authored-by: Fredrik Lönnegren <fredrik.lonnegren@gmail.com>
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
@anmazzotti anmazzotti force-pushed the add_user_defined_labels_to_snapshots branch from 3b1700a to 802c7a0 Compare September 12, 2024 12:17
@anmazzotti anmazzotti merged commit dc52491 into rancher:main Sep 12, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants