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

Fix wrong fs label as partition label #316

Merged
merged 2 commits into from
May 10, 2022
Merged

Fix wrong fs label as partition label #316

merged 2 commits into from
May 10, 2022

Conversation

Itxaka
Copy link
Contributor

@Itxaka Itxaka commented May 5, 2022

The label entry in the Partition struct should correspond to the
partition label, but we were getting the FS label instead.

This patch fixes that by getting the actual partition label for the
label value and adding an extra field on the Partition struct to add the
fs label, so they are separated and clear on which is which.

Signed-off-by: Itxaka igarcia@suse.com

The label entry in the Partition struct should correspond to the
partition label, but we were getting the FS label instead.

This patch fixes that by getting the actual partition label for the
label value and adding an extra field on the Partition struct to add the
fs label, so they are separated and clear on which is which.

Signed-off-by: Itxaka <igarcia@suse.com>
@Itxaka
Copy link
Contributor Author

Itxaka commented May 5, 2022

For me it makes sense that the entry at Partition.Label refers to the actual label of the partition itself, if it has. And FsLabel is for the FS that the partition has and can change if the partition is reformatted. The partition label wont change in that case.

Sorry about this :)

@Itxaka
Copy link
Contributor Author

Itxaka commented May 5, 2022

This breaks the API by changing the underlying value, unfortunately.

Another proposal could be adding 2 new fields, FSLabel and PartLabel and filling those correctly while deprecating the Label field but keeping it like it currently is, so it can be dropped in a couple of versions while we transition.

@Itxaka
Copy link
Contributor Author

Itxaka commented May 5, 2022

Although one could argue that the API is not really broken, we are fixing the value that it returns because its not really correct and providing another way of getting the older value provided by it.

It would be good to get a look at this asap, as this was recently released (the new Partition.Label entry) so the time to fix it is now, before it can be used generally by other projects cc @jaypipes @fromanirh :)

@jaypipes jaypipes requested review from ffromani and jaypipes May 6, 2022 14:16
@ffromani
Copy link
Collaborator

ffromani commented May 6, 2022

Although one could argue that the API is not really broken, we are fixing the value that it returns because its not really correct and providing another way of getting the older value provided by it.

It would be good to get a look at this asap, as this was recently released (the new Partition.Label entry) so the time to fix it is now, before it can be used generally by other projects cc @jaypipes @fromanirh :)

I'll review shortly (ETA worst case 20220509)

return util.UNKNOWN
}

if label, ok := info["ID_PART_ENTRY_NAME"]; ok {
Copy link
Owner

Choose a reason for hiding this comment

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

@Itxaka what would you think about leaving only Partition.Label field and simply looking up ID_PART_ENTRY_NAME first and then using ID_FS_LABEL if and only if ID_PART_ENTRY_NAME is empty?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jaypipes I don't really have strong feelings here, but I do have a feeble feeling ( :) ) that conflating these two different labels in the same field feels a bit funky. OTOH avoiding to expand the API surface also makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Itxaka what would you think about leaving only Partition.Label field and simply looking up ID_PART_ENTRY_NAME first and then using ID_FS_LABEL if and only if ID_PART_ENTRY_NAME is empty?

I would not do that as they are different values and can be set by different things, so it doesnt make sense to mix them together, that can lead to mistakes happening. i.e. If I format a partition with a label X and then search for the partition label I would get X which is not necessarily the label of the partition.

that conflating these two different labels in the same field feels a bit funky.

Agreed, they are different things and should be separated. They can be different and should be reported as different IMHO, as one is a partition label and the other a FS label.

Note that if your FS is formatted, the label will be erased but not the partition label, so its very helpful to have both.

OTOH avoiding to expand the API surface also makes sense.

I understand not wanting to expand the API surface, but this is a valuable information to add, especially with it already reporting the partition type, its a nice thing to also have the FS label and partition as you can identify partitions by any of those values.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Itxaka yes, I'm now pretty much convinced we should have two separate fields for these labels.

@@ -183,6 +183,7 @@ type Partition struct {
Type string `json:"type"`
IsReadOnly bool `json:"read_only"`
UUID string `json:"uuid"` // This would be volume UUID on macOS, PartUUID on linux, empty on Windows
FSLabel string
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing json tags - should probably add json:"fs_label" or perhaps we want to go as far as json:"filesystem_label"? (I think the former is good)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, didnt want to add anything here yet as the values can change. Will make sure to add the json tags once we agreed what fields goes where 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fine for me, thanks!

Copy link
Owner

Choose a reason for hiding this comment

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

@Itxaka @fromanirh OK, good with me to have a separate field then :) Can we name it FilesystemLabel and json:"filesystem_label" though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you wish is my command, behold a new commit!

@Itxaka Itxaka requested review from jaypipes and ffromani May 9, 2022 08:04
@@ -183,6 +183,7 @@ type Partition struct {
Type string `json:"type"`
IsReadOnly bool `json:"read_only"`
UUID string `json:"uuid"` // This would be volume UUID on macOS, PartUUID on linux, empty on Windows
FSLabel string
Copy link
Owner

Choose a reason for hiding this comment

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

@Itxaka @fromanirh OK, good with me to have a separate field then :) Can we name it FilesystemLabel and json:"filesystem_label" though?

Signed-off-by: Itxaka <igarcia@suse.com>
@Itxaka Itxaka requested a review from jaypipes May 10, 2022 14:01
@ffromani
Copy link
Collaborator

LGTM! thanks a lot!

Copy link
Owner

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

perfect :) thanks @Itxaka!

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