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
02d980b2
Commit
02d980b2
authored
Jul 21, 2018
by
fisherxu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up unused code
parent
819604e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
168 deletions
+1
-168
BUILD
pkg/controller/deployment/util/BUILD
+1
-11
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+0
-37
pod_util.go
pkg/controller/deployment/util/pod_util.go
+0
-60
replicaset_util.go
pkg/controller/deployment/util/replicaset_util.go
+0
-60
No files found.
pkg/controller/deployment/util/BUILD
View file @
02d980b2
...
...
@@ -8,14 +8,9 @@ load(
go_library(
name = "go_default_library",
srcs = [
"deployment_util.go",
"pod_util.go",
"replicaset_util.go",
],
srcs = ["deployment_util.go"],
importpath = "k8s.io/kubernetes/pkg/controller/deployment/util",
deps = [
"//pkg/apis/extensions:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/util/labels:go_default_library",
"//staging/src/k8s.io/api/apps/v1:go_default_library",
...
...
@@ -25,15 +20,10 @@ go_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/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/apps/v1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/listers/apps/v1:go_default_library",
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/util/integer:go_default_library",
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
],
)
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
02d980b2
...
...
@@ -36,7 +36,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
appsclient
"k8s.io/client-go/kubernetes/typed/apps/v1"
"k8s.io/client-go/util/integer"
internalextensions
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/controller"
labelsutil
"k8s.io/kubernetes/pkg/util/labels"
)
...
...
@@ -575,29 +574,6 @@ func ListReplicaSets(deployment *apps.Deployment, getRSList RsListFunc) ([]*apps
return
owned
,
nil
}
// ListReplicaSetsInternal is ListReplicaSets for internalextensions.
// TODO: Remove the duplicate when call sites are updated to ListReplicaSets.
func
ListReplicaSetsInternal
(
deployment
*
internalextensions
.
Deployment
,
getRSList
func
(
string
,
metav1
.
ListOptions
)
([]
*
internalextensions
.
ReplicaSet
,
error
))
([]
*
internalextensions
.
ReplicaSet
,
error
)
{
namespace
:=
deployment
.
Namespace
selector
,
err
:=
metav1
.
LabelSelectorAsSelector
(
deployment
.
Spec
.
Selector
)
if
err
!=
nil
{
return
nil
,
err
}
options
:=
metav1
.
ListOptions
{
LabelSelector
:
selector
.
String
()}
all
,
err
:=
getRSList
(
namespace
,
options
)
if
err
!=
nil
{
return
nil
,
err
}
// Only include those whose ControllerRef matches the Deployment.
filtered
:=
make
([]
*
internalextensions
.
ReplicaSet
,
0
,
len
(
all
))
for
_
,
rs
:=
range
all
{
if
metav1
.
IsControlledBy
(
rs
,
deployment
)
{
filtered
=
append
(
filtered
,
rs
)
}
}
return
filtered
,
nil
}
// ListPods returns a list of pods the given deployment targets.
// This needs a list of ReplicaSets for the Deployment,
// which can be found with ListReplicaSets().
...
...
@@ -876,19 +852,6 @@ func WaitForObservedDeployment(getDeploymentFunc func() (*apps.Deployment, error
})
}
// TODO: remove the duplicate
// WaitForObservedInternalDeployment polls for deployment to be updated so that deployment.Status.ObservedGeneration >= desiredGeneration.
// Returns error if polling timesout.
func
WaitForObservedDeploymentInternal
(
getDeploymentFunc
func
()
(
*
internalextensions
.
Deployment
,
error
),
desiredGeneration
int64
,
interval
,
timeout
time
.
Duration
)
error
{
return
wait
.
Poll
(
interval
,
timeout
,
func
()
(
bool
,
error
)
{
deployment
,
err
:=
getDeploymentFunc
()
if
err
!=
nil
{
return
false
,
err
}
return
deployment
.
Status
.
ObservedGeneration
>=
desiredGeneration
,
nil
})
}
// ResolveFenceposts resolves both maxSurge and maxUnavailable. This needs to happen in one
// step. For example:
//
...
...
pkg/controller/deployment/util/pod_util.go
deleted
100644 → 0
View file @
819604e2
/*
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
util
import
(
"github.com/golang/glog"
"k8s.io/api/core/v1"
errorsutil
"k8s.io/apimachinery/pkg/util/errors"
v1core
"k8s.io/client-go/kubernetes/typed/core/v1"
corelisters
"k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/util/retry"
)
// TODO: use client library instead when it starts to support update retries
// see https://github.com/kubernetes/kubernetes/issues/21479
type
updatePodFunc
func
(
pod
*
v1
.
Pod
)
error
// UpdatePodWithRetries updates a pod with given applyUpdate function.
func
UpdatePodWithRetries
(
podClient
v1core
.
PodInterface
,
podLister
corelisters
.
PodLister
,
namespace
,
name
string
,
applyUpdate
updatePodFunc
)
(
*
v1
.
Pod
,
error
)
{
var
pod
*
v1
.
Pod
retryErr
:=
retry
.
RetryOnConflict
(
retry
.
DefaultBackoff
,
func
()
error
{
var
err
error
pod
,
err
=
podLister
.
Pods
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
return
err
}
pod
=
pod
.
DeepCopy
()
// Apply the update, then attempt to push it to the apiserver.
if
applyErr
:=
applyUpdate
(
pod
);
applyErr
!=
nil
{
return
applyErr
}
pod
,
err
=
podClient
.
Update
(
pod
)
return
err
})
// Ignore the precondition violated error, this pod is already updated
// with the desired label.
if
retryErr
==
errorsutil
.
ErrPreconditionViolated
{
glog
.
V
(
4
)
.
Infof
(
"Pod %s/%s precondition doesn't hold, skip updating it."
,
namespace
,
name
)
retryErr
=
nil
}
return
pod
,
retryErr
}
pkg/controller/deployment/util/replicaset_util.go
deleted
100644 → 0
View file @
819604e2
/*
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
util
import
(
"github.com/golang/glog"
apps
"k8s.io/api/apps/v1"
errorsutil
"k8s.io/apimachinery/pkg/util/errors"
appsclient
"k8s.io/client-go/kubernetes/typed/apps/v1"
appslisters
"k8s.io/client-go/listers/apps/v1"
"k8s.io/client-go/util/retry"
)
// TODO: use client library instead when it starts to support update retries
// see https://github.com/kubernetes/kubernetes/issues/21479
type
updateRSFunc
func
(
rs
*
apps
.
ReplicaSet
)
error
// UpdateRSWithRetries updates a RS with given applyUpdate function. Note that RS not found error is ignored.
// The returned bool value can be used to tell if the RS is actually updated.
func
UpdateRSWithRetries
(
rsClient
appsclient
.
ReplicaSetInterface
,
rsLister
appslisters
.
ReplicaSetLister
,
namespace
,
name
string
,
applyUpdate
updateRSFunc
)
(
*
apps
.
ReplicaSet
,
error
)
{
var
rs
*
apps
.
ReplicaSet
retryErr
:=
retry
.
RetryOnConflict
(
retry
.
DefaultBackoff
,
func
()
error
{
var
err
error
rs
,
err
=
rsLister
.
ReplicaSets
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
return
err
}
rs
=
rs
.
DeepCopy
()
// Apply the update, then attempt to push it to the apiserver.
if
applyErr
:=
applyUpdate
(
rs
);
applyErr
!=
nil
{
return
applyErr
}
rs
,
err
=
rsClient
.
Update
(
rs
)
return
err
})
// Ignore the precondition violated error, but the RS isn't updated.
if
retryErr
==
errorsutil
.
ErrPreconditionViolated
{
glog
.
V
(
4
)
.
Infof
(
"Replica set %s/%s precondition doesn't hold, skip updating it."
,
namespace
,
name
)
retryErr
=
nil
}
return
rs
,
retryErr
}
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