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
283211c1
Unverified
Commit
283211c1
authored
Jul 19, 2017
by
Anthony Yeh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StatefulSet: Remove `pod.alpha.kubernetes.io/initialized` annotation.
parent
48e83706
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
113 deletions
+2
-113
stateful_set_control_test.go
pkg/controller/statefulset/stateful_set_control_test.go
+0
-78
stateful_set_utils.go
pkg/controller/statefulset/stateful_set_utils.go
+2
-21
stateful_set_utils_test.go
pkg/controller/statefulset/stateful_set_utils_test.go
+0
-12
types.go
staging/src/k8s.io/api/apps/v1beta1/types.go
+0
-2
No files found.
pkg/controller/statefulset/stateful_set_control_test.go
View file @
283211c1
...
...
@@ -85,7 +85,6 @@ func TestStatefulSetControl(t *testing.T) {
{
ScalesDown
,
simpleSetFn
},
{
ReplacesPods
,
largeSetFn
},
{
RecreatesFailedPod
,
simpleSetFn
},
{
SetsInitAnnotation
,
simpleSetFn
},
{
CreatePodFailure
,
simpleSetFn
},
{
UpdatePodFailure
,
simpleSetFn
},
{
UpdateSetStatusFailure
,
simpleSetFn
},
...
...
@@ -279,59 +278,6 @@ func RecreatesFailedPod(t *testing.T, set *apps.StatefulSet, invariants invarian
}
}
func
SetsInitAnnotation
(
t
*
testing
.
T
,
set
*
apps
.
StatefulSet
,
invariants
invariantFunc
)
{
client
:=
fake
.
NewSimpleClientset
(
set
)
spc
,
_
,
ssc
,
stop
:=
setupController
(
client
)
defer
close
(
stop
)
selector
,
err
:=
metav1
.
LabelSelectorAsSelector
(
set
.
Spec
.
Selector
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
pods
,
err
:=
spc
.
podsLister
.
Pods
(
set
.
Namespace
)
.
List
(
selector
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
=
ssc
.
UpdateStatefulSet
(
set
,
pods
);
err
!=
nil
{
t
.
Errorf
(
"Error updating StatefulSet %s"
,
err
)
}
if
err
=
invariants
(
set
,
spc
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
pods
,
err
=
spc
.
setPodRunning
(
set
,
0
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
pods
,
err
=
spc
.
setPodReady
(
set
,
0
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
pods
,
err
=
spc
.
setPodInitStatus
(
set
,
0
,
false
);
err
!=
nil
{
t
.
Error
(
err
)
}
replicas
:=
int
(
set
.
Status
.
Replicas
)
if
err
:=
ssc
.
UpdateStatefulSet
(
set
,
pods
);
err
!=
nil
{
t
.
Errorf
(
"Error updating StatefulSet %s"
,
err
)
}
if
err
:=
invariants
(
set
,
spc
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
replicas
!=
int
(
set
.
Status
.
Replicas
)
{
t
.
Errorf
(
"StatefulSetControl does not block on %s=false"
,
apps
.
StatefulSetInitAnnotation
)
}
if
pods
,
err
=
spc
.
setPodInitStatus
(
set
,
0
,
true
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
:=
scaleUpStatefulSetControl
(
set
,
ssc
,
spc
,
invariants
);
err
!=
nil
{
t
.
Errorf
(
"Failed to turn up StatefulSet : %s"
,
err
)
}
set
,
err
=
spc
.
setsLister
.
StatefulSets
(
set
.
Namespace
)
.
Get
(
set
.
Name
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error getting updated StatefulSet: %v"
,
err
)
}
if
int
(
set
.
Status
.
Replicas
)
!=
3
{
t
.
Errorf
(
"StatefulSetControl does not unblock on %s=true"
,
apps
.
StatefulSetInitAnnotation
)
}
}
func
CreatePodFailure
(
t
*
testing
.
T
,
set
*
apps
.
StatefulSet
,
invariants
invariantFunc
)
{
client
:=
fake
.
NewSimpleClientset
(
set
)
spc
,
_
,
ssc
,
stop
:=
setupController
(
client
)
...
...
@@ -1673,30 +1619,6 @@ func (spc *fakeStatefulPodControl) setPodReady(set *apps.StatefulSet, ordinal in
return
spc
.
podsLister
.
Pods
(
set
.
Namespace
)
.
List
(
selector
)
}
func
(
spc
*
fakeStatefulPodControl
)
setPodInitStatus
(
set
*
apps
.
StatefulSet
,
ordinal
int
,
init
bool
)
([]
*
v1
.
Pod
,
error
)
{
selector
,
err
:=
metav1
.
LabelSelectorAsSelector
(
set
.
Spec
.
Selector
)
if
err
!=
nil
{
return
nil
,
err
}
pods
,
err
:=
spc
.
podsLister
.
Pods
(
set
.
Namespace
)
.
List
(
selector
)
if
err
!=
nil
{
return
nil
,
err
}
if
0
>
ordinal
||
ordinal
>=
len
(
pods
)
{
return
nil
,
fmt
.
Errorf
(
"ordinal %d out of range [0,%d)"
,
ordinal
,
len
(
pods
))
}
sort
.
Sort
(
ascendingOrdinal
(
pods
))
pod
:=
copyPod
(
pods
[
ordinal
])
if
init
{
pod
.
Annotations
[
apps
.
StatefulSetInitAnnotation
]
=
"true"
}
else
{
pod
.
Annotations
[
apps
.
StatefulSetInitAnnotation
]
=
"false"
}
fakeResourceVersion
(
pod
)
spc
.
podsIndexer
.
Update
(
pod
)
return
spc
.
podsLister
.
Pods
(
set
.
Namespace
)
.
List
(
selector
)
}
func
(
spc
*
fakeStatefulPodControl
)
addTerminatingPod
(
set
*
apps
.
StatefulSet
,
ordinal
int
)
([]
*
v1
.
Pod
,
error
)
{
pod
:=
newStatefulSetPod
(
set
,
ordinal
)
pod
.
Status
.
Phase
=
v1
.
PodRunning
...
...
pkg/controller/statefulset/stateful_set_utils.go
View file @
283211c1
...
...
@@ -31,8 +31,6 @@ import (
podutil
"k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/history"
"github.com/golang/glog"
)
// maxUpdateRetries is the maximum number of retries used for update conflict resolution prior to failure
...
...
@@ -191,26 +189,9 @@ func updateIdentity(set *apps.StatefulSet, pod *v1.Pod) {
pod
.
Spec
.
Subdomain
=
set
.
Spec
.
ServiceName
}
// isRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady, and if the init
// annotation has not explicitly disabled the Pod from being ready.
// isRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady.
func
isRunningAndReady
(
pod
*
v1
.
Pod
)
bool
{
if
pod
.
Status
.
Phase
!=
v1
.
PodRunning
{
return
false
}
podReady
:=
podutil
.
IsPodReady
(
pod
)
// User may have specified a pod readiness override through a debug annotation.
initialized
,
ok
:=
pod
.
Annotations
[
apps
.
StatefulSetInitAnnotation
]
if
ok
{
if
initAnnotation
,
err
:=
strconv
.
ParseBool
(
initialized
);
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"Failed to parse %v annotation on pod %v: %v"
,
apps
.
StatefulSetInitAnnotation
,
pod
.
Name
,
err
)
}
else
if
!
initAnnotation
{
glog
.
V
(
4
)
.
Infof
(
"StatefulSet pod %v waiting on annotation %v"
,
pod
.
Name
,
apps
.
StatefulSetInitAnnotation
)
podReady
=
initAnnotation
}
}
return
podReady
return
pod
.
Status
.
Phase
==
v1
.
PodRunning
&&
podutil
.
IsPodReady
(
pod
)
}
// isCreated returns true if pod has been created and is maintained by the API server
...
...
pkg/controller/statefulset/stateful_set_utils_test.go
View file @
283211c1
...
...
@@ -213,18 +213,6 @@ func TestIsRunningAndReady(t *testing.T) {
if
!
isRunningAndReady
(
pod
)
{
t
.
Error
(
"Pod should be running and ready"
)
}
pod
.
Annotations
[
apps
.
StatefulSetInitAnnotation
]
=
"true"
if
!
isRunningAndReady
(
pod
)
{
t
.
Error
(
"isRunningAndReady does not respected init annotation set to true"
)
}
pod
.
Annotations
[
apps
.
StatefulSetInitAnnotation
]
=
"false"
if
isRunningAndReady
(
pod
)
{
t
.
Error
(
"isRunningAndReady does not respected init annotation set to false"
)
}
pod
.
Annotations
[
apps
.
StatefulSetInitAnnotation
]
=
"blah"
if
!
isRunningAndReady
(
pod
)
{
t
.
Error
(
"isRunningAndReady does not erroneous init annotation"
)
}
}
func
TestAscendingOrdinal
(
t
*
testing
.
T
)
{
...
...
staging/src/k8s.io/api/apps/v1beta1/types.go
View file @
283211c1
...
...
@@ -24,8 +24,6 @@ import (
)
const
(
// StatefulSetInitAnnotation if present, and set to false, indicates that a Pod's readiness should be ignored.
StatefulSetInitAnnotation
=
"pod.alpha.kubernetes.io/initialized"
ControllerRevisionHashLabelKey
=
"controller-revision-hash"
StatefulSetRevisionLabel
=
ControllerRevisionHashLabelKey
)
...
...
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