Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0ae81c98
Unverified
Commit
0ae81c98
authored
Feb 11, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 11, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #67678 from caesarxuchao/remove-storage-versions-flag
Remove storage versions flag
parents
ee734d05
4ea07084
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
24 additions
and
325 deletions
+24
-325
BUILD
cmd/kube-apiserver/app/options/BUILD
+0
-1
options.go
cmd/kube-apiserver/app/options/options.go
+0
-3
options_test.go
cmd/kube-apiserver/app/options/options_test.go
+0
-5
server.go
cmd/kube-apiserver/app/server.go
+1
-1
test-dockerized.sh
hack/jenkins/test-dockerized.sh
+0
-1
BUILD
pkg/kubeapiserver/BUILD
+0
-1
default_storage_factory_builder.go
pkg/kubeapiserver/default_storage_factory_builder.go
+2
-12
BUILD
pkg/kubeapiserver/options/BUILD
+0
-5
options.go
pkg/kubeapiserver/options/options.go
+2
-0
storage_versions.go
pkg/kubeapiserver/options/storage_versions.go
+0
-124
storage_versions_test.go
pkg/kubeapiserver/options/storage_versions_test.go
+0
-73
BUILD
pkg/master/BUILD
+0
-8
master_test.go
pkg/master/master_test.go
+0
-20
helpers.go
...src/k8s.io/apiserver/pkg/server/resourceconfig/helpers.go
+0
-12
resource_encoding_config.go
.../apiserver/pkg/server/storage/resource_encoding_config.go
+19
-54
BUILD
test/integration/framework/BUILD
+0
-1
master_utils.go
test/integration/framework/master_utils.go
+0
-4
No files found.
cmd/kube-apiserver/app/options/BUILD
View file @
0ae81c98
...
...
@@ -45,7 +45,6 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/kubeapiserver/options:go_default_library",
"//pkg/kubelet/client:go_default_library",
...
...
cmd/kube-apiserver/app/options/options.go
View file @
0ae81c98
...
...
@@ -47,7 +47,6 @@ type ServerRunOptions struct {
Authentication
*
kubeoptions
.
BuiltInAuthenticationOptions
Authorization
*
kubeoptions
.
BuiltInAuthorizationOptions
CloudProvider
*
kubeoptions
.
CloudProviderOptions
StorageSerialization
*
kubeoptions
.
StorageSerializationOptions
APIEnablement
*
genericoptions
.
APIEnablementOptions
AllowPrivileged
bool
...
...
@@ -87,7 +86,6 @@ func NewServerRunOptions() *ServerRunOptions {
Authentication
:
kubeoptions
.
NewBuiltInAuthenticationOptions
()
.
WithAll
(),
Authorization
:
kubeoptions
.
NewBuiltInAuthorizationOptions
(),
CloudProvider
:
kubeoptions
.
NewCloudProviderOptions
(),
StorageSerialization
:
kubeoptions
.
NewStorageSerializationOptions
(),
APIEnablement
:
genericoptions
.
NewAPIEnablementOptions
(),
EnableLogsHandler
:
true
,
...
...
@@ -135,7 +133,6 @@ func (s *ServerRunOptions) Flags() (fss apiserverflag.NamedFlagSets) {
s
.
Authentication
.
AddFlags
(
fss
.
FlagSet
(
"authentication"
))
s
.
Authorization
.
AddFlags
(
fss
.
FlagSet
(
"authorization"
))
s
.
CloudProvider
.
AddFlags
(
fss
.
FlagSet
(
"cloud provider"
))
s
.
StorageSerialization
.
AddFlags
(
fss
.
FlagSet
(
"storage"
))
s
.
APIEnablement
.
AddFlags
(
fss
.
FlagSet
(
"api enablement"
))
s
.
Admission
.
AddFlags
(
fss
.
FlagSet
(
"admission"
))
...
...
cmd/kube-apiserver/app/options/options_test.go
View file @
0ae81c98
...
...
@@ -32,7 +32,6 @@ import (
auditdynamic
"k8s.io/apiserver/plugin/pkg/audit/dynamic"
audittruncate
"k8s.io/apiserver/plugin/pkg/audit/truncate"
restclient
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api/legacyscheme"
kapi
"k8s.io/kubernetes/pkg/apis/core"
kubeoptions
"k8s.io/kubernetes/pkg/kubeapiserver/options"
kubeletclient
"k8s.io/kubernetes/pkg/kubelet/client"
...
...
@@ -288,10 +287,6 @@ func TestAddFlags(t *testing.T) {
CloudConfigFile
:
"/cloud-config"
,
CloudProvider
:
"azure"
,
},
StorageSerialization
:
&
kubeoptions
.
StorageSerializationOptions
{
StorageVersions
:
kubeoptions
.
ToPreferredVersionString
(
legacyscheme
.
Scheme
.
PreferredVersionAllGroups
()),
DefaultStorageVersions
:
kubeoptions
.
ToPreferredVersionString
(
legacyscheme
.
Scheme
.
PreferredVersionAllGroups
()),
},
APIEnablement
:
&
apiserveroptions
.
APIEnablementOptions
{
RuntimeConfig
:
utilflag
.
ConfigurationMap
{},
},
...
...
cmd/kube-apiserver/app/server.go
View file @
0ae81c98
...
...
@@ -415,7 +415,7 @@ func buildGenericConfig(
storageFactoryConfig
:=
kubeapiserver
.
NewStorageFactoryConfig
()
storageFactoryConfig
.
ApiResourceConfig
=
genericConfig
.
MergedResourceConfig
completedStorageFactoryConfig
,
err
:=
storageFactoryConfig
.
Complete
(
s
.
Etcd
,
s
.
StorageSerialization
)
completedStorageFactoryConfig
,
err
:=
storageFactoryConfig
.
Complete
(
s
.
Etcd
)
if
err
!=
nil
{
lastErr
=
err
return
...
...
hack/jenkins/test-dockerized.sh
View file @
0ae81c98
...
...
@@ -56,4 +56,3 @@ go install ./cmd/...
make test-cmd
make test-integration
./hack/test-update-storage-objects.sh
pkg/kubeapiserver/BUILD
View file @
0ae81c98
...
...
@@ -22,7 +22,6 @@ go_library(
"//pkg/apis/networking:go_default_library",
"//pkg/apis/policy:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/kubeapiserver/options:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/server/options:go_default_library",
...
...
pkg/kubeapiserver/default_storage_factory_builder.go
View file @
0ae81c98
...
...
@@ -19,8 +19,6 @@ package kubeapiserver
import
(
"strings"
"fmt"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
serveroptions
"k8s.io/apiserver/pkg/server/options"
...
...
@@ -37,7 +35,6 @@ import (
"k8s.io/kubernetes/pkg/apis/networking"
"k8s.io/kubernetes/pkg/apis/policy"
apisstorage
"k8s.io/kubernetes/pkg/apis/storage"
kubeapiserveroptions
"k8s.io/kubernetes/pkg/kubeapiserver/options"
)
// SpecialDefaultResourcePrefixes are prefixes compiled into Kubernetes.
...
...
@@ -68,18 +65,12 @@ type StorageFactoryConfig struct {
DefaultResourceEncoding
*
serverstorage
.
DefaultResourceEncodingConfig
DefaultStorageMediaType
string
Serializer
runtime
.
StorageSerializer
StorageEncodingOverrides
map
[
string
]
schema
.
GroupVersion
ResourceEncodingOverrides
[]
schema
.
GroupVersionResource
EtcdServersOverrides
[]
string
EncryptionProviderConfigFilepath
string
}
func
(
c
*
StorageFactoryConfig
)
Complete
(
etcdOptions
*
serveroptions
.
EtcdOptions
,
serializationOptions
*
kubeapiserveroptions
.
StorageSerializationOptions
)
(
*
completedStorageFactoryConfig
,
error
)
{
storageGroupsToEncodingVersion
,
err
:=
serializationOptions
.
StorageGroupsToEncodingVersion
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error generating storage version map: %s"
,
err
)
}
c
.
StorageEncodingOverrides
=
storageGroupsToEncodingVersion
func
(
c
*
StorageFactoryConfig
)
Complete
(
etcdOptions
*
serveroptions
.
EtcdOptions
)
(
*
completedStorageFactoryConfig
,
error
)
{
c
.
StorageConfig
=
etcdOptions
.
StorageConfig
c
.
DefaultStorageMediaType
=
etcdOptions
.
DefaultStorageMediaType
c
.
EtcdServersOverrides
=
etcdOptions
.
EtcdServersOverrides
...
...
@@ -92,8 +83,7 @@ type completedStorageFactoryConfig struct {
}
func
(
c
*
completedStorageFactoryConfig
)
New
()
(
*
serverstorage
.
DefaultStorageFactory
,
error
)
{
resourceEncodingConfig
:=
resourceconfig
.
MergeGroupEncodingConfigs
(
c
.
DefaultResourceEncoding
,
c
.
StorageEncodingOverrides
)
resourceEncodingConfig
=
resourceconfig
.
MergeResourceEncodingConfigs
(
resourceEncodingConfig
,
c
.
ResourceEncodingOverrides
)
resourceEncodingConfig
:=
resourceconfig
.
MergeResourceEncodingConfigs
(
c
.
DefaultResourceEncoding
,
c
.
ResourceEncodingOverrides
)
storageFactory
:=
serverstorage
.
NewDefaultStorageFactory
(
c
.
StorageConfig
,
c
.
DefaultStorageMediaType
,
...
...
pkg/kubeapiserver/options/BUILD
View file @
0ae81c98
...
...
@@ -16,11 +16,9 @@ go_library(
"options.go",
"plugins.go",
"serving.go",
"storage_versions.go",
],
importpath = "k8s.io/kubernetes/pkg/kubeapiserver/options",
deps = [
"//pkg/api/legacyscheme:go_default_library",
"//pkg/cloudprovider/providers:go_default_library",
"//pkg/features:go_default_library",
"//pkg/kubeapiserver/authenticator:go_default_library",
...
...
@@ -54,7 +52,6 @@ go_library(
"//plugin/pkg/admission/storage/storageclass/setdefault:go_default_library",
"//plugin/pkg/admission/storage/storageobjectinuseprotection:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
...
...
@@ -92,13 +89,11 @@ go_test(
"admission_test.go",
"authentication_test.go",
"authorization_test.go",
"storage_versions_test.go",
],
embed = [":go_default_library"],
deps = [
"//pkg/kubeapiserver/authenticator:go_default_library",
"//pkg/kubeapiserver/authorizer/modes:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/authentication/authenticator:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/authentication/authenticatorfactory:go_default_library",
...
...
pkg/kubeapiserver/options/options.go
View file @
0ae81c98
...
...
@@ -27,3 +27,5 @@ var DefaultServiceNodePortRange = utilnet.PortRange{Base: 30000, Size: 2768}
// DefaultServiceIPCIDR is a CIDR notation of IP range from which to allocate service cluster IPs
var
DefaultServiceIPCIDR
net
.
IPNet
=
net
.
IPNet
{
IP
:
net
.
ParseIP
(
"10.0.0.0"
),
Mask
:
net
.
CIDRMask
(
24
,
32
)}
const
DefaultEtcdPathPrefix
=
"/registry"
pkg/kubeapiserver/options/storage_versions.go
deleted
100644 → 0
View file @
ee734d05
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
options
import
(
"sort"
"strings"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api/legacyscheme"
)
const
(
DefaultEtcdPathPrefix
=
"/registry"
)
// StorageSerializationOptions contains the options for encoding resources.
type
StorageSerializationOptions
struct
{
StorageVersions
string
// The default values for StorageVersions. StorageVersions overrides
// these; you can change this if you want to change the defaults (e.g.,
// for testing). This is not actually exposed as a flag.
DefaultStorageVersions
string
}
func
NewStorageSerializationOptions
()
*
StorageSerializationOptions
{
return
&
StorageSerializationOptions
{
DefaultStorageVersions
:
ToPreferredVersionString
(
legacyscheme
.
Scheme
.
PreferredVersionAllGroups
()),
StorageVersions
:
ToPreferredVersionString
(
legacyscheme
.
Scheme
.
PreferredVersionAllGroups
()),
}
}
// StorageGroupsToEncodingVersion returns a map from group name to group version,
// computed from s.StorageVersions flag.
func
(
s
*
StorageSerializationOptions
)
StorageGroupsToEncodingVersion
()
(
map
[
string
]
schema
.
GroupVersion
,
error
)
{
storageVersionMap
:=
map
[
string
]
schema
.
GroupVersion
{}
// First, get the defaults.
if
err
:=
mergeGroupVersionIntoMap
(
s
.
DefaultStorageVersions
,
storageVersionMap
);
err
!=
nil
{
return
nil
,
err
}
// Override any defaults with the user settings.
if
err
:=
mergeGroupVersionIntoMap
(
s
.
StorageVersions
,
storageVersionMap
);
err
!=
nil
{
return
nil
,
err
}
return
storageVersionMap
,
nil
}
// dest must be a map of group to groupVersion.
func
mergeGroupVersionIntoMap
(
gvList
string
,
dest
map
[
string
]
schema
.
GroupVersion
)
error
{
for
_
,
gvString
:=
range
strings
.
Split
(
gvList
,
","
)
{
if
gvString
==
""
{
continue
}
// We accept two formats. "group/version" OR
// "group=group/version". The latter is used when types
// move between groups.
if
!
strings
.
Contains
(
gvString
,
"="
)
{
gv
,
err
:=
schema
.
ParseGroupVersion
(
gvString
)
if
err
!=
nil
{
return
err
}
dest
[
gv
.
Group
]
=
gv
}
else
{
parts
:=
strings
.
SplitN
(
gvString
,
"="
,
2
)
gv
,
err
:=
schema
.
ParseGroupVersion
(
parts
[
1
])
if
err
!=
nil
{
return
err
}
dest
[
parts
[
0
]]
=
gv
}
}
return
nil
}
// AddFlags adds flags for a specific APIServer to the specified FlagSet
func
(
s
*
StorageSerializationOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// arrange these text blocks sensibly. Grrr.
fs
.
StringVar
(
&
s
.
StorageVersions
,
"storage-versions"
,
s
.
StorageVersions
,
""
+
"The per-group version to store resources in. "
+
"Specified in the format
\"
group1/version1,group2/version2,...
\"
. "
+
"In the case where objects are moved from one group to the other, "
+
"you may specify the format
\"
group1=group2/v1beta1,group3/v1beta1,...
\"
. "
+
"You only need to pass the groups you wish to change from the defaults. "
+
"It defaults to a list of preferred versions of all known groups."
)
fs
.
MarkDeprecated
(
"storage-versions"
,
""
+
"Please omit this flag to ensure the default storage versions are used ."
+
"Otherwise the cluster is not safe to upgrade to a version newer than 1.12. "
+
"This flag will be removed in 1.13."
)
}
// ToPreferredVersionString returns the preferred versions of all registered
// groups in the form of "group1/version1,group2/version2,...". This is compatible
// with the flag format
func
ToPreferredVersionString
(
versions
[]
schema
.
GroupVersion
)
string
{
var
defaults
[]
string
for
_
,
version
:=
range
versions
{
defaults
=
append
(
defaults
,
version
.
String
())
}
// sorting provides stable output for help.
sort
.
Strings
(
defaults
)
return
strings
.
Join
(
defaults
,
","
)
}
pkg/kubeapiserver/options/storage_versions_test.go
deleted
100644 → 0
View file @
ee734d05
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
options
import
(
"reflect"
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
)
func
TestGenerateStorageVersionMap
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
storageVersions
string
defaultVersions
string
expectedMap
map
[
string
]
schema
.
GroupVersion
}{
{
storageVersions
:
"v1,extensions/v1beta1"
,
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
""
:
{
Version
:
"v1"
},
"extensions"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
},
},
{
storageVersions
:
"extensions/v1beta1,v1"
,
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
""
:
{
Version
:
"v1"
},
"extensions"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
},
},
{
storageVersions
:
"autoscaling=extensions/v1beta1,v1"
,
defaultVersions
:
"extensions/v1beta1,v1,autoscaling/v1"
,
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{
""
:
{
Version
:
"v1"
},
"autoscaling"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
"extensions"
:
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
},
},
{
storageVersions
:
""
,
expectedMap
:
map
[
string
]
schema
.
GroupVersion
{},
},
}
for
i
,
test
:=
range
testCases
{
s
:=
&
StorageSerializationOptions
{
StorageVersions
:
test
.
storageVersions
,
DefaultStorageVersions
:
test
.
defaultVersions
,
}
output
,
err
:=
s
.
StorageGroupsToEncodingVersion
()
if
err
!=
nil
{
t
.
Errorf
(
"%v: unexpected error: %v"
,
i
,
err
)
}
if
!
reflect
.
DeepEqual
(
test
.
expectedMap
,
output
)
{
t
.
Errorf
(
"%v: unexpected error. expect: %v, got: %v"
,
i
,
test
.
expectedMap
,
output
)
}
}
}
pkg/master/BUILD
View file @
0ae81c98
...
...
@@ -134,14 +134,7 @@ go_test(
deps = [
"//pkg/api/legacyscheme:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/apis/apps:go_default_library",
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/certificates:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/rbac:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/generated/openapi:go_default_library",
"//pkg/kubelet/client:go_default_library",
"//pkg/master/reconcilers:go_default_library",
...
...
@@ -154,7 +147,6 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/api/apitesting/naming:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
...
...
pkg/master/master_test.go
View file @
0ae81c98
...
...
@@ -31,8 +31,6 @@ import (
certificatesapiv1beta1
"k8s.io/api/certificates/v1beta1"
apiv1
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
utilnet
"k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/version"
...
...
@@ -46,14 +44,7 @@ import (
restclient
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/certificates"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/apis/storage"
kubeletclient
"k8s.io/kubernetes/pkg/kubelet/client"
"k8s.io/kubernetes/pkg/master/reconcilers"
certificatesrest
"k8s.io/kubernetes/pkg/registry/certificates/rest"
...
...
@@ -79,17 +70,6 @@ func setUp(t *testing.T) (*etcdtesting.EtcdTestServer, Config, *assert.Assertion
}
resourceEncoding
:=
serverstorage
.
NewDefaultResourceEncodingConfig
(
legacyscheme
.
Scheme
)
resourceEncoding
.
SetVersionEncoding
(
api
.
GroupName
,
schema
.
GroupVersion
{
Group
:
""
,
Version
:
"v1"
},
schema
.
GroupVersion
{
Group
:
api
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
autoscaling
.
GroupName
,
schema
.
GroupVersion
{
Group
:
"autoscaling"
,
Version
:
"v1"
},
schema
.
GroupVersion
{
Group
:
autoscaling
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
batch
.
GroupName
,
schema
.
GroupVersion
{
Group
:
"batch"
,
Version
:
"v1"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
// FIXME (soltysh): this GroupVersionResource override should be configurable
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
"batch"
,
Resource
:
"cronjobs"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
"storage.k8s.io"
,
Resource
:
"volumeattachments"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
apps
.
GroupName
,
schema
.
GroupVersion
{
Group
:
"apps"
,
Version
:
"v1"
},
schema
.
GroupVersion
{
Group
:
apps
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
extensions
.
GroupName
,
schema
.
GroupVersion
{
Group
:
"extensions"
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
extensions
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
rbac
.
GroupName
,
schema
.
GroupVersion
{
Group
:
"rbac.authorization.k8s.io"
,
Version
:
"v1"
},
schema
.
GroupVersion
{
Group
:
rbac
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
certificates
.
GroupName
,
schema
.
GroupVersion
{
Group
:
"certificates.k8s.io"
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
certificates
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
storageFactory
:=
serverstorage
.
NewDefaultStorageFactory
(
*
storageConfig
,
testapi
.
StorageMediaType
(),
legacyscheme
.
Codecs
,
resourceEncoding
,
DefaultAPIResourceConfigSource
(),
nil
)
etcdOptions
:=
options
.
NewEtcdOptions
(
storageConfig
)
...
...
staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers.go
View file @
0ae81c98
...
...
@@ -51,18 +51,6 @@ func MergeResourceEncodingConfigs(
return
resourceEncodingConfig
}
// MergeGroupEncodingConfigs merges the given defaultResourceConfig with specific GroupVersion overrides.
func
MergeGroupEncodingConfigs
(
defaultResourceEncoding
*
serverstore
.
DefaultResourceEncodingConfig
,
storageEncodingOverrides
map
[
string
]
schema
.
GroupVersion
,
)
*
serverstore
.
DefaultResourceEncodingConfig
{
resourceEncodingConfig
:=
defaultResourceEncoding
for
group
,
storageEncodingVersion
:=
range
storageEncodingOverrides
{
resourceEncodingConfig
.
SetVersionEncoding
(
group
,
storageEncodingVersion
,
schema
.
GroupVersion
{
Group
:
group
,
Version
:
runtime
.
APIVersionInternal
})
}
return
resourceEncodingConfig
}
// MergeAPIResourceConfigs merges the given defaultAPIResourceConfig with the given resourceConfigOverrides.
// Exclude the groups not registered in registry, and check if version is
// not registered in group, then it will fail.
...
...
staging/src/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go
View file @
0ae81c98
...
...
@@ -34,50 +34,27 @@ type ResourceEncodingConfig interface {
}
type
DefaultResourceEncodingConfig
struct
{
groups
map
[
string
]
*
GroupResourceEncodingConfig
scheme
*
runtime
.
Scheme
// resources records the overriding encoding configs for individual resources.
resources
map
[
schema
.
GroupResource
]
*
OverridingResourceEncoding
scheme
*
runtime
.
Scheme
}
type
GroupResourceEncodingConfig
struct
{
DefaultExternalEncoding
schema
.
GroupVersion
ExternalResourceEncodings
map
[
string
]
schema
.
GroupVersion
DefaultInternalEncoding
schema
.
GroupVersion
InternalResourceEncodings
map
[
string
]
schema
.
GroupVersion
type
OverridingResourceEncoding
struct
{
ExternalResourceEncoding
schema
.
GroupVersion
InternalResourceEncoding
schema
.
GroupVersion
}
var
_
ResourceEncodingConfig
=
&
DefaultResourceEncodingConfig
{}
func
NewDefaultResourceEncodingConfig
(
scheme
*
runtime
.
Scheme
)
*
DefaultResourceEncodingConfig
{
return
&
DefaultResourceEncodingConfig
{
groups
:
map
[
string
]
*
GroupResourceEncodingConfig
{},
scheme
:
scheme
}
}
func
newGroupResourceEncodingConfig
(
defaultEncoding
,
defaultInternalVersion
schema
.
GroupVersion
)
*
GroupResourceEncodingConfig
{
return
&
GroupResourceEncodingConfig
{
DefaultExternalEncoding
:
defaultEncoding
,
ExternalResourceEncodings
:
map
[
string
]
schema
.
GroupVersion
{},
DefaultInternalEncoding
:
defaultInternalVersion
,
InternalResourceEncodings
:
map
[
string
]
schema
.
GroupVersion
{},
}
}
func
(
o
*
DefaultResourceEncodingConfig
)
SetVersionEncoding
(
group
string
,
externalEncodingVersion
,
internalVersion
schema
.
GroupVersion
)
{
_
,
groupExists
:=
o
.
groups
[
group
]
if
!
groupExists
{
o
.
groups
[
group
]
=
newGroupResourceEncodingConfig
(
externalEncodingVersion
,
internalVersion
)
}
o
.
groups
[
group
]
.
DefaultExternalEncoding
=
externalEncodingVersion
o
.
groups
[
group
]
.
DefaultInternalEncoding
=
internalVersion
return
&
DefaultResourceEncodingConfig
{
resources
:
map
[
schema
.
GroupResource
]
*
OverridingResourceEncoding
{},
scheme
:
scheme
}
}
func
(
o
*
DefaultResourceEncodingConfig
)
SetResourceEncoding
(
resourceBeingStored
schema
.
GroupResource
,
externalEncodingVersion
,
internalVersion
schema
.
GroupVersion
)
{
group
:=
resourceBeingStored
.
Group
_
,
groupExists
:=
o
.
groups
[
group
]
if
!
groupExists
{
o
.
groups
[
group
]
=
newGroupResourceEncodingConfig
(
externalEncodingVersion
,
internalVersion
)
o
.
resources
[
resourceBeingStored
]
=
&
OverridingResourceEncoding
{
ExternalResourceEncoding
:
externalEncodingVersion
,
InternalResourceEncoding
:
internalVersion
,
}
o
.
groups
[
group
]
.
ExternalResourceEncodings
[
resourceBeingStored
.
Resource
]
=
externalEncodingVersion
o
.
groups
[
group
]
.
InternalResourceEncodings
[
resourceBeingStored
.
Resource
]
=
internalVersion
}
func
(
o
*
DefaultResourceEncodingConfig
)
StorageEncodingFor
(
resource
schema
.
GroupResource
)
(
schema
.
GroupVersion
,
error
)
{
...
...
@@ -85,19 +62,13 @@ func (o *DefaultResourceEncodingConfig) StorageEncodingFor(resource schema.Group
return
schema
.
GroupVersion
{},
fmt
.
Errorf
(
"group %q is not registered in scheme"
,
resource
.
Group
)
}
groupEncoding
,
groupExists
:=
o
.
groups
[
resource
.
Group
]
if
!
groupExists
{
// return the most preferred external version for the group
return
o
.
scheme
.
PrioritizedVersionsForGroup
(
resource
.
Group
)[
0
],
nil
}
resourceOverride
,
resourceExists
:=
groupEncoding
.
ExternalResourceEncodings
[
resource
.
Resource
]
if
!
resourceExists
{
return
groupEncoding
.
DefaultExternalEncoding
,
nil
resourceOverride
,
resourceExists
:=
o
.
resources
[
resource
]
if
resourceExists
{
return
resourceOverride
.
ExternalResourceEncoding
,
nil
}
return
resourceOverride
,
nil
// return the most preferred external version for the group
return
o
.
scheme
.
PrioritizedVersionsForGroup
(
resource
.
Group
)[
0
],
nil
}
func
(
o
*
DefaultResourceEncodingConfig
)
InMemoryEncodingFor
(
resource
schema
.
GroupResource
)
(
schema
.
GroupVersion
,
error
)
{
...
...
@@ -105,15 +76,9 @@ func (o *DefaultResourceEncodingConfig) InMemoryEncodingFor(resource schema.Grou
return
schema
.
GroupVersion
{},
fmt
.
Errorf
(
"group %q is not registered in scheme"
,
resource
.
Group
)
}
groupEncoding
,
groupExists
:=
o
.
groups
[
resource
.
Group
]
if
!
group
Exists
{
return
schema
.
GroupVersion
{
Group
:
resource
.
Group
,
Version
:
runtime
.
APIVersionInternal
}
,
nil
resourceOverride
,
resourceExists
:=
o
.
resources
[
resource
]
if
resource
Exists
{
return
resourceOverride
.
InternalResourceEncoding
,
nil
}
resourceOverride
,
resourceExists
:=
groupEncoding
.
InternalResourceEncodings
[
resource
.
Resource
]
if
!
resourceExists
{
return
groupEncoding
.
DefaultInternalEncoding
,
nil
}
return
resourceOverride
,
nil
return
schema
.
GroupVersion
{
Group
:
resource
.
Group
,
Version
:
runtime
.
APIVersionInternal
},
nil
}
test/integration/framework/BUILD
View file @
0ae81c98
...
...
@@ -24,7 +24,6 @@ go_library(
"//cmd/kube-apiserver/app/options:go_default_library",
"//cmd/kubeadm/app/util/pkiutil:go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/policy/v1beta1:go_default_library",
"//pkg/generated/openapi:go_default_library",
...
...
test/integration/framework/master_utils.go
View file @
0ae81c98
...
...
@@ -56,7 +56,6 @@ import (
"k8s.io/klog"
openapicommon
"k8s.io/kube-openapi/pkg/common"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/apis/batch"
policy
"k8s.io/kubernetes/pkg/apis/policy/v1beta1"
"k8s.io/kubernetes/pkg/generated/openapi"
...
...
@@ -263,11 +262,8 @@ func NewMasterConfig() *master.Config {
resourceEncoding
:=
serverstorage
.
NewDefaultResourceEncodingConfig
(
legacyscheme
.
Scheme
)
// FIXME (soltysh): this GroupVersionResource override should be configurable
// we need to set both for the whole group and for cronjobs, separately
resourceEncoding
.
SetVersionEncoding
(
batch
.
GroupName
,
*
testapi
.
Batch
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
batch
.
GroupName
,
Resource
:
"cronjobs"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
// we also need to set both for the storage group and for volumeattachments, separately
resourceEncoding
.
SetVersionEncoding
(
storage
.
GroupName
,
*
testapi
.
Storage
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
storage
.
GroupName
,
Resource
:
"volumeattachments"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
storageFactory
:=
serverstorage
.
NewDefaultStorageFactory
(
etcdOptions
.
StorageConfig
,
runtime
.
ContentTypeJSON
,
ns
,
resourceEncoding
,
master
.
DefaultAPIResourceConfigSource
(),
nil
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment