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

fcos/v1_6_exp: warn if config attempts to reuse partition by label #436

Merged
merged 1 commit into from
May 11, 2023

Conversation

Adam0Brien
Copy link
Member

@Adam0Brien Adam0Brien commented Mar 9, 2023

Fix : #377

@Adam0Brien Adam0Brien self-assigned this Mar 9, 2023
Copy link
Contributor

@bgilbert bgilbert 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 working on this!

config/fcos/v1_5_exp/translate.go Outdated Show resolved Hide resolved
config/fcos/v1_5_exp/translate.go Outdated Show resolved Hide resolved
config/fcos/v1_5_exp/translate.go Outdated Show resolved Hide resolved
config/fcos/v1_5_exp/translate.go Outdated Show resolved Hide resolved
@prestist prestist self-requested a review March 10, 2023 01:47
@bgilbert
Copy link
Contributor

FYI, #434 will land first, so you'll eventually have to rebase this onto fcos/v1_6_exp.

@Adam0Brien Adam0Brien force-pushed the p-tables-tests branch 2 times, most recently from e561669 to 66a46d6 Compare March 10, 2023 12:31
@Adam0Brien Adam0Brien marked this pull request as draft March 10, 2023 12:31
@Adam0Brien
Copy link
Member Author

Marking this as a Draft PR as i'm not too familiar with butane yet.

@Adam0Brien Adam0Brien force-pushed the p-tables-tests branch 3 times, most recently from c4bb164 to 0834659 Compare March 10, 2023 15:08
@Adam0Brien Adam0Brien marked this pull request as ready for review March 13, 2023 16:36
@Adam0Brien
Copy link
Member Author

Test is working fine now : fails when a partition has the number 0 and wipe_tables is set to false

@bgilbert
Copy link
Contributor

Have you manually tested with the config from #377?

@Adam0Brien
Copy link
Member Author

I haven't only the test that is in translate_test.go and i'm not entirely sure how i would go about testing manually

@bgilbert
Copy link
Contributor

You should be able to just run Butane and pass it the config, and see whether it outputs the warning.

@Adam0Brien
Copy link
Member Author

this is the output i got :

adamobrien@fedora:~/coreos/coreos-butane/butane(p-tables-tests⚡) » butane config.yaml 2 ↵
{"ignition":{"version":"3.3.0"},"storage":{"disks":[{"device":"/dev/sdb","partitions":[{"label":"foo"}],"wipeTable":false}]}}

looks okay

@bgilbert
Copy link
Contributor

There's no warning there.

@Adam0Brien
Copy link
Member Author

There's not supposed to be a warning is there?

@bgilbert
Copy link
Contributor

wipeTable is set to false and there's a partition with number 0, so yes.

@Adam0Brien
Copy link
Member Author

my bad i thought there shouldn't be one taking a look now!

@Adam0Brien
Copy link
Member Author

Adam0Brien commented Mar 14, 2023

okay so after running this config on a local build

version: 1.4.0
storage:
  disks:
    - device: /dev/sdb
      wipe_table: false
      partitions:
        - label: foo
        - number: 1

generates a .ign fine

but if i was to change the number from 1 -> 0 then i get the following error
error at $.storage.disks.0.partitions.1, line 9 col 11: a partition number >= 1 or a label must be specified Error translating config: config generated was invalid

@bgilbert
Copy link
Contributor

You're declaring two separate partitions but I think you're intending to declare one. You'll probably want to drop the - from the last line.

@Adam0Brien
Copy link
Member Author

my bad didn't know that made a new partition. tested it without the - and i didn't get an error...

config.yaml Outdated Show resolved Hide resolved
@Adam0Brien
Copy link
Member Author

Adam0Brien commented Mar 15, 2023

At the moment if i use this config butane will return the error message "Partition number cannot be zero.% "
works as intended but id love some feedback

version: 1.5.0-experimental
storage:
  disks:
    - device: /dev/sdb
      wipe_table: false
      partitions:
        - label: foo```

Copy link
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

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

The PR title and commit message still need details.

docs/release-notes.md Outdated Show resolved Hide resolved
docs/release-notes.md Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate_test.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
config/common/errors.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate_test.go Show resolved Hide resolved
@Adam0Brien Adam0Brien changed the title fcos/v1_6_exp: Add warning for invalid partition configurations Add warning for invalid partition configuration when reprovisioning with non-root disks Apr 21, 2023
Copy link
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

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

Tests are failing.

config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate_test.go Show resolved Hide resolved
docs/release-notes.md Outdated Show resolved Hide resolved
config/common/errors.go Outdated Show resolved Hide resolved
@bgilbert
Copy link
Contributor

For the commit message, I wrote this text:

fcos/v1_6_exp: warn if config attempts to reuse partition by label

Ignition matches existing partitions by number, not by label.  When
reusing an existing partition table, if the config specifies a label
and leaves the number at the default of 0, Ignition will try to add a
new partition rather than reusing any existing one.  That was probably
not the user's intention, so warn in this case.

However, the boot disk is a common exception, since it has a fresh
partition table on every run.  On FCOS we can detect the alias
/dev/disk/by-id/coreos-boot-disk and not warn, but that alias was added
recently and older configs won't use it.  On other variants we don't
have any way to detect the boot disk.  Therefore, don't implement the
warning in base and don't make it retroactive to existing stable specs;
only add it to the FCOS experimental spec.

Suggestions/edits welcome.

@Adam0Brien Adam0Brien force-pushed the p-tables-tests branch 6 times, most recently from 82ba4e8 to 7ec5e1f Compare April 21, 2023 20:40
@bgilbert bgilbert changed the title Add warning for invalid partition configuration when reprovisioning with non-root disks fcos/v1_6_exp: warn if config attempts to reuse partition by label Apr 22, 2023
config/fcos/v1_6_exp/validate_test.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate_test.go Show resolved Hide resolved
@Adam0Brien Adam0Brien force-pushed the p-tables-tests branch 2 times, most recently from 3a7ebe0 to d513c50 Compare April 22, 2023 01:45
@Adam0Brien Adam0Brien force-pushed the p-tables-tests branch 3 times, most recently from b112b73 to aa9010a Compare May 2, 2023 18:54
docs/release-notes.md Outdated Show resolved Hide resolved
Copy link
Contributor

@bgilbert bgilbert 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 overall! A couple small fixes and then this should be ready.

docs/release-notes.md Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate_test.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate_test.go Outdated Show resolved Hide resolved
config/fcos/v1_6_exp/validate_test.go Show resolved Hide resolved
@bgilbert
Copy link
Contributor

LGTM. Please squash your commits and I'll approve.

Ignition matches existing partitions by number, not by label.  When
reusing an existing partition table, if the config specifies a label
and leaves the number at the default of 0, Ignition will try to add a
new partition rather than reusing any existing one.  That was probably
not the user's intention, so warn in this case.

However, the boot disk is a common exception, since it has a fresh
partition table on every run.  On FCOS we can detect the alias
/dev/disk/by-id/coreos-boot-disk and not warn, but that alias was added
recently and older configs won't use it.  On other variants we don't
have any way to detect the boot disk.  Therefore, don't implement the
warning in base and don't make it retroactive to existing stable specs;
only add it to the FCOS experimental spec.
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.

Warn if config attempts to reuse partition by label
3 participants