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
cda3f18b
Commit
cda3f18b
authored
Mar 26, 2018
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused Deployment util functions
parent
647d8d8a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
66 deletions
+0
-66
BUILD
pkg/controller/deployment/util/BUILD
+0
-1
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+0
-54
replicaset_util.go
pkg/controller/deployment/util/replicaset_util.go
+0
-11
No files found.
pkg/controller/deployment/util/BUILD
View file @
cda3f18b
...
...
@@ -29,7 +29,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/extensions/v1beta1:go_default_library",
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
cda3f18b
...
...
@@ -32,13 +32,9 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/errors"
intstrutil
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/wait"
clientset
"k8s.io/client-go/kubernetes"
extensionsv1beta1
"k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
corelisters
"k8s.io/client-go/listers/core/v1"
extensionslisters
"k8s.io/client-go/listers/extensions/v1beta1"
"k8s.io/client-go/util/integer"
internalextensions
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/controller"
...
...
@@ -677,56 +673,6 @@ func FindOldReplicaSets(deployment *extensions.Deployment, rsList []*extensions.
return
requiredRSs
,
allRSs
}
// WaitForReplicaSetUpdated polls the replica set until it is updated.
func
WaitForReplicaSetUpdated
(
c
extensionslisters
.
ReplicaSetLister
,
desiredGeneration
int64
,
namespace
,
name
string
)
error
{
return
wait
.
PollImmediate
(
1
*
time
.
Second
,
1
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
rs
,
err
:=
c
.
ReplicaSets
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
return
false
,
err
}
return
rs
.
Status
.
ObservedGeneration
>=
desiredGeneration
,
nil
})
}
// WaitForPodsHashPopulated polls the replica set until updated and fully labeled.
func
WaitForPodsHashPopulated
(
c
extensionslisters
.
ReplicaSetLister
,
desiredGeneration
int64
,
namespace
,
name
string
)
error
{
return
wait
.
PollImmediate
(
1
*
time
.
Second
,
1
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
rs
,
err
:=
c
.
ReplicaSets
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
return
false
,
err
}
return
rs
.
Status
.
ObservedGeneration
>=
desiredGeneration
&&
rs
.
Status
.
FullyLabeledReplicas
==
*
(
rs
.
Spec
.
Replicas
),
nil
})
}
// LabelPodsWithHash labels all pods in the given podList with the new hash label.
func
LabelPodsWithHash
(
podList
*
v1
.
PodList
,
c
clientset
.
Interface
,
podLister
corelisters
.
PodLister
,
namespace
,
name
,
hash
string
)
error
{
for
_
,
pod
:=
range
podList
.
Items
{
// Ignore inactive Pods.
if
!
controller
.
IsPodActive
(
&
pod
)
{
continue
}
// Only label the pod that doesn't already have the new hash
if
pod
.
Labels
[
extensions
.
DefaultDeploymentUniqueLabelKey
]
!=
hash
{
_
,
err
:=
UpdatePodWithRetries
(
c
.
CoreV1
()
.
Pods
(
namespace
),
podLister
,
pod
.
Namespace
,
pod
.
Name
,
func
(
podToUpdate
*
v1
.
Pod
)
error
{
// Precondition: the pod doesn't contain the new hash in its label.
if
podToUpdate
.
Labels
[
extensions
.
DefaultDeploymentUniqueLabelKey
]
==
hash
{
return
errors
.
ErrPreconditionViolated
}
podToUpdate
.
Labels
=
labelsutil
.
AddLabel
(
podToUpdate
.
Labels
,
extensions
.
DefaultDeploymentUniqueLabelKey
,
hash
)
return
nil
})
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error in adding template hash label %s to pod %q: %v"
,
hash
,
pod
.
Name
,
err
)
}
glog
.
V
(
4
)
.
Infof
(
"Labeled pod %s/%s of ReplicaSet %s/%s with hash %s."
,
pod
.
Namespace
,
pod
.
Name
,
namespace
,
name
,
hash
)
}
}
return
nil
}
// 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/replicaset_util.go
View file @
cda3f18b
...
...
@@ -17,8 +17,6 @@ limitations under the License.
package
util
import
(
"fmt"
"github.com/golang/glog"
extensions
"k8s.io/api/extensions/v1beta1"
...
...
@@ -26,8 +24,6 @@ import (
unversionedextensions
"k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
extensionslisters
"k8s.io/client-go/listers/extensions/v1beta1"
"k8s.io/client-go/util/retry"
"k8s.io/kubernetes/pkg/controller"
labelsutil
"k8s.io/kubernetes/pkg/util/labels"
)
// TODO: use client library instead when it starts to support update retries
...
...
@@ -62,10 +58,3 @@ func UpdateRSWithRetries(rsClient unversionedextensions.ReplicaSetInterface, rsL
return
rs
,
retryErr
}
// GetReplicaSetHash returns the pod template hash of a ReplicaSet's pod template space
func
GetReplicaSetHash
(
rs
*
extensions
.
ReplicaSet
,
uniquifier
*
int32
)
(
string
,
error
)
{
rsTemplate
:=
rs
.
Spec
.
Template
.
DeepCopy
()
rsTemplate
.
Labels
=
labelsutil
.
CloneAndRemoveLabel
(
rsTemplate
.
Labels
,
extensions
.
DefaultDeploymentUniqueLabelKey
)
return
fmt
.
Sprintf
(
"%d"
,
controller
.
ComputeHash
(
rsTemplate
,
uniquifier
)),
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