Change:
Starting in 1.31, --version no longer works to modify the build ID of the running components. /kind regression /priority important-soon Running kube-apiserver v1.31.0 with ignores the modified build ID and reports In 1.28, 1.29, and 1.30 (since ), this allowed modifying the build ID of the running server. /sig api-machinery /assign Run v1.31.0 with No response 31.0 n/a <details</details<details</details<details</details<details</details
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the label and provide further guidance. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
I think this broke in DefaultBuildEffectiveVersion() is grabbed in NewAPIServerCommand(), before the flag is parsed, so the GitVersion propagated into the snapshot effectiveVersion doesn't honor
cc

Discussion:
# Enable features ENABLE_FEATURE_GATES="" <ins> VERSION_OVERRIDE="" if [[ "${CUSTOM_VERSION_SUFFIX:-}" != "" ]]; then VERSION_OVERRIDE="--version=$("${THIS_PLATFORM_BIN}/kube-apiserver" --version | awk '{print $2}')${CUSTOM_VERSION_SUFFIX:-}" fi </ins> "${THIS_PLATFORM_BIN}/kube-apiserver"  <ins> ${VERSION_OVERRIDE:+"${VERSION_OVERRIDE}"}  </ins> --bind-address="127.0.0.1"  --authorization-mode="${AUTHORIZATION_MODE}"  --secure-port="${SECURE_API_PORT}" 

kube::log::status "Running kubectl tests for kube-apiserver" setup <ins> # Test custom version invocation CUSTOM_VERSION_SUFFIX=-custom run_kube_apiserver kube::test::if_has_string "$(kubectl get --raw /version)" "gitVersion.*-custom" kill "${APISERVER_PID}" 1>&2 2>/dev/null wait "${APISERVER_PID}" || true unset APISERVER_PID </ins> run_kube_apiserver run_kube_controller_manager create_node

} type effectiveVersion struct { <ins> // When true, BinaryVersion() returns the current binary version useDefaultBuildBinaryVersion atomic.Bool // Holds the last binary version stored in Set() </ins> binaryVersion atomic.Pointer[version.Version] // If the emulationVersion is set by the users, it could only contain major and minor versions. // In tests, emulationVersion could be the same as the binary version, or set directly,

} func (m *effectiveVersion) BinaryVersion() *version.Version { <ins> if m.useDefaultBuildBinaryVersion.Load() { return defaultBuildBinaryVersion() } </ins> return m.binaryVersion.Load() }

func (m *effectiveVersion) Set(binaryVersion, emulationVersion, minCompatibilityVersion *version.Version) { m.binaryVersion.Store(binaryVersion) <ins> m.useDefaultBuildBinaryVersion.Store(false) </ins> m.emulationVersion.Store(majorMinor(emulationVersion)) m.minCompatibilityVersion.Store(majorMinor(minCompatibilityVersion)) }

func (m *effectiveVersion) Validate() []error { var errs []error // Validate only checks the major and minor versions. <del> binaryVersion := m.binaryVersion.Load().WithPatch(0) </del> <ins> binaryVersion := m.BinaryVersion().WithPatch(0) </ins> emulationVersion := m.emulationVersion.Load() minCompatibilityVersion := m.minCompatibilityVersion.Load()

return errs } <del> func newEffectiveVersion(binaryVersion *version.Version) MutableEffectiveVersion { </del> <ins> func newEffectiveVersion(binaryVersion *version.Version, useDefaultBuildBinaryVersion bool) MutableEffectiveVersion { </ins> effective := &effectiveVersion{} compatVersion := binaryVersion.SubtractMinor(1) effective.Set(binaryVersion, binaryVersion, compatVersion) <ins> effective.useDefaultBuildBinaryVersion.Store(useDefaultBuildBinaryVersion) </ins> return effective }

return &effectiveVersion{} } binaryVersion := version.MustParse(binaryVer) <del> return newEffectiveVersion(binaryVersion) </del> <ins> return newEffectiveVersion(binaryVersion, false) } func defaultBuildBinaryVersion() *version.Version { verInfo := baseversion.Get() return version.MustParse(verInfo.String()).WithInfo(verInfo) </ins> } // DefaultBuildEffectiveVersion returns the MutableEffectiveVersion based on the // current build information. func DefaultBuildEffectiveVersion() MutableEffectiveVersion { <del> verInfo := baseversion.Get() binaryVersion := version.MustParse(verInfo.String()).WithInfo(verInfo) </del> <ins> binaryVersion := defaultBuildBinaryVersion() </ins> if binaryVersion.Major() == 0 && binaryVersion.Minor() == 0 { return DefaultKubeEffectiveVersion() } <del> return newEffectiveVersion(binaryVersion) </del> <ins> return newEffectiveVersion(binaryVersion, true) </ins> } // DefaultKubeEffectiveVersion returns the MutableEffectiveVersion based on the // latest K8s release. func DefaultKubeEffectiveVersion() MutableEffectiveVersion { binaryVersion := version.MustParse(baseversion.DefaultKubeBinaryVersion).WithInfo(baseversion.Get()) <del> return newEffectiveVersion(binaryVersion) </del> <ins> return newEffectiveVersion(binaryVersion, false) </ins> } // ValidateKubeEffectiveVersion validates the EmulationVersion is equal to the binary version at 1.31 for kube components.