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

feat(spdk): Support changing volume size #2646

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AaronDewes
Copy link

@AaronDewes AaronDewes commented Feb 24, 2024

Which issue(s) this PR fixes:

longhorn/longhorn#8022

What this PR does / why we need it:

Currently, SPDK volumes can not be expanded. This aims at fixing this.

Special notes for your reviewer:

I've not contributed to Longhorn before and this is completely untested. I'm trying to implement & test this feature, this is just a draft.

Additional documentation or context

Depends on longhorn/longhorn-instance-manager#415

@derekbit
Copy link
Member

derekbit commented Mar 1, 2024

Need to update the function. cliAPIVersion is always 0 for v2 volume, so skip the check.

func IsValidForExpansion(engine *longhorn.Engine, cliAPIVersion, imAPIVersion int) (bool, error) {
	if engine.Status.IsExpanding {
		return false, nil
	}
	if engine.Spec.VolumeSize == engine.Status.CurrentSize {
		return false, nil
	}
	if engine.Spec.VolumeSize < engine.Status.CurrentSize {
		return false, fmt.Errorf("the expected size %v of engine %v should not be smaller than the current size %v", engine.Spec.VolumeSize, engine.Name, engine.Status.CurrentSize)
	}

	if datastore.IsDataEngineV1(engine.Spec.DataEngine) {
		if cliAPIVersion < engineapi.CLIAPIMinVersionForExistingEngineBeforeUpgrade {
			return false, nil
		}

		if !engineapi.IsEndpointTGTBlockDev(engine.Status.Endpoint) {
			return true, nil
		}
		if cliAPIVersion < 7 {
			return false, fmt.Errorf("failed to do online expansion for the old engine %v with cli API version %v", engine.Name, cliAPIVersion)
		}
		if imAPIVersion < 3 {
			return false, fmt.Errorf("failed do online expansion for the engine %v in the instance manager with API version %v", engine.Name, imAPIVersion)
		}
	}

	return true, nil
}

@AaronDewes AaronDewes changed the title Support changing volume size feat(spdk): Support changing volume size Mar 1, 2024
@innobead
Copy link
Member

@AaronDewes any updates?

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