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

growpart: Fix behaviour for ZFS datasets #5169

Merged
merged 2 commits into from
May 31, 2024

Conversation

igalic
Copy link
Collaborator

@igalic igalic commented Apr 11, 2024

Proposed Commit Message

growpart: Fix behaviour for ZFS datasets

on FreeBSD, ZFS datasets aren't exposed directly as disks devices, so
stats will fail. Currently, this means that growpart will be skipped for
FreeBSD ZFS volumes, even tho we are perfectly capable of  resizing ZFS.

- Return fs from devent2dev(), which is now inappropriately named
- Add get_zfs_size() helper, and extend get_size() to accept an `fs`
  parameter.
- Add _call_resizer() helper, to avoid an indent on `if fs == zfs`

Sponsored by:	The FreeBSD Foundation

Additional Context

Test Steps

Checklist

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Copy link
Collaborator Author

@igalic igalic 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 the kind of code that a goto would make more readable.
Unfortunately, Python has no goto, so I'll have to think a little harder about how to do this.

cloudinit/config/cc_growpart.py Show resolved Hide resolved
LOG.debug("Failed: zpool get size %s", zpool)
return None
return int(size.strip())

def devent2dev(devent):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

might wanna rename this function now that it returns more, maybe deventinfo?

Copy link
Member

Choose a reason for hiding this comment

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

might wanna rename this function now that it returns more, maybe deventinfo?

Agreed, how about a snake case device_entry_info() or dev_entry_info() or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds good, I'll change that tomorrow or the day after.

cloudinit/config/cc_growpart.py Outdated Show resolved Hide resolved
@igalic igalic force-pushed the fix/zfs_growpart branch 5 times, most recently from 5589b3e to 05f7702 Compare April 17, 2024 21:48
@holmanb holmanb self-assigned this Apr 18, 2024
@igalic igalic force-pushed the fix/zfs_growpart branch 3 times, most recently from 4850aec to 587c5ea Compare April 28, 2024 08:39
…cal#5169)

First off, the recursion was bogus, because it called the wrong
function, but more importantly, it would lead to infinite recursion
anyway, even if we called the right one.

Throw a ValueError instead, because we've most likely been called with a
bogus value. Add a test to show that.

Sponsored by: The FreeBSD Foundation
igalic added a commit to igalic/cloud-init that referenced this pull request Apr 29, 2024
on FreeBSD, ZFS datasets aren't exposed directly as disks devices, so
stats will fail. Currently, this means that growpart will be skipped for
FreeBSD ZFS volumes, even tho we are perfectly capable of  resizing ZFS.

- Return fs from devent2dev(), which is now inappropriately named
- Add get_zfs_size() helper, and extend get_size() to accept an `fs`
  parameter.
- Add _call_resizer() helper, to avoid an indent on `if fs == zfs`
- Add a unittest to show the behaviour

Sponsored by:	The FreeBSD Foundation
@igalic igalic marked this pull request as ready for review April 29, 2024 15:52
igalic added a commit to igalic/cloud-init that referenced this pull request Apr 29, 2024
on FreeBSD, ZFS datasets aren't exposed directly as disks devices, so
stats will fail. Currently, this means that growpart will be skipped for
FreeBSD ZFS volumes, even tho we are perfectly capable of  resizing ZFS.

- Return fs from devent2dev(), which is now inappropriately named
- Add get_zfs_size() helper, and extend get_size() to accept an `fs`
  parameter.
- Add _call_resizer() helper, to avoid an indent on `if fs == zfs`
- Add a unittest to show the behaviour

Sponsored by:	The FreeBSD Foundation
on FreeBSD, ZFS datasets aren't exposed directly as disks devices, so
stats will fail. Currently, this means that growpart will be skipped for
FreeBSD ZFS volumes, even tho we are perfectly capable of  resizing ZFS.

- Return fs from devent2dev(), which is now inappropriately named
- Add get_zfs_size() helper, and extend get_size() to accept an `fs`
  parameter.
- Add _call_resizer() helper, to avoid an indent on `if fs == zfs`
- Add a unittest to show the behaviour

Sponsored by:	The FreeBSD Foundation
@igalic
Copy link
Collaborator Author

igalic commented Apr 29, 2024

tested on aws: Still works!

@holmanb
Copy link
Member

holmanb commented May 13, 2024

tested on aws: Still works!

Nice, thanks for this. Busy at a conference now but I'll try to review (and land it if ready) in the next few days.

Copy link

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label May 29, 2024
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay on this one @igalic. This looks good to me, thanks for putting in the work on it!

@holmanb holmanb merged commit e520c94 into canonical:main May 31, 2024
29 checks passed
holmanb pushed a commit that referenced this pull request May 31, 2024
First off, the recursion was bogus, because it called the wrong
function, but more importantly, it would lead to infinite recursion
anyway, even if we called the right one.

Throw a ValueError instead, because we've most likely been called with a
bogus value. Add a test to show that.

Sponsored by: The FreeBSD Foundation
holmanb pushed a commit that referenced this pull request Jun 28, 2024
First off, the recursion was bogus, because it called the wrong
function, but more importantly, it would lead to infinite recursion
anyway, even if we called the right one.

Throw a ValueError instead, because we've most likely been called with a
bogus value. Add a test to show that.

Sponsored by: The FreeBSD Foundation
holmanb pushed a commit that referenced this pull request Jun 28, 2024
on FreeBSD, ZFS datasets aren't exposed directly as disks devices, so
stats will fail. Currently, this means that growpart will be skipped for
FreeBSD ZFS volumes, even tho we are perfectly capable of  resizing ZFS.

- Return fs from devent2dev(), which is now inappropriately named
- Add get_zfs_size() helper, and extend get_size() to accept an `fs`
  parameter.
- Add _call_resizer() helper, to avoid an indent on `if fs == zfs`
- Add a unittest to show the behaviour

Sponsored by:	The FreeBSD Foundation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale-pr Pull request is stale; will be auto-closed soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants