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
fcf68ba7
Unverified
Commit
fcf68ba7
authored
Apr 21, 2017
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove obsolete deployment helpers
Signed-off-by:
Michail Kargakis
<
mkargaki@redhat.com
>
parent
4aa8b1a6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
85 deletions
+13
-85
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+0
-25
hash_test.go
pkg/controller/deployment/util/hash_test.go
+10
-24
pod_util.go
pkg/controller/deployment/util/pod_util.go
+0
-14
replicaset_util.go
pkg/controller/deployment/util/replicaset_util.go
+0
-10
stop_test.go
pkg/kubectl/stop_test.go
+3
-12
No files found.
pkg/controller/deployment/util/deployment_util.go
View file @
fcf68ba7
...
...
@@ -746,31 +746,6 @@ func LabelPodsWithHash(podList *v1.PodList, c clientset.Interface, podLister cor
return
nil
}
// GetNewReplicaSetTemplate returns the desired PodTemplateSpec for the new ReplicaSet corresponding to the given ReplicaSet.
// Callers of this helper need to set the DefaultDeploymentUniqueLabelKey k/v pair.
func
GetNewReplicaSetTemplate
(
deployment
*
extensions
.
Deployment
)
v1
.
PodTemplateSpec
{
// newRS will have the same template as in deployment spec.
return
v1
.
PodTemplateSpec
{
ObjectMeta
:
deployment
.
Spec
.
Template
.
ObjectMeta
,
Spec
:
deployment
.
Spec
.
Template
.
Spec
,
}
}
// TODO: remove the duplicate
// GetNewReplicaSetTemplateInternal returns the desired PodTemplateSpec for the new ReplicaSet corresponding to the given ReplicaSet.
func
GetNewReplicaSetTemplateInternal
(
deployment
*
internalextensions
.
Deployment
)
api
.
PodTemplateSpec
{
// newRS will have the same template as in deployment spec, plus a unique label in some cases.
newRSTemplate
:=
api
.
PodTemplateSpec
{
ObjectMeta
:
deployment
.
Spec
.
Template
.
ObjectMeta
,
Spec
:
deployment
.
Spec
.
Template
.
Spec
,
}
newRSTemplate
.
ObjectMeta
.
Labels
=
labelsutil
.
CloneAndAddLabel
(
deployment
.
Spec
.
Template
.
ObjectMeta
.
Labels
,
internalextensions
.
DefaultDeploymentUniqueLabelKey
,
fmt
.
Sprintf
(
"%d"
,
GetInternalPodTemplateSpecHash
(
newRSTemplate
)))
return
newRSTemplate
}
// SetFromReplicaSetTemplate sets the desired PodTemplateSpec from a replica set template to the given deployment.
func
SetFromReplicaSetTemplate
(
deployment
*
extensions
.
Deployment
,
template
v1
.
PodTemplateSpec
)
*
extensions
.
Deployment
{
deployment
.
Spec
.
Template
.
ObjectMeta
=
template
.
ObjectMeta
...
...
pkg/controller/deployment/util/hash_test.go
View file @
fcf68ba7
...
...
@@ -18,11 +18,13 @@ package util
import
(
"encoding/json"
"hash/adler32"
"strconv"
"strings"
"testing"
"k8s.io/kubernetes/pkg/api/v1"
hashutil
"k8s.io/kubernetes/pkg/util/hash"
)
var
podSpec
string
=
`
...
...
@@ -103,7 +105,6 @@ var podSpec string = `
func
TestPodTemplateSpecHash
(
t
*
testing
.
T
)
{
seenHashes
:=
make
(
map
[
uint32
]
int
)
broken
:=
false
for
i
:=
0
;
i
<
1000
;
i
++
{
specJson
:=
strings
.
Replace
(
podSpec
,
"@@VERSION@@"
,
strconv
.
Itoa
(
i
),
1
)
...
...
@@ -111,27 +112,6 @@ func TestPodTemplateSpecHash(t *testing.T) {
json
.
Unmarshal
([]
byte
(
specJson
),
&
spec
)
hash
:=
GetPodTemplateSpecHash
(
spec
)
if
v
,
ok
:=
seenHashes
[
hash
];
ok
{
broken
=
true
t
.
Logf
(
"Hash collision, old: %d new: %d"
,
v
,
i
)
break
}
seenHashes
[
hash
]
=
i
}
if
!
broken
{
t
.
Errorf
(
"expected adler to break but it didn't"
)
}
}
func
TestPodTemplateSpecHashFnv
(
t
*
testing
.
T
)
{
seenHashes
:=
make
(
map
[
uint32
]
int
)
for
i
:=
0
;
i
<
1000
;
i
++
{
specJson
:=
strings
.
Replace
(
podSpec
,
"@@VERSION@@"
,
strconv
.
Itoa
(
i
),
1
)
spec
:=
v1
.
PodTemplateSpec
{}
json
.
Unmarshal
([]
byte
(
specJson
),
&
spec
)
hash
:=
GetPodTemplateSpecHashFnv
(
spec
)
if
v
,
ok
:=
seenHashes
[
hash
];
ok
{
t
.
Errorf
(
"Hash collision, old: %d new: %d"
,
v
,
i
)
break
}
...
...
@@ -144,15 +124,21 @@ func BenchmarkAdler(b *testing.B) {
json
.
Unmarshal
([]
byte
(
podSpec
),
&
spec
)
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
GetPodTemplateSpec
Hash
(
spec
)
getPodTemplateSpecOld
Hash
(
spec
)
}
}
func
getPodTemplateSpecOldHash
(
template
v1
.
PodTemplateSpec
)
uint32
{
podTemplateSpecHasher
:=
adler32
.
New
()
hashutil
.
DeepHashObject
(
podTemplateSpecHasher
,
template
)
return
podTemplateSpecHasher
.
Sum32
()
}
func
BenchmarkFnv
(
b
*
testing
.
B
)
{
spec
:=
v1
.
PodTemplateSpec
{}
json
.
Unmarshal
([]
byte
(
podSpec
),
&
spec
)
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
GetPodTemplateSpecHash
Fnv
(
spec
)
GetPodTemplateSpecHash
(
spec
)
}
}
pkg/controller/deployment/util/pod_util.go
View file @
fcf68ba7
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
util
import
(
"hash/adler32"
"hash/fnv"
"github.com/golang/glog"
...
...
@@ -32,19 +31,6 @@ import (
)
func
GetPodTemplateSpecHash
(
template
v1
.
PodTemplateSpec
)
uint32
{
podTemplateSpecHasher
:=
adler32
.
New
()
hashutil
.
DeepHashObject
(
podTemplateSpecHasher
,
template
)
return
podTemplateSpecHasher
.
Sum32
()
}
// TODO: remove the duplicate
func
GetInternalPodTemplateSpecHash
(
template
api
.
PodTemplateSpec
)
uint32
{
podTemplateSpecHasher
:=
adler32
.
New
()
hashutil
.
DeepHashObject
(
podTemplateSpecHasher
,
template
)
return
podTemplateSpecHasher
.
Sum32
()
}
func
GetPodTemplateSpecHashFnv
(
template
v1
.
PodTemplateSpec
)
uint32
{
podTemplateSpecHasher
:=
fnv
.
New32a
()
hashutil
.
DeepHashObject
(
podTemplateSpecHasher
,
template
)
return
podTemplateSpecHasher
.
Sum32
()
...
...
pkg/controller/deployment/util/replicaset_util.go
View file @
fcf68ba7
...
...
@@ -77,13 +77,3 @@ func GetReplicaSetHash(rs *extensions.ReplicaSet) string {
Spec
:
rs
.
Spec
.
Template
.
Spec
,
}))
}
// GetReplicaSetHashFnv returns the pod template hash of a ReplicaSet's pod template spec.
func
GetReplicaSetHashFnv
(
rs
*
extensions
.
ReplicaSet
)
string
{
meta
:=
rs
.
Spec
.
Template
.
ObjectMeta
meta
.
Labels
=
labelsutil
.
CloneAndRemoveLabel
(
meta
.
Labels
,
extensions
.
DefaultDeploymentUniqueLabelKey
)
return
fmt
.
Sprintf
(
"%d"
,
GetPodTemplateSpecHashFnv
(
v1
.
PodTemplateSpec
{
ObjectMeta
:
meta
,
Spec
:
rs
.
Spec
.
Template
.
Spec
,
}))
}
pkg/kubectl/stop_test.go
View file @
fcf68ba7
...
...
@@ -35,7 +35,6 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
coreclient
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
)
func
TestReplicationControllerStop
(
t
*
testing
.
T
)
{
...
...
@@ -441,7 +440,6 @@ func TestDeploymentStop(t *testing.T) {
Replicas
:
0
,
},
}
template
:=
deploymentutil
.
GetNewReplicaSetTemplateInternal
(
&
deployment
)
trueVar
:=
true
tests
:=
[]
struct
{
Name
string
...
...
@@ -492,9 +490,7 @@ func TestDeploymentStop(t *testing.T) {
},
},
},
Spec
:
extensions
.
ReplicaSetSpec
{
Template
:
template
,
},
Spec
:
extensions
.
ReplicaSetSpec
{},
},
// ReplicaSet owned by something else (should be ignored).
{
...
...
@@ -512,9 +508,7 @@ func TestDeploymentStop(t *testing.T) {
},
},
},
Spec
:
extensions
.
ReplicaSetSpec
{
Template
:
template
,
},
Spec
:
extensions
.
ReplicaSetSpec
{},
},
},
},
...
...
@@ -709,7 +703,6 @@ func TestDeploymentNotFoundError(t *testing.T) {
Replicas
:
0
,
},
}
template
:=
deploymentutil
.
GetNewReplicaSetTemplateInternal
(
deployment
)
fake
:=
fake
.
NewSimpleClientset
(
deployment
,
...
...
@@ -719,9 +712,7 @@ func TestDeploymentNotFoundError(t *testing.T) {
Name
:
name
,
Namespace
:
ns
,
},
Spec
:
extensions
.
ReplicaSetSpec
{
Template
:
template
,
},
Spec
:
extensions
.
ReplicaSetSpec
{},
},
},
},
...
...
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