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
4f84a1cb
Commit
4f84a1cb
authored
Feb 09, 2018
by
Ayush Pateria
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass pod labels to controller revision
parent
8de89d9f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
30 deletions
+4
-30
controller_history.go
pkg/controller/history/controller_history.go
+2
-30
controller_history_test.go
pkg/controller/history/controller_history_test.go
+0
-0
stateful_set_utils.go
pkg/controller/statefulset/stateful_set_utils.go
+2
-0
No files found.
pkg/controller/history/controller_history.go
View file @
4f84a1cb
...
@@ -18,7 +18,6 @@ package history
...
@@ -18,7 +18,6 @@ package history
import
(
import
(
"bytes"
"bytes"
"encoding/json"
"fmt"
"fmt"
"hash/fnv"
"hash/fnv"
"sort"
"sort"
...
@@ -63,11 +62,12 @@ func ControllerRevisionName(prefix string, hash uint32) string {
...
@@ -63,11 +62,12 @@ func ControllerRevisionName(prefix string, hash uint32) string {
// returned error is not nil, the returned ControllerRevision is invalid for use.
// returned error is not nil, the returned ControllerRevision is invalid for use.
func
NewControllerRevision
(
parent
metav1
.
Object
,
func
NewControllerRevision
(
parent
metav1
.
Object
,
parentKind
schema
.
GroupVersionKind
,
parentKind
schema
.
GroupVersionKind
,
podLabels
map
[
string
]
string
,
selector
labels
.
Selector
,
selector
labels
.
Selector
,
data
runtime
.
RawExtension
,
data
runtime
.
RawExtension
,
revision
int64
,
revision
int64
,
collisionCount
*
int32
)
(
*
apps
.
ControllerRevision
,
error
)
{
collisionCount
*
int32
)
(
*
apps
.
ControllerRevision
,
error
)
{
labelMap
:=
getPodLabelsFromData
(
data
)
labelMap
:=
podLabels
blockOwnerDeletion
:=
true
blockOwnerDeletion
:=
true
isController
:=
true
isController
:=
true
cr
:=
&
apps
.
ControllerRevision
{
cr
:=
&
apps
.
ControllerRevision
{
...
@@ -452,31 +452,3 @@ func (fh *fakeHistory) ReleaseControllerRevision(parent metav1.Object, revision
...
@@ -452,31 +452,3 @@ func (fh *fakeHistory) ReleaseControllerRevision(parent metav1.Object, revision
}
}
return
clone
,
fh
.
indexer
.
Update
(
clone
)
return
clone
,
fh
.
indexer
.
Update
(
clone
)
}
}
func
getPodLabelsFromData
(
data
runtime
.
RawExtension
)
map
[
string
]
string
{
var
dat
map
[
string
]
interface
{}
labelMap
:=
make
(
map
[
string
]
string
)
if
err
:=
json
.
Unmarshal
(
data
.
Raw
,
&
dat
);
err
!=
nil
{
return
labelMap
}
spec
,
ok
:=
dat
[
"spec"
]
.
(
map
[
string
]
interface
{})
if
!
ok
{
return
labelMap
}
template
,
ok
:=
spec
[
"template"
]
.
(
map
[
string
]
interface
{})
if
!
ok
{
return
labelMap
}
metadata
,
ok
:=
template
[
"metadata"
]
.
(
map
[
string
]
interface
{})
if
!
ok
{
return
labelMap
}
labels
,
ok
:=
metadata
[
"labels"
]
.
(
map
[
string
]
interface
{})
if
!
ok
{
return
labelMap
}
for
key
,
value
:=
range
labels
{
labelMap
[
key
]
=
value
.
(
string
)
}
return
labelMap
}
pkg/controller/history/controller_history_test.go
View file @
4f84a1cb
This diff is collapsed.
Click to expand it.
pkg/controller/statefulset/stateful_set_utils.go
View file @
4f84a1cb
...
@@ -316,8 +316,10 @@ func newRevision(set *apps.StatefulSet, revision int64, collisionCount *int32) (
...
@@ -316,8 +316,10 @@ func newRevision(set *apps.StatefulSet, revision int64, collisionCount *int32) (
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
podLabels
:=
set
.
Spec
.
Template
.
Labels
cr
,
err
:=
history
.
NewControllerRevision
(
set
,
cr
,
err
:=
history
.
NewControllerRevision
(
set
,
controllerKind
,
controllerKind
,
podLabels
,
selector
,
selector
,
runtime
.
RawExtension
{
Raw
:
patch
},
runtime
.
RawExtension
{
Raw
:
patch
},
revision
,
revision
,
...
...
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