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
620310c1
Commit
620310c1
authored
Feb 23, 2017
by
Łukasz Oleś
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move TemplateGeneration to the Spec
parent
b59ecde5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
19 deletions
+22
-19
types.go
pkg/apis/extensions/types.go
+5
-5
types.go
pkg/apis/extensions/v1beta1/types.go
+5
-5
validation.go
pkg/apis/extensions/validation/validation.go
+1
-0
daemoncontroller.go
pkg/controller/daemon/daemoncontroller.go
+2
-2
daemoncontroller_test.go
pkg/controller/daemon/daemoncontroller_test.go
+3
-3
update.go
pkg/controller/daemon/update.go
+1
-1
strategy.go
pkg/registry/extensions/daemonset/strategy.go
+5
-3
No files found.
pkg/apis/extensions/types.go
View file @
620310c1
...
...
@@ -441,6 +441,11 @@ type DaemonSetSpec struct {
// is ready).
// +optional
MinReadySeconds
int32
// A sequence number representing a specific generation of the template.
// Populated by the system. It can be set only during the creation.
// +optional
TemplateGeneration
int64
}
// DaemonSetStatus represents the current status of a daemon set.
...
...
@@ -505,11 +510,6 @@ type DaemonSet struct {
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
// +optional
Status
DaemonSetStatus
// A sequence number representing a specific generation of the template.
// Populated by the system. Read-only.
// +optional
TemplateGeneration
int64
}
const
(
...
...
pkg/apis/extensions/v1beta1/types.go
View file @
620310c1
...
...
@@ -440,6 +440,11 @@ type DaemonSetSpec struct {
// is ready).
// +optional
MinReadySeconds
int32
`json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`
// A sequence number representing a specific generation of the template.
// Populated by the system. It can be set only during the creation.
// +optional
TemplateGeneration
int64
`json:"templateGeneration,omitempty" protobuf:"varint,5,opt,name=templateGeneration"`
}
// DaemonSetStatus represents the current status of a daemon set.
...
...
@@ -507,11 +512,6 @@ type DaemonSet struct {
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
// +optional
Status
DaemonSetStatus
`json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
// A sequence number representing a specific generation of the template.
// Populated by the system. Read-only.
// +optional
TemplateGeneration
int64
`json:"templateGeneration,omitempty" protobuf:"varint,4,opt,name=templateGeneration"`
}
const
(
...
...
pkg/apis/extensions/validation/validation.go
View file @
620310c1
...
...
@@ -145,6 +145,7 @@ func ValidateDaemonSetSpec(spec *extensions.DaemonSetSpec, fldPath *field.Path)
allErrs
=
append
(
allErrs
,
field
.
NotSupported
(
fldPath
.
Child
(
"template"
,
"spec"
,
"restartPolicy"
),
spec
.
Template
.
Spec
.
RestartPolicy
,
[]
string
{
string
(
api
.
RestartPolicyAlways
)}))
}
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateNonnegativeField
(
int64
(
spec
.
MinReadySeconds
),
fldPath
.
Child
(
"minReadySeconds"
))
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateNonnegativeField
(
int64
(
spec
.
TemplateGeneration
),
fldPath
.
Child
(
"templateGeneration"
))
...
)
allErrs
=
append
(
allErrs
,
ValidateDaemonSetUpdateStrategy
(
&
spec
.
UpdateStrategy
,
fldPath
.
Child
(
"updateStrategy"
))
...
)
return
allErrs
...
...
pkg/controller/daemon/daemoncontroller.go
View file @
620310c1
...
...
@@ -576,7 +576,7 @@ func (dsc *DaemonSetsController) syncNodes(ds *extensions.DaemonSet, podsToDelet
glog
.
V
(
4
)
.
Infof
(
"Nodes needing daemon pods for daemon set %s: %+v, creating %d"
,
ds
.
Name
,
nodesNeedingDaemonPods
,
createDiff
)
createWait
:=
sync
.
WaitGroup
{}
createWait
.
Add
(
createDiff
)
template
:=
util
.
GetPodTemplateWithGeneration
(
ds
.
Spec
.
Template
,
ds
.
TemplateGeneration
)
template
:=
util
.
GetPodTemplateWithGeneration
(
ds
.
Spec
.
Template
,
ds
.
Spec
.
TemplateGeneration
)
for
i
:=
0
;
i
<
createDiff
;
i
++
{
go
func
(
ix
int
)
{
defer
createWait
.
Done
()
...
...
@@ -695,7 +695,7 @@ func (dsc *DaemonSetsController) updateDaemonSetStatus(ds *extensions.DaemonSet)
numberAvailable
++
}
}
if
util
.
IsPodUpdated
(
ds
.
TemplateGeneration
,
pod
)
{
if
util
.
IsPodUpdated
(
ds
.
Spec
.
TemplateGeneration
,
pod
)
{
updatedNumberScheduled
++
}
}
...
...
pkg/controller/daemon/daemoncontroller_test.go
View file @
620310c1
...
...
@@ -1022,7 +1022,7 @@ func TestDaemonSetUpdatesPods(t *testing.T) {
ds
.
Spec
.
UpdateStrategy
.
Type
=
extensions
.
RollingUpdateDaemonSetStrategyType
intStr
:=
intstr
.
FromInt
(
maxUnavailable
)
ds
.
Spec
.
UpdateStrategy
.
RollingUpdate
=
&
extensions
.
RollingUpdateDaemonSet
{
MaxUnavailable
:
&
intStr
}
ds
.
TemplateGeneration
++
ds
.
Spec
.
TemplateGeneration
++
manager
.
dsStore
.
Update
(
ds
)
clearExpectations
(
t
,
manager
,
ds
,
podControl
)
...
...
@@ -1061,7 +1061,7 @@ func TestDaemonSetUpdatesWhenNewPosIsNotReady(t *testing.T) {
ds
.
Spec
.
UpdateStrategy
.
Type
=
extensions
.
RollingUpdateDaemonSetStrategyType
intStr
:=
intstr
.
FromInt
(
maxUnavailable
)
ds
.
Spec
.
UpdateStrategy
.
RollingUpdate
=
&
extensions
.
RollingUpdateDaemonSet
{
MaxUnavailable
:
&
intStr
}
ds
.
TemplateGeneration
++
ds
.
Spec
.
TemplateGeneration
++
manager
.
dsStore
.
Update
(
ds
)
// new pods are not ready numUnavailable == maxUnavailable
...
...
@@ -1087,7 +1087,7 @@ func TestDaemonSetUpdatesAllOldPodsNotReady(t *testing.T) {
ds
.
Spec
.
UpdateStrategy
.
Type
=
extensions
.
RollingUpdateDaemonSetStrategyType
intStr
:=
intstr
.
FromInt
(
maxUnavailable
)
ds
.
Spec
.
UpdateStrategy
.
RollingUpdate
=
&
extensions
.
RollingUpdateDaemonSet
{
MaxUnavailable
:
&
intStr
}
ds
.
TemplateGeneration
++
ds
.
Spec
.
TemplateGeneration
++
manager
.
dsStore
.
Update
(
ds
)
// all old pods are unavailable so should be removed
...
...
pkg/controller/daemon/update.go
View file @
620310c1
...
...
@@ -80,7 +80,7 @@ func (dsc *DaemonSetsController) getAllDaemonSetPods(ds *extensions.DaemonSet) (
return
newPods
,
oldPods
,
fmt
.
Errorf
(
"Couldn't get list of pods for daemon set %#v: %v"
,
ds
,
err
)
}
for
_
,
pod
:=
range
daemonPods
{
if
util
.
IsPodUpdated
(
ds
.
TemplateGeneration
,
pod
)
{
if
util
.
IsPodUpdated
(
ds
.
Spec
.
TemplateGeneration
,
pod
)
{
newPods
=
append
(
newPods
,
pod
)
}
else
{
oldPods
=
append
(
oldPods
,
pod
)
...
...
pkg/registry/extensions/daemonset/strategy.go
View file @
620310c1
...
...
@@ -53,7 +53,9 @@ func (daemonSetStrategy) PrepareForCreate(ctx genericapirequest.Context, obj run
daemonSet
.
Status
=
extensions
.
DaemonSetStatus
{}
daemonSet
.
Generation
=
1
daemonSet
.
TemplateGeneration
=
1
if
daemonSet
.
Spec
.
TemplateGeneration
<
1
{
daemonSet
.
Spec
.
TemplateGeneration
=
1
}
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
...
...
@@ -65,7 +67,7 @@ func (daemonSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol
newDaemonSet
.
Status
=
oldDaemonSet
.
Status
// update is not allowed to set TemplateGeneration
newDaemonSet
.
TemplateGeneration
=
oldDaemonSet
.
TemplateGeneration
newDaemonSet
.
Spec
.
TemplateGeneration
=
oldDaemonSet
.
Spec
.
TemplateGeneration
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object. We push
...
...
@@ -79,7 +81,7 @@ func (daemonSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, ol
// TODO: Any changes to a part of the object that represents desired state (labels,
// annotations etc) should also increment the generation.
if
!
reflect
.
DeepEqual
(
oldDaemonSet
.
Spec
.
Template
,
newDaemonSet
.
Spec
.
Template
)
{
newDaemonSet
.
TemplateGeneration
=
oldDaemonSet
.
TemplateGeneration
+
1
newDaemonSet
.
Spec
.
TemplateGeneration
=
oldDaemonSet
.
Spec
.
TemplateGeneration
+
1
newDaemonSet
.
Generation
=
oldDaemonSet
.
Generation
+
1
return
}
...
...
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