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

Update disk resize to work with lvms-storage-operator/topolvm #4114

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

anjannath
Copy link
Member

@anjannath anjannath commented Apr 9, 2024

fixes #4117

needs crc-org/snc#877

@openshift-ci openshift-ci bot requested review from cfergeau and gbraad April 9, 2024 12:30
Copy link

openshift-ci bot commented Apr 9, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from anjannath. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

pkg/crc/config/settings.go Outdated Show resolved Hide resolved
cmd/crc/cmd/start.go Outdated Show resolved Hide resolved
@anjannath

This comment was marked as outdated.

@praveenkumar
Copy link
Member

/wip

@praveenkumar
Copy link
Member

/hold

@anjannath anjannath force-pushed the extradisk branch 3 times, most recently from 92fa114 to efefed3 Compare June 6, 2024 11:38
@anjannath anjannath changed the title Install LVMCluster resource during crc start Update disk resize to work with lvms-storage-operator/topolvm Jun 6, 2024
Copy link
Contributor

@cfergeau cfergeau left a comment

Choose a reason for hiding this comment

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

I'm a bit confused by ' update disk resize to work with new disk layout ', could you detail more in the commit log why we need to move the topolvm partition (ie what fails if we don't do this)? What is the order before, what is the order after? Could this be done proactively in snc? And can we resize both the root partition and the PVs without any issue?

}
part, _, err := sshRunner.RunPrivileged("Get device id", "/usr/sbin/blkid", "-t", fmt.Sprintf("TYPE=%s", diskType), "-o", "device")
part, _, err := sshRunner.RunPrivileged("Get device id", cmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

WhilesshRunner.RunPrivileged(cmd) will work, the RunPrivileged interface expects split args (ie a []string) as other implementations won't work with a single string containing all the args separated with spaces.

Copy link
Contributor

@cfergeau cfergeau Jul 1, 2024

Choose a reason for hiding this comment

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

Might be better to avoid the duplication by using query := "--label root" and query = "-t TYPE=LVM2_member" and then hardcoding /usr/sbin/blkid and -o device in a single place.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated the commit to use the above suggestion!

}

// with '/dev/[sv]da4' as input, run 'growpart /dev/[sv]da 4'
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Growing %s partition", rootPart), "/usr/bin/growpart", rootPart[:len("/dev/.da")], rootPart[len("/dev/.da"):]); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

The corresponding code in the new file has become

	if err := growPersistentVolume(sshRunner, startConfig.Preset, startConfig.PersistentVolumeSize); err != nil {
		return fmt.Errorf("Unable to grow persistent volume partition: %w", err)
	}

	// with '/dev/[sv]da4' as input, run 'growpart /dev/[sv]da 4'
	if err := growPartition(sshRunner, rootPart); err != nil {
		return nil
	}

While the addition of a helper is a good thing, this should not be hidden in a commit saying it's only moving code.
Fwiw, a helper for move topolvm partition to end of disk could also be useful to make growRootFilesystem easier to read.

@cfergeau
Copy link
Contributor

cfergeau commented Jul 1, 2024

this PR is not needed anymore, the snc PRs:

I assume this is no longer accurate as you updated the PR?

after using topolvm as storage provisioner there's
two partitions of type xfs and its ambiguos  which
is the root partition but the root partition  also
has a label 'root' in case of the ocp bundle
this allows users to also configure the persistent volume's partition
size for the ocp preset, in case of ocp preset the default size of the
persistent volume partition (topolvm partition) is 3G
to be able to use topolvm we need a separate parition this new
partition is added at the end of the disk and used by  topolvm
so the new disk layout is |efi|boot|root|pv|

earlier the root parition could be easily extended after  increasing
the disk size as there was no patition after it, with the new layout
after increasing the disk size we have to move the "pv" partition to
create free space after the "root" partition to increase its size

this adds code to move topolvm partition and restart the VM which is
needed to re-read the changed partition table, after moving the part
the root partition can be grown
this makes it a bit easier to navigate the start.go file by moving
some of the disk size and partition modification functions into  a
separate disks.go file in the same machine package
this uses `blkid -t PARTLABEL=topolvm` to get the topolvm
partition name and introduces a new helper getDeviceID to
run different forms of the `blkid` command
Copy link

openshift-ci bot commented Jul 3, 2024

@anjannath: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security 4617cab link false /test security
ci/prow/e2e-microshift-crc 4617cab link true /test e2e-microshift-crc
ci/prow/integration-crc 4617cab link true /test integration-crc
ci/prow/e2e-crc 4617cab link true /test e2e-crc

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@anjannath
Copy link
Member Author

I'm a bit confused by ' update disk resize to work with new disk layout ', could you detail more in the commit log why we need to move the topolvm partition (ie what fails if we don't do this)? What is the order before, what is the order after? Could this be done proactively in snc? And can we resize both the root partition and the PVs without any issue?

i've updated the commit message.. but mentioning here as well: after adding a new partition at the end of disk, the partition layout is |efi|boot|root|topolvm|, now if we want to increase the size of the root partition we have to first move the topolvm partition to create the required free space after the root partition, earlier the root partition was the last partition on the disk and after increasing the disk size the additional free space was added after it, which is not the case anymore because the topolvm partition is there now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for review
Development

Successfully merging this pull request may close these issues.

Use LVM storage operator for dynamic PV provisioning
4 participants