mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #99840 from deads2k/try-beta
update to handle beta removals in 1.22
This commit is contained in:
commit
8abdf8cf45
19484
api/openapi-spec/swagger.json
generated
19484
api/openapi-spec/swagger.json
generated
File diff suppressed because it is too large
Load Diff
@ -83,7 +83,6 @@ import (
|
|||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
discoveryclient "k8s.io/client-go/kubernetes/typed/discovery/v1"
|
discoveryclient "k8s.io/client-go/kubernetes/typed/discovery/v1"
|
||||||
"k8s.io/component-base/version"
|
|
||||||
"k8s.io/component-helpers/apimachinery/lease"
|
"k8s.io/component-helpers/apimachinery/lease"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
@ -571,7 +570,7 @@ func (m *Instance) InstallAPIs(apiResourceConfigSource serverstorage.APIResource
|
|||||||
apiGroupsInfo := []*genericapiserver.APIGroupInfo{}
|
apiGroupsInfo := []*genericapiserver.APIGroupInfo{}
|
||||||
|
|
||||||
// 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.
|
||||||
resourceExpirationEvaluator, err := genericapiserver.NewResourceExpirationEvaluator(version.Get())
|
resourceExpirationEvaluator, err := genericapiserver.NewResourceExpirationEvaluator(*m.GenericAPIServer.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -317,31 +317,13 @@ func TestAPIVersionOfDiscoveryEndpoints(t *testing.T) {
|
|||||||
assert.NoError(decodeResponse(resp, &groupList))
|
assert.NoError(decodeResponse(resp, &groupList))
|
||||||
assert.Equal(groupList.APIVersion, "")
|
assert.Equal(groupList.APIVersion, "")
|
||||||
|
|
||||||
// /apis/extensions exists in release-1.1
|
|
||||||
resp, err = http.Get(server.URL + "/apis/extensions")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
group := metav1.APIGroup{}
|
|
||||||
assert.NoError(decodeResponse(resp, &group))
|
|
||||||
assert.Equal(group.APIVersion, "")
|
|
||||||
|
|
||||||
// /apis/extensions/v1beta1 exists in release-1.1
|
|
||||||
resp, err = http.Get(server.URL + "/apis/extensions/v1beta1")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
resourceList = metav1.APIResourceList{}
|
|
||||||
assert.NoError(decodeResponse(resp, &resourceList))
|
|
||||||
assert.Equal(resourceList.APIVersion, "")
|
|
||||||
|
|
||||||
// /apis/autoscaling doesn't exist in release-1.1, so the APIVersion field
|
// /apis/autoscaling doesn't exist in release-1.1, so the APIVersion field
|
||||||
// should be non-empty in the results returned by the server.
|
// should be non-empty in the results returned by the server.
|
||||||
resp, err = http.Get(server.URL + "/apis/autoscaling")
|
resp, err = http.Get(server.URL + "/apis/autoscaling")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
group = metav1.APIGroup{}
|
group := metav1.APIGroup{}
|
||||||
assert.NoError(decodeResponse(resp, &group))
|
assert.NoError(decodeResponse(resp, &group))
|
||||||
assert.Equal(group.APIVersion, "v1")
|
assert.Equal(group.APIVersion, "v1")
|
||||||
|
|
||||||
@ -376,8 +358,10 @@ func TestStorageVersionHashes(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
var count int
|
var count int
|
||||||
|
apiResources := sets.NewString()
|
||||||
for _, g := range all {
|
for _, g := range all {
|
||||||
for _, r := range g.APIResources {
|
for _, r := range g.APIResources {
|
||||||
|
apiResources.Insert(g.GroupVersion + "/" + r.Name)
|
||||||
if strings.Contains(r.Name, "/") ||
|
if strings.Contains(r.Name, "/") ||
|
||||||
storageversionhashdata.NoStorageVersionHash.Has(g.GroupVersion+"/"+r.Name) {
|
storageversionhashdata.NoStorageVersionHash.Has(g.GroupVersion+"/"+r.Name) {
|
||||||
if r.StorageVersionHash != "" {
|
if r.StorageVersionHash != "" {
|
||||||
@ -399,7 +383,8 @@ func TestStorageVersionHashes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if count != len(storageversionhashdata.GVRToStorageVersionHash) {
|
if count != len(storageversionhashdata.GVRToStorageVersionHash) {
|
||||||
t.Errorf("please remove the redundant entries from GVRToStorageVersionHash")
|
knownResources := sets.StringKeySet(storageversionhashdata.GVRToStorageVersionHash)
|
||||||
|
t.Errorf("please remove the redundant entries from GVRToStorageVersionHash: %v", knownResources.Difference(apiResources).List())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,6 +593,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||||||
|
|
||||||
APIServerID: c.APIServerID,
|
APIServerID: c.APIServerID,
|
||||||
StorageVersionManager: c.StorageVersionManager,
|
StorageVersionManager: c.StorageVersionManager,
|
||||||
|
|
||||||
|
Version: c.Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -54,7 +54,10 @@ type ResourceExpirationEvaluator interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewResourceExpirationEvaluator(currentVersion apimachineryversion.Info) (ResourceExpirationEvaluator, error) {
|
func NewResourceExpirationEvaluator(currentVersion apimachineryversion.Info) (ResourceExpirationEvaluator, error) {
|
||||||
ret := &resourceExpirationEvaluator{}
|
ret := &resourceExpirationEvaluator{
|
||||||
|
// TODO https://github.com/kubernetes/kubernetes/issues/101951 set this back to false after beta is tagged.
|
||||||
|
strictRemovedHandlingInAlpha: true,
|
||||||
|
}
|
||||||
if len(currentVersion.Major) > 0 {
|
if len(currentVersion.Major) > 0 {
|
||||||
currentMajor64, err := strconv.ParseInt(currentVersion.Major, 10, 32)
|
currentMajor64, err := strconv.ParseInt(currentVersion.Major, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -83,6 +86,7 @@ func NewResourceExpirationEvaluator(currentVersion apimachineryversion.Info) (Re
|
|||||||
} else {
|
} else {
|
||||||
ret.strictRemovedHandlingInAlpha = envBool
|
ret.strictRemovedHandlingInAlpha = envBool
|
||||||
}
|
}
|
||||||
|
|
||||||
if envString, ok := os.LookupEnv("KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE"); !ok {
|
if envString, ok := os.LookupEnv("KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE"); !ok {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if envBool, err := strconv.ParseBool(envString); err != nil {
|
} else if envBool, err := strconv.ParseBool(envString); err != nil {
|
||||||
|
@ -82,6 +82,7 @@ func Test_newResourceExpirationEvaluator(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actual.(*resourceExpirationEvaluator).strictRemovedHandlingInAlpha = false
|
||||||
if !reflect.DeepEqual(tt.expected, *actual.(*resourceExpirationEvaluator)) {
|
if !reflect.DeepEqual(tt.expected, *actual.(*resourceExpirationEvaluator)) {
|
||||||
t.Fatal(actual)
|
t.Fatal(actual)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/apimachinery/pkg/util/clock"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
utilwaitgroup "k8s.io/apimachinery/pkg/util/waitgroup"
|
utilwaitgroup "k8s.io/apimachinery/pkg/util/waitgroup"
|
||||||
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/apiserver/pkg/admission"
|
"k8s.io/apiserver/pkg/admission"
|
||||||
"k8s.io/apiserver/pkg/audit"
|
"k8s.io/apiserver/pkg/audit"
|
||||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||||
@ -209,6 +210,9 @@ type GenericAPIServer struct {
|
|||||||
|
|
||||||
// StorageVersionManager holds the storage versions of the API resources installed by this server.
|
// StorageVersionManager holds the storage versions of the API resources installed by this server.
|
||||||
StorageVersionManager storageversion.Manager
|
StorageVersionManager storageversion.Manager
|
||||||
|
|
||||||
|
// Version will enable the /version endpoint if non-nil
|
||||||
|
Version *version.Info
|
||||||
}
|
}
|
||||||
|
|
||||||
// DelegationTarget is an interface which allows for composition of API servers with top level handling that works
|
// DelegationTarget is an interface which allows for composition of API servers with top level handling that works
|
||||||
|
@ -138,6 +138,7 @@ func (o *ReconcileOptions) Complete(cmd *cobra.Command, f cmdutil.Factory, args
|
|||||||
NamespaceParam(namespace).DefaultNamespace().
|
NamespaceParam(namespace).DefaultNamespace().
|
||||||
FilenameParam(enforceNamespace, o.FilenameOptions).
|
FilenameParam(enforceNamespace, o.FilenameOptions).
|
||||||
Flatten().
|
Flatten().
|
||||||
|
Local().
|
||||||
Do()
|
Do()
|
||||||
|
|
||||||
if err := r.Err(); err != nil {
|
if err := r.Err(); err != nil {
|
||||||
|
@ -309,6 +309,12 @@ func NewMasterConfigWithOptions(opts *MasterConfigOptions) *controlplane.Config
|
|||||||
|
|
||||||
genericConfig := genericapiserver.NewConfig(legacyscheme.Codecs)
|
genericConfig := genericapiserver.NewConfig(legacyscheme.Codecs)
|
||||||
kubeVersion := version.Get()
|
kubeVersion := version.Get()
|
||||||
|
if len(kubeVersion.Major) == 0 {
|
||||||
|
kubeVersion.Major = "1"
|
||||||
|
}
|
||||||
|
if len(kubeVersion.Minor) == 0 {
|
||||||
|
kubeVersion.Minor = "22"
|
||||||
|
}
|
||||||
genericConfig.Version = &kubeVersion
|
genericConfig.Version = &kubeVersion
|
||||||
genericConfig.Authorization.Authorizer = authorizerfactory.NewAlwaysAllowAuthorizer()
|
genericConfig.Authorization.Authorizer = authorizerfactory.NewAlwaysAllowAuthorizer()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user