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
89fd3b0e
Commit
89fd3b0e
authored
Aug 07, 2017
by
Yinan Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy annotations from StatefulSet to ControllerRevisions it owns
parent
fddc7f3e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
stateful_set_utils.go
pkg/controller/statefulset/stateful_set_utils.go
+11
-1
stateful_set_utils_test.go
pkg/controller/statefulset/stateful_set_utils_test.go
+13
-0
No files found.
pkg/controller/statefulset/stateful_set_utils.go
View file @
89fd3b0e
...
@@ -311,11 +311,21 @@ func newRevision(set *apps.StatefulSet, revision int64) (*apps.ControllerRevisio
...
@@ -311,11 +311,21 @@ func newRevision(set *apps.StatefulSet, revision int64) (*apps.ControllerRevisio
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
history
.
NewControllerRevision
(
set
,
cr
,
err
:=
history
.
NewControllerRevision
(
set
,
controllerKind
,
controllerKind
,
selector
,
selector
,
runtime
.
RawExtension
{
Raw
:
patch
},
runtime
.
RawExtension
{
Raw
:
patch
},
revision
)
revision
)
if
err
!=
nil
{
return
nil
,
err
}
if
cr
.
ObjectMeta
.
Annotations
==
nil
{
cr
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
for
key
,
value
:=
range
set
.
Annotations
{
cr
.
ObjectMeta
.
Annotations
[
key
]
=
value
}
return
cr
,
nil
}
}
// applyRevision returns a new StatefulSet constructed by restoring the state in revision to set. If the returned error
// applyRevision returns a new StatefulSet constructed by restoring the state in revision to set. If the returned error
...
...
pkg/controller/statefulset/stateful_set_utils_test.go
View file @
89fd3b0e
...
@@ -280,6 +280,12 @@ func TestCreateApplyRevision(t *testing.T) {
...
@@ -280,6 +280,12 @@ func TestCreateApplyRevision(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
set
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Name
=
"foo"
set
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Name
=
"foo"
if
set
.
Annotations
==
nil
{
set
.
Annotations
=
make
(
map
[
string
]
string
)
}
key
:=
"foo"
expectedValue
:=
"bar"
set
.
Annotations
[
key
]
=
expectedValue
restoredSet
,
err
:=
applyRevision
(
set
,
revision
)
restoredSet
,
err
:=
applyRevision
(
set
,
revision
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
@@ -291,6 +297,13 @@ func TestCreateApplyRevision(t *testing.T) {
...
@@ -291,6 +297,13 @@ func TestCreateApplyRevision(t *testing.T) {
if
!
history
.
EqualRevision
(
revision
,
restoredRevision
)
{
if
!
history
.
EqualRevision
(
revision
,
restoredRevision
)
{
t
.
Errorf
(
"wanted %v got %v"
,
string
(
revision
.
Data
.
Raw
),
string
(
restoredRevision
.
Data
.
Raw
))
t
.
Errorf
(
"wanted %v got %v"
,
string
(
revision
.
Data
.
Raw
),
string
(
restoredRevision
.
Data
.
Raw
))
}
}
value
,
ok
:=
restoredRevision
.
Annotations
[
key
]
if
!
ok
{
t
.
Errorf
(
"missing annotation %s"
,
key
)
}
if
value
!=
expectedValue
{
t
.
Errorf
(
"for annotation %s wanted %s got %s"
,
key
,
expectedValue
,
value
)
}
}
}
func
newPVC
(
name
string
)
v1
.
PersistentVolumeClaim
{
func
newPVC
(
name
string
)
v1
.
PersistentVolumeClaim
{
...
...
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