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
a593ab80
Commit
a593ab80
authored
Apr 06, 2019
by
Darren Shepherd
Committed by
root
Jun 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove StorageVersionHash
parent
c05674e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
82 deletions
+1
-82
customresource_discovery_controller.go
...rver/pkg/apiserver/customresource_discovery_controller.go
+0
-5
storageversionhash.go
...o/apiserver/pkg/endpoints/discovery/storageversionhash.go
+0
-40
installer.go
staging/src/k8s.io/apiserver/pkg/endpoints/installer.go
+1
-29
kube_features.go
staging/src/k8s.io/apiserver/pkg/features/kube_features.go
+0
-8
No files found.
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_discovery_controller.go
View file @
a593ab80
...
@@ -95,7 +95,6 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
...
@@ -95,7 +95,6 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
}
}
foundThisVersion
:=
false
foundThisVersion
:=
false
var
storageVersionHash
string
for
_
,
v
:=
range
crd
.
Spec
.
Versions
{
for
_
,
v
:=
range
crd
.
Spec
.
Versions
{
if
!
v
.
Served
{
if
!
v
.
Served
{
continue
continue
...
@@ -114,9 +113,6 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
...
@@ -114,9 +113,6 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
if
v
.
Name
==
version
.
Version
{
if
v
.
Name
==
version
.
Version
{
foundThisVersion
=
true
foundThisVersion
=
true
}
}
if
v
.
Storage
{
storageVersionHash
=
discovery
.
StorageVersionHash
(
gv
.
Group
,
gv
.
Version
,
crd
.
Spec
.
Names
.
Kind
)
}
}
}
if
!
foundThisVersion
{
if
!
foundThisVersion
{
...
@@ -138,7 +134,6 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
...
@@ -138,7 +134,6 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
Verbs
:
verbs
,
Verbs
:
verbs
,
ShortNames
:
crd
.
Status
.
AcceptedNames
.
ShortNames
,
ShortNames
:
crd
.
Status
.
AcceptedNames
.
ShortNames
,
Categories
:
crd
.
Status
.
AcceptedNames
.
Categories
,
Categories
:
crd
.
Status
.
AcceptedNames
.
Categories
,
StorageVersionHash
:
storageVersionHash
,
})
})
subresources
,
err
:=
apiextensions
.
GetSubresourcesForVersion
(
crd
,
version
.
Version
)
subresources
,
err
:=
apiextensions
.
GetSubresourcesForVersion
(
crd
,
version
.
Version
)
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/discovery/storageversionhash.go
deleted
100644 → 0
View file @
c05674e7
/*
Copyright 2019 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
discovery
import
(
"crypto/sha256"
"encoding/base64"
)
// StorageVersionHash calculates the storage version hash for a
// <group/version/kind> tuple.
// WARNING: this function is subject to change. Clients shouldn't depend on
// this function.
func
StorageVersionHash
(
group
,
version
,
kind
string
)
string
{
gvk
:=
group
+
"/"
+
version
+
"/"
+
kind
if
gvk
==
""
{
return
""
}
bytes
:=
sha256
.
Sum256
([]
byte
(
gvk
))
// Assuming there are N kinds in the cluster, and the hash is X-byte long,
// the chance of colliding hash P(N,X) approximates to 1-e^(-(N^2)/2^(8X+1)).
// P(10,000, 8) ~= 2.7*10^(-12), which is low enough.
// See https://en.wikipedia.org/wiki/Birthday_problem#Approximations.
return
base64
.
StdEncoding
.
EncodeToString
(
bytes
[
:
8
])
}
staging/src/k8s.io/apiserver/pkg/endpoints/installer.go
View file @
a593ab80
...
@@ -26,20 +26,17 @@ import (
...
@@ -26,20 +26,17 @@ import (
"time"
"time"
"unicode"
"unicode"
restful
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/endpoints/discovery"
"k8s.io/apiserver/pkg/endpoints/handlers"
"k8s.io/apiserver/pkg/endpoints/handlers"
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
"k8s.io/apiserver/pkg/endpoints/metrics"
"k8s.io/apiserver/pkg/endpoints/metrics"
"k8s.io/apiserver/pkg/features"
"k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/registry/rest"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
)
)
const
(
const
(
...
@@ -131,20 +128,6 @@ func (a *APIInstaller) newWebService() *restful.WebService {
...
@@ -131,20 +128,6 @@ func (a *APIInstaller) newWebService() *restful.WebService {
return
ws
return
ws
}
}
// calculate the storage gvk, the gvk objects are converted to before persisted to the etcd.
func
getStorageVersionKind
(
storageVersioner
runtime
.
GroupVersioner
,
storage
rest
.
Storage
,
typer
runtime
.
ObjectTyper
)
(
schema
.
GroupVersionKind
,
error
)
{
object
:=
storage
.
New
()
fqKinds
,
_
,
err
:=
typer
.
ObjectKinds
(
object
)
if
err
!=
nil
{
return
schema
.
GroupVersionKind
{},
err
}
gvk
,
ok
:=
storageVersioner
.
KindForGroupVersionKinds
(
fqKinds
)
if
!
ok
{
return
schema
.
GroupVersionKind
{},
fmt
.
Errorf
(
"cannot find the storage version kind for %v"
,
reflect
.
TypeOf
(
object
))
}
return
gvk
,
nil
}
// GetResourceKind returns the external group version kind registered for the given storage
// GetResourceKind returns the external group version kind registered for the given storage
// object. If the storage object is a subresource and has an override supplied for it, it returns
// object. If the storage object is a subresource and has an override supplied for it, it returns
// the group version kind supplied in the override.
// the group version kind supplied in the override.
...
@@ -239,7 +222,6 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
...
@@ -239,7 +222,6 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
watcher
,
isWatcher
:=
storage
.
(
rest
.
Watcher
)
watcher
,
isWatcher
:=
storage
.
(
rest
.
Watcher
)
connecter
,
isConnecter
:=
storage
.
(
rest
.
Connecter
)
connecter
,
isConnecter
:=
storage
.
(
rest
.
Connecter
)
storageMeta
,
isMetadata
:=
storage
.
(
rest
.
StorageMetadata
)
storageMeta
,
isMetadata
:=
storage
.
(
rest
.
StorageMetadata
)
storageVersionProvider
,
isStorageVersionProvider
:=
storage
.
(
rest
.
StorageVersionProvider
)
if
!
isMetadata
{
if
!
isMetadata
{
storageMeta
=
defaultStorageMetadata
{}
storageMeta
=
defaultStorageMetadata
{}
}
}
...
@@ -378,16 +360,6 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
...
@@ -378,16 +360,6 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
tableProvider
,
_
:=
storage
.
(
rest
.
TableConvertor
)
tableProvider
,
_
:=
storage
.
(
rest
.
TableConvertor
)
var
apiResource
metav1
.
APIResource
var
apiResource
metav1
.
APIResource
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageVersionHash
)
&&
isStorageVersionProvider
&&
storageVersionProvider
.
StorageVersion
()
!=
nil
{
versioner
:=
storageVersionProvider
.
StorageVersion
()
gvk
,
err
:=
getStorageVersionKind
(
versioner
,
storage
,
a
.
group
.
Typer
)
if
err
!=
nil
{
return
nil
,
err
}
apiResource
.
StorageVersionHash
=
discovery
.
StorageVersionHash
(
gvk
.
Group
,
gvk
.
Version
,
gvk
.
Kind
)
}
// Get the list of actions for the given scope.
// Get the list of actions for the given scope.
switch
{
switch
{
...
...
staging/src/k8s.io/apiserver/pkg/features/kube_features.go
View file @
a593ab80
...
@@ -70,13 +70,6 @@ const (
...
@@ -70,13 +70,6 @@ const (
// committing.
// committing.
DryRun
utilfeature
.
Feature
=
"DryRun"
DryRun
utilfeature
.
Feature
=
"DryRun"
// owner: @caesarxuchao
// alpha: v1.14
//
// Allow apiservers to expose the storage version hash in the discovery
// document.
StorageVersionHash
utilfeature
.
Feature
=
"StorageVersionHash"
// owner: @ksubrmnn
// owner: @ksubrmnn
// alpha: v1.14
// alpha: v1.14
//
//
...
@@ -103,7 +96,6 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
...
@@ -103,7 +96,6 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
AdvancedAuditing
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
GA
},
AdvancedAuditing
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
GA
},
APIListChunking
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
APIListChunking
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
DryRun
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
DryRun
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
StorageVersionHash
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
WinOverlay
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
WinOverlay
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
WinDSR
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
WinDSR
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
}
}
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