mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #130930 from siyuanfoundation/help
chore: update emulation version help msg.
This commit is contained in:
commit
b4c6895d0b
@ -91,6 +91,7 @@ func (s *Server) InstallAPIs(restStorageProviders ...RESTStorageProvider) error
|
|||||||
// used later in the loop to filter the served resource by those that have expired.
|
// used later in the loop to filter the served resource by those that have expired.
|
||||||
resourceExpirationEvaluatorOpts := genericapiserver.ResourceExpirationEvaluatorOptions{
|
resourceExpirationEvaluatorOpts := genericapiserver.ResourceExpirationEvaluatorOptions{
|
||||||
CurrentVersion: s.GenericAPIServer.EffectiveVersion.EmulationVersion(),
|
CurrentVersion: s.GenericAPIServer.EffectiveVersion.EmulationVersion(),
|
||||||
|
Prerelease: s.GenericAPIServer.EffectiveVersion.BinaryVersion().PreRelease(),
|
||||||
EmulationForwardCompatible: s.GenericAPIServer.EmulationForwardCompatible,
|
EmulationForwardCompatible: s.GenericAPIServer.EmulationForwardCompatible,
|
||||||
RuntimeConfigEmulationForwardCompatible: s.GenericAPIServer.RuntimeConfigEmulationForwardCompatible,
|
RuntimeConfigEmulationForwardCompatible: s.GenericAPIServer.RuntimeConfigEmulationForwardCompatible,
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,9 @@ type ResourceExpirationEvaluator interface {
|
|||||||
type ResourceExpirationEvaluatorOptions struct {
|
type ResourceExpirationEvaluatorOptions struct {
|
||||||
// CurrentVersion is the current version of the apiserver.
|
// CurrentVersion is the current version of the apiserver.
|
||||||
CurrentVersion *apimachineryversion.Version
|
CurrentVersion *apimachineryversion.Version
|
||||||
|
// Prerelease holds an optional prerelease portion of the version.
|
||||||
|
// This is used to determine if the current binary is an alpha.
|
||||||
|
Prerelease string
|
||||||
// EmulationForwardCompatible indicates whether the apiserver should serve resources that are introduced after the current version,
|
// EmulationForwardCompatible indicates whether the apiserver should serve resources that are introduced after the current version,
|
||||||
// when resources of the same group and resource name but with lower priority are served.
|
// when resources of the same group and resource name but with lower priority are served.
|
||||||
EmulationForwardCompatible bool
|
EmulationForwardCompatible bool
|
||||||
@ -76,7 +79,8 @@ type ResourceExpirationEvaluatorOptions struct {
|
|||||||
|
|
||||||
func NewResourceExpirationEvaluator(currentVersion *apimachineryversion.Version) (ResourceExpirationEvaluator, error) {
|
func NewResourceExpirationEvaluator(currentVersion *apimachineryversion.Version) (ResourceExpirationEvaluator, error) {
|
||||||
opts := ResourceExpirationEvaluatorOptions{
|
opts := ResourceExpirationEvaluatorOptions{
|
||||||
CurrentVersion: currentVersion,
|
CurrentVersion: apimachineryversion.MajorMinor(currentVersion.Major(), currentVersion.Minor()),
|
||||||
|
Prerelease: currentVersion.PreRelease(),
|
||||||
}
|
}
|
||||||
return NewResourceExpirationEvaluatorFromOptions(opts)
|
return NewResourceExpirationEvaluatorFromOptions(opts)
|
||||||
}
|
}
|
||||||
@ -94,8 +98,8 @@ func NewResourceExpirationEvaluatorFromOptions(opts ResourceExpirationEvaluatorO
|
|||||||
}
|
}
|
||||||
// Only keeps the major and minor versions from input version.
|
// Only keeps the major and minor versions from input version.
|
||||||
ret.currentVersion = apimachineryversion.MajorMinor(currentVersion.Major(), currentVersion.Minor())
|
ret.currentVersion = apimachineryversion.MajorMinor(currentVersion.Major(), currentVersion.Minor())
|
||||||
ret.isAlpha = strings.Contains(currentVersion.PreRelease(), "alpha")
|
ret.isAlpha = strings.Contains(opts.Prerelease, "alpha")
|
||||||
ret.isAlphaZero = strings.Contains(currentVersion.PreRelease(), "alpha.0")
|
ret.isAlphaZero = strings.Contains(opts.Prerelease, "alpha.0")
|
||||||
|
|
||||||
if envString, ok := os.LookupEnv("KUBE_APISERVER_STRICT_REMOVED_API_HANDLING_IN_ALPHA"); !ok {
|
if envString, ok := os.LookupEnv("KUBE_APISERVER_STRICT_REMOVED_API_HANDLING_IN_ALPHA"); !ok {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -234,8 +234,8 @@ func (r *componentGlobalsRegistry) AddFlags(fs *pflag.FlagSet) {
|
|||||||
fs.StringSliceVar(&r.emulationVersionConfig, "emulated-version", r.emulationVersionConfig, ""+
|
fs.StringSliceVar(&r.emulationVersionConfig, "emulated-version", r.emulationVersionConfig, ""+
|
||||||
"The versions different components emulate their capabilities (APIs, features, ...) of.\n"+
|
"The versions different components emulate their capabilities (APIs, features, ...) of.\n"+
|
||||||
"If set, the component will emulate the behavior of this version instead of the underlying binary version.\n"+
|
"If set, the component will emulate the behavior of this version instead of the underlying binary version.\n"+
|
||||||
"Version format could only be major.minor, for example: '--emulated-version=wardle=1.2,kube=1.31'. Options are:\n"+strings.Join(r.unsafeVersionFlagOptions(true), "\n")+
|
"Version format could only be major.minor, for example: '--emulated-version=wardle=1.2,kube=1.31'.\nOptions are: "+strings.Join(r.unsafeVersionFlagOptions(true), ",")+
|
||||||
"If the component is not specified, defaults to \"kube\"")
|
"\nIf the component is not specified, defaults to \"kube\"")
|
||||||
|
|
||||||
if r.featureGatesConfigFlags == nil {
|
if r.featureGatesConfigFlags == nil {
|
||||||
r.featureGatesConfigFlags = cliflag.NewColonSeparatedMultimapStringStringAllowDefaultEmptyKey(&r.featureGatesConfig)
|
r.featureGatesConfigFlags = cliflag.NewColonSeparatedMultimapStringStringAllowDefaultEmptyKey(&r.featureGatesConfig)
|
||||||
|
@ -57,7 +57,7 @@ func TestEffectiveVersionRegistry(t *testing.T) {
|
|||||||
|
|
||||||
func testRegistry(t *testing.T) *componentGlobalsRegistry {
|
func testRegistry(t *testing.T) *componentGlobalsRegistry {
|
||||||
r := NewComponentGlobalsRegistry()
|
r := NewComponentGlobalsRegistry()
|
||||||
verKube := NewEffectiveVersionFromString("1.31", "1.31", "1.30")
|
verKube := NewEffectiveVersionFromString("1.31.1-beta.0.353", "1.31", "1.30")
|
||||||
fgKube := featuregate.NewVersionedFeatureGate(version.MustParse("0.0"))
|
fgKube := featuregate.NewVersionedFeatureGate(version.MustParse("0.0"))
|
||||||
err := fgKube.AddVersioned(map[featuregate.Feature]featuregate.VersionedSpecs{
|
err := fgKube.AddVersioned(map[featuregate.Feature]featuregate.VersionedSpecs{
|
||||||
"kubeA": {
|
"kubeA": {
|
||||||
@ -103,13 +103,13 @@ func testRegistry(t *testing.T) *componentGlobalsRegistry {
|
|||||||
|
|
||||||
func TestVersionFlagOptions(t *testing.T) {
|
func TestVersionFlagOptions(t *testing.T) {
|
||||||
r := testRegistry(t)
|
r := testRegistry(t)
|
||||||
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), "\n")
|
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), ",")
|
||||||
expectedEmuVers := "kube=1.31..1.31 (default=1.31)\ntest=2.8..2.8 (default=2.8)"
|
expectedEmuVers := "kube=1.31..1.31(default:1.31),test=2.8..2.8(default:2.8)"
|
||||||
if emuVers != expectedEmuVers {
|
if emuVers != expectedEmuVers {
|
||||||
t.Errorf("wanted emulation version flag options to be: %s, got %s", expectedEmuVers, emuVers)
|
t.Errorf("wanted emulation version flag options to be: %s, got %s", expectedEmuVers, emuVers)
|
||||||
}
|
}
|
||||||
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), "\n")
|
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), ",")
|
||||||
expectedMinCompVers := "kube=1.30..1.31 (default=1.30)\ntest=2.7..2.8 (default=2.7)"
|
expectedMinCompVers := "kube=1.30..1.31(default:1.30),test=2.7..2.8(default:2.7)"
|
||||||
if minCompVers != expectedMinCompVers {
|
if minCompVers != expectedMinCompVers {
|
||||||
t.Errorf("wanted min compatibility version flag options to be: %s, got %s", expectedMinCompVers, minCompVers)
|
t.Errorf("wanted min compatibility version flag options to be: %s, got %s", expectedMinCompVers, minCompVers)
|
||||||
}
|
}
|
||||||
@ -119,13 +119,13 @@ func TestVersionFlagOptionsWithMapping(t *testing.T) {
|
|||||||
r := testRegistry(t)
|
r := testRegistry(t)
|
||||||
utilruntime.Must(r.SetEmulationVersionMapping(testComponent, DefaultKubeComponent,
|
utilruntime.Must(r.SetEmulationVersionMapping(testComponent, DefaultKubeComponent,
|
||||||
func(from *version.Version) *version.Version { return version.MajorMinor(1, from.Minor()+23) }))
|
func(from *version.Version) *version.Version { return version.MajorMinor(1, from.Minor()+23) }))
|
||||||
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), "\n")
|
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), ",")
|
||||||
expectedEmuVers := "test=2.8..2.8 (default=2.8)"
|
expectedEmuVers := "test=2.8..2.8(default:2.8)"
|
||||||
if emuVers != expectedEmuVers {
|
if emuVers != expectedEmuVers {
|
||||||
t.Errorf("wanted emulation version flag options to be: %s, got %s", expectedEmuVers, emuVers)
|
t.Errorf("wanted emulation version flag options to be: %s, got %s", expectedEmuVers, emuVers)
|
||||||
}
|
}
|
||||||
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), "\n")
|
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), ",")
|
||||||
expectedMinCompVers := "kube=1.30..1.31 (default=1.30)\ntest=2.7..2.8 (default=2.7)"
|
expectedMinCompVers := "kube=1.30..1.31(default:1.30),test=2.7..2.8(default:2.7)"
|
||||||
if minCompVers != expectedMinCompVers {
|
if minCompVers != expectedMinCompVers {
|
||||||
t.Errorf("wanted min compatibility version flag options to be: %s, got %s", expectedMinCompVers, minCompVers)
|
t.Errorf("wanted min compatibility version flag options to be: %s, got %s", expectedMinCompVers, minCompVers)
|
||||||
}
|
}
|
||||||
|
@ -79,13 +79,7 @@ func (m *effectiveVersion) BinaryVersion() *version.Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *effectiveVersion) EmulationVersion() *version.Version {
|
func (m *effectiveVersion) EmulationVersion() *version.Version {
|
||||||
ver := m.emulationVersion.Load()
|
return m.emulationVersion.Load()
|
||||||
if ver != nil {
|
|
||||||
// Emulation version can have "alpha" as pre-release to continue serving expired apis while we clean up the test.
|
|
||||||
// The pre-release should not be accessible to the users.
|
|
||||||
return ver.WithPreRelease(m.BinaryVersion().PreRelease())
|
|
||||||
}
|
|
||||||
return ver
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *effectiveVersion) MinCompatibilityVersion() *version.Version {
|
func (m *effectiveVersion) MinCompatibilityVersion() *version.Version {
|
||||||
@ -140,7 +134,7 @@ func (m *effectiveVersion) AllowedEmulationVersionRange() string {
|
|||||||
floor = version.MajorMinor(0, 0)
|
floor = version.MajorMinor(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s..%s (default=%s)", floor.String(), binaryVersion.String(), m.EmulationVersion().String())
|
return fmt.Sprintf("%s..%s(default:%s)", floor.String(), binaryVersion.String(), m.EmulationVersion().String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *effectiveVersion) AllowedMinCompatibilityVersionRange() string {
|
func (m *effectiveVersion) AllowedMinCompatibilityVersionRange() string {
|
||||||
@ -157,7 +151,7 @@ func (m *effectiveVersion) AllowedMinCompatibilityVersionRange() string {
|
|||||||
floor = version.MajorMinor(0, 0)
|
floor = version.MajorMinor(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s..%s (default=%s)", floor.String(), binaryVersion.String(), m.MinCompatibilityVersion().String())
|
return fmt.Sprintf("%s..%s(default:%s)", floor.String(), binaryVersion.String(), m.MinCompatibilityVersion().String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *effectiveVersion) Validate() []error {
|
func (m *effectiveVersion) Validate() []error {
|
||||||
|
Loading…
Reference in New Issue
Block a user