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
1f921760
Commit
1f921760
authored
Aug 10, 2018
by
Weibin Lin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default extensions/v1beta1 Deployment's RevisionHistoryLimit to MaxInt32
parent
fbb2dfcc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
1 deletion
+27
-1
defaults.go
pkg/apis/extensions/v1beta1/defaults.go
+6
-0
defaults_test.go
pkg/apis/extensions/v1beta1/defaults_test.go
+5
-0
sync.go
pkg/controller/deployment/sync.go
+1
-1
sync_test.go
pkg/controller/deployment/sync_test.go
+12
-0
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+3
-0
No files found.
pkg/apis/extensions/v1beta1/defaults.go
View file @
1f921760
...
...
@@ -118,6 +118,12 @@ func SetDefaults_Deployment(obj *extensionsv1beta1.Deployment) {
obj
.
Spec
.
ProgressDeadlineSeconds
=
new
(
int32
)
*
obj
.
Spec
.
ProgressDeadlineSeconds
=
math
.
MaxInt32
}
// Set extensionsv1beta1.DeploymentSpec.RevisionHistoryLimit to MaxInt32,
// which has the same meaning as unset.
if
obj
.
Spec
.
RevisionHistoryLimit
==
nil
{
obj
.
Spec
.
RevisionHistoryLimit
=
new
(
int32
)
*
obj
.
Spec
.
RevisionHistoryLimit
=
math
.
MaxInt32
}
}
func
SetDefaults_ReplicaSet
(
obj
*
extensionsv1beta1
.
ReplicaSet
)
{
...
...
pkg/apis/extensions/v1beta1/defaults_test.go
View file @
1f921760
...
...
@@ -191,6 +191,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
Template
:
defaultTemplate
,
ProgressDeadlineSeconds
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
RevisionHistoryLimit
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
},
},
},
...
...
@@ -217,6 +218,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
Template
:
defaultTemplate
,
ProgressDeadlineSeconds
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
RevisionHistoryLimit
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
},
},
},
...
...
@@ -242,6 +244,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
Template
:
defaultTemplate
,
ProgressDeadlineSeconds
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
RevisionHistoryLimit
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
},
},
},
...
...
@@ -262,6 +265,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
Template
:
defaultTemplate
,
ProgressDeadlineSeconds
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
RevisionHistoryLimit
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
},
},
},
...
...
@@ -283,6 +287,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
Template
:
defaultTemplate
,
ProgressDeadlineSeconds
:
utilpointer
.
Int32Ptr
(
30
),
RevisionHistoryLimit
:
utilpointer
.
Int32Ptr
(
math
.
MaxInt32
),
},
},
},
...
...
pkg/controller/deployment/sync.go
View file @
1f921760
...
...
@@ -424,7 +424,7 @@ func (dc *DeploymentController) scaleReplicaSet(rs *apps.ReplicaSet, newScale in
// where N=d.Spec.RevisionHistoryLimit. Old replica sets are older versions of the podtemplate of a deployment kept
// around by default 1) for historical reasons and 2) for the ability to rollback a deployment.
func
(
dc
*
DeploymentController
)
cleanupDeployment
(
oldRSs
[]
*
apps
.
ReplicaSet
,
deployment
*
apps
.
Deployment
)
error
{
if
deployment
.
Spec
.
RevisionHistoryLimit
==
nil
{
if
!
deploymentutil
.
HasRevisionHistoryLimit
(
deployment
)
{
return
nil
}
...
...
pkg/controller/deployment/sync_test.go
View file @
1f921760
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
deployment
import
(
"math"
"testing"
"time"
...
...
@@ -393,6 +394,16 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) {
revisionHistoryLimit
:
0
,
expectedDeletions
:
0
,
},
{
// with unlimited revisionHistoryLimit
oldRSs
:
[]
*
apps
.
ReplicaSet
{
newRSWithStatus
(
"foo-1"
,
0
,
0
,
selector
),
newRSWithStatus
(
"foo-2"
,
0
,
0
,
selector
),
newRSWithStatus
(
"foo-3"
,
0
,
0
,
selector
),
},
revisionHistoryLimit
:
math
.
MaxInt32
,
expectedDeletions
:
0
,
},
}
for
i
:=
range
tests
{
...
...
@@ -418,6 +429,7 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) {
defer
close
(
stopCh
)
informers
.
Start
(
stopCh
)
t
.
Logf
(
" &test.revisionHistoryLimit: %d"
,
test
.
revisionHistoryLimit
)
d
:=
newDeployment
(
"foo"
,
1
,
&
test
.
revisionHistoryLimit
,
nil
,
nil
,
map
[
string
]
string
{
"foo"
:
"bar"
})
controller
.
cleanupDeployment
(
test
.
oldRSs
,
d
)
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
1f921760
...
...
@@ -886,3 +886,6 @@ func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired
func
HasProgressDeadline
(
d
*
apps
.
Deployment
)
bool
{
return
d
.
Spec
.
ProgressDeadlineSeconds
!=
nil
&&
*
d
.
Spec
.
ProgressDeadlineSeconds
!=
math
.
MaxInt32
}
func
HasRevisionHistoryLimit
(
d
*
apps
.
Deployment
)
bool
{
return
d
.
Spec
.
RevisionHistoryLimit
!=
nil
&&
*
d
.
Spec
.
RevisionHistoryLimit
!=
math
.
MaxInt32
}
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