Skip to content

Add validation that --emulation-version=<version> >= DefaultKubeBinaryVersion-3  #127514

Closed
@aaron-prindle

Description

What would you like to be added?

Currently we have validation logic here:

https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/util/version/version.go#L171-L180

// ValidateKubeEffectiveVersion validates the EmulationVersion is equal to the binary version at 1.31 for kube components.
// emulationVersion is introduced in 1.31, so it is only allowed to be equal to the binary version at 1.31.
func ValidateKubeEffectiveVersion(effectiveVersion EffectiveVersion) error {
	binaryVersion := version.MajorMinor(effectiveVersion.BinaryVersion().Major(), effectiveVersion.BinaryVersion().Minor())
	if binaryVersion.EqualTo(version.MajorMinor(1, 31)) && !effectiveVersion.EmulationVersion().EqualTo(binaryVersion) {
		return fmt.Errorf("emulation version needs to be equal to binary version(%s) in compatibility-version alpha, got %s",
			binaryVersion.String(), effectiveVersion.EmulationVersion().String())
	}
	return nil
}

That makes sure that --emulation-version=<version> version that is passed is >=1.31. Currently this check is enough as k8s latest release is 1.31 but the actual restriction for --emulation-version is the current k8s binary version-3 (denoted as n-3). As such the validation rule needs to be updated to prevent unsupported emulation versions for k8s versions v1.35+

Related PR comment denoted this future work: #126977 (comment)

Why is this needed?

This is needed as w/o this, users could set --emulation-version=<n-4> in the future (eg: k8s versions v1.35+) which is not supported and could break them

/sig api-machinery

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions