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
32b78aeb
Unverified
Commit
32b78aeb
authored
Aug 02, 2017
by
Mikhail Mazurskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to IsControlledBy from meta/v1 package
parent
042b5642
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
17 deletions
+13
-17
daemon_controller.go
pkg/controller/daemon/daemon_controller.go
+1
-1
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+2
-4
controller_history_test.go
pkg/controller/history/controller_history_test.go
+5
-6
history.go
pkg/kubectl/history.go
+3
-4
daemon_set.go
test/e2e/apps/daemon_set.go
+2
-2
No files found.
pkg/controller/daemon/daemon_controller.go
View file @
32b78aeb
...
...
@@ -1068,7 +1068,7 @@ func (dsc *DaemonSetsController) simulate(newPod *v1.Pod, node *v1.Node, ds *ext
}
// ignore pods that belong to the daemonset when taking into account whether
// a daemonset should bind to a node.
if
controllerRef
:=
metav1
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
&&
controllerRef
.
UID
==
ds
.
UID
{
if
metav1
.
IsControlledBy
(
pod
,
ds
)
{
continue
}
pods
=
append
(
pods
,
pod
)
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
32b78aeb
...
...
@@ -579,8 +579,7 @@ func ListReplicaSets(deployment *extensions.Deployment, getRSList RsListFunc) ([
// Only include those whose ControllerRef matches the Deployment.
owned
:=
make
([]
*
extensions
.
ReplicaSet
,
0
,
len
(
all
))
for
_
,
rs
:=
range
all
{
controllerRef
:=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
!=
nil
&&
controllerRef
.
UID
==
deployment
.
UID
{
if
metav1
.
IsControlledBy
(
rs
,
deployment
)
{
owned
=
append
(
owned
,
rs
)
}
}
...
...
@@ -603,8 +602,7 @@ func ListReplicaSetsInternal(deployment *internalextensions.Deployment, getRSLis
// Only include those whose ControllerRef matches the Deployment.
filtered
:=
make
([]
*
internalextensions
.
ReplicaSet
,
0
,
len
(
all
))
for
_
,
rs
:=
range
all
{
controllerRef
:=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
!=
nil
&&
controllerRef
.
UID
==
deployment
.
UID
{
if
metav1
.
IsControlledBy
(
rs
,
deployment
)
{
filtered
=
append
(
filtered
,
rs
)
}
}
...
...
pkg/controller/history/controller_history_test.go
View file @
32b78aeb
...
...
@@ -992,7 +992,7 @@ func TestRealHistory_AdoptControllerRevision(t *testing.T) {
if
!
test
.
err
&&
err
!=
nil
{
t
.
Errorf
(
"%s: %s"
,
test
.
name
,
err
)
}
if
!
test
.
err
&&
metav1
.
GetControllerOf
(
adopted
)
.
UID
!=
test
.
parent
.
GetUID
(
)
{
if
!
test
.
err
&&
!
metav1
.
IsControlledBy
(
adopted
,
test
.
parent
)
{
t
.
Errorf
(
"%s: adoption failed"
,
test
.
name
)
}
if
test
.
err
&&
err
==
nil
{
...
...
@@ -1103,7 +1103,7 @@ func TestFakeHistory_AdoptControllerRevision(t *testing.T) {
if
!
test
.
err
&&
err
!=
nil
{
t
.
Errorf
(
"%s: %s"
,
test
.
name
,
err
)
}
if
!
test
.
err
&&
metav1
.
GetControllerOf
(
adopted
)
.
UID
!=
test
.
parent
.
GetUID
(
)
{
if
!
test
.
err
&&
!
metav1
.
IsControlledBy
(
adopted
,
test
.
parent
)
{
t
.
Errorf
(
"%s: adoption failed"
,
test
.
name
)
}
if
test
.
err
&&
err
==
nil
{
...
...
@@ -1211,8 +1211,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
if
found
==
nil
{
return
true
,
nil
,
errors
.
NewNotFound
(
apps
.
Resource
(
"controllerrevisions"
),
test
.
revision
.
Name
)
}
if
foundParent
:=
metav1
.
GetControllerOf
(
test
.
revision
);
foundParent
==
nil
||
foundParent
.
UID
!=
test
.
parent
.
GetUID
()
{
if
!
metav1
.
IsControlledBy
(
test
.
revision
,
test
.
parent
)
{
return
true
,
nil
,
errors
.
NewInvalid
(
test
.
revision
.
GroupVersionKind
()
.
GroupKind
(),
test
.
revision
.
Name
,
nil
)
}
...
...
@@ -1258,7 +1257,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
if
adopted
==
nil
{
return
}
if
owner
:=
metav1
.
GetControllerOf
(
adopted
);
owner
!=
nil
&&
owner
.
UID
==
test
.
parent
.
GetUID
(
)
{
if
metav1
.
IsControlledBy
(
adopted
,
test
.
parent
)
{
t
.
Errorf
(
"%s: release failed"
,
test
.
name
)
}
}
...
...
@@ -1386,7 +1385,7 @@ func TestFakeHistory_ReleaseControllerRevision(t *testing.T) {
if
adopted
==
nil
{
return
}
if
owner
:=
metav1
.
GetControllerOf
(
adopted
);
owner
!=
nil
&&
owner
.
UID
==
test
.
parent
.
GetUID
(
)
{
if
metav1
.
IsControlledBy
(
adopted
,
test
.
parent
)
{
t
.
Errorf
(
"%s: release failed"
,
test
.
name
)
}
}
...
...
pkg/kubectl/history.go
View file @
32b78aeb
...
...
@@ -271,11 +271,10 @@ func controlledHistories(c externalclientset.Interface, namespace, name string)
}
for
i
:=
range
historyList
.
Items
{
history
:=
historyList
.
Items
[
i
]
//
Skip history that doesn't belong
to the DaemonSet
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
history
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
continue
//
Only add history that belongs
to the DaemonSet
if
metav1
.
IsControlledBy
(
&
history
,
ds
)
{
result
=
append
(
result
,
&
history
)
}
result
=
append
(
result
,
&
history
)
}
return
ds
,
result
,
nil
}
...
...
test/e2e/apps/daemon_set.go
View file @
32b78aeb
...
...
@@ -630,7 +630,7 @@ func checkDaemonPodOnNodes(f *framework.Framework, ds *extensions.DaemonSet, nod
nodesToPodCount
:=
make
(
map
[
string
]
int
)
for
_
,
pod
:=
range
pods
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
if
!
metav1
.
IsControlledBy
(
&
pod
,
ds
)
{
continue
}
if
pod
.
DeletionTimestamp
!=
nil
{
...
...
@@ -726,7 +726,7 @@ func checkDaemonPodsImageAndAvailability(c clientset.Interface, ds *extensions.D
unavailablePods
:=
0
allImagesUpdated
:=
true
for
_
,
pod
:=
range
pods
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
if
!
metav1
.
IsControlledBy
(
&
pod
,
ds
)
{
continue
}
podImage
:=
pod
.
Spec
.
Containers
[
0
]
.
Image
...
...
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