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
41e71683
Commit
41e71683
authored
Oct 05, 2018
by
Darren Shepherd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove TTLAfterFinished
parent
5eb2ec73
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
4 additions
and
586 deletions
+4
-586
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+0
-1
core.go
cmd/kube-controller-manager/app/core.go
+0
-12
validation.go
pkg/apis/batch/validation/validation.go
+1
-8
BUILD
pkg/controller/ttlafterfinished/BUILD
+0
-54
ttlafterfinished_controller.go
...ontroller/ttlafterfinished/ttlafterfinished_controller.go
+0
-308
ttlafterfinished_controller_test.go
...ller/ttlafterfinished/ttlafterfinished_controller_test.go
+0
-177
kube_features.go
pkg/features/kube_features.go
+0
-7
strategy.go
pkg/registry/batch/job/strategy.go
+3
-10
controller_policy.go
...auth/authorizer/rbac/bootstrappolicy/controller_policy.go
+0
-9
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
41e71683
...
...
@@ -393,7 +393,6 @@ func NewControllerInitializers(loopMode ControllerLoopMode) map[string]InitFunc
controllers
[
"clusterrole-aggregation"
]
=
startClusterRoleAggregrationController
controllers
[
"pvc-protection"
]
=
startPVCProtectionController
controllers
[
"pv-protection"
]
=
startPVProtectionController
controllers
[
"ttl-after-finished"
]
=
startTTLAfterFinishedController
controllers
[
"root-ca-cert-publisher"
]
=
startRootCACertPublisher
return
controllers
...
...
cmd/kube-controller-manager/app/core.go
View file @
41e71683
...
...
@@ -50,7 +50,6 @@ import (
servicecontroller
"k8s.io/kubernetes/pkg/controller/service"
serviceaccountcontroller
"k8s.io/kubernetes/pkg/controller/serviceaccount"
ttlcontroller
"k8s.io/kubernetes/pkg/controller/ttl"
"k8s.io/kubernetes/pkg/controller/ttlafterfinished"
"k8s.io/kubernetes/pkg/controller/volume/attachdetach"
"k8s.io/kubernetes/pkg/controller/volume/expand"
persistentvolumecontroller
"k8s.io/kubernetes/pkg/controller/volume/persistentvolume"
...
...
@@ -390,14 +389,3 @@ func startPVProtectionController(ctx ControllerContext) (http.Handler, bool, err
)
.
Run
(
1
,
ctx
.
Stop
)
return
nil
,
true
,
nil
}
func
startTTLAfterFinishedController
(
ctx
ControllerContext
)
(
http
.
Handler
,
bool
,
error
)
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
TTLAfterFinished
)
{
return
nil
,
false
,
nil
}
go
ttlafterfinished
.
New
(
ctx
.
InformerFactory
.
Batch
()
.
V1
()
.
Jobs
(),
ctx
.
ClientBuilder
.
ClientOrDie
(
"ttl-after-finished-controller"
),
)
.
Run
(
int
(
ctx
.
ComponentConfig
.
TTLAfterFinishedController
.
ConcurrentTTLSyncs
),
ctx
.
Stop
)
return
nil
,
true
,
nil
}
pkg/apis/batch/validation/validation.go
View file @
41e71683
...
...
@@ -24,11 +24,9 @@ import (
"k8s.io/apimachinery/pkg/labels"
apimachineryvalidation
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/apis/batch"
api
"k8s.io/kubernetes/pkg/apis/core"
apivalidation
"k8s.io/kubernetes/pkg/apis/core/validation"
"k8s.io/kubernetes/pkg/features"
)
// TODO: generalize for other controller objects that will follow the same pattern, such as ReplicaSet and DaemonSet, and
...
...
@@ -119,12 +117,7 @@ func validateJobSpec(spec *batch.JobSpec, fldPath *field.Path) field.ErrorList {
if
spec
.
BackoffLimit
!=
nil
{
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateNonnegativeField
(
int64
(
*
spec
.
BackoffLimit
),
fldPath
.
Child
(
"backoffLimit"
))
...
)
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
TTLAfterFinished
)
{
// normal validation for TTLSecondsAfterFinished
if
spec
.
TTLSecondsAfterFinished
!=
nil
{
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateNonnegativeField
(
int64
(
*
spec
.
TTLSecondsAfterFinished
),
fldPath
.
Child
(
"ttlSecondsAfterFinished"
))
...
)
}
}
else
if
spec
.
TTLSecondsAfterFinished
!=
nil
{
if
spec
.
TTLSecondsAfterFinished
!=
nil
{
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
fldPath
.
Child
(
"ttlSecondsAfterFinished"
),
"disabled by feature-gate"
))
}
...
...
pkg/controller/ttlafterfinished/BUILD
deleted
100644 → 0
View file @
5eb2ec73
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["ttlafterfinished_controller.go"],
importpath = "k8s.io/kubernetes/pkg/controller/ttlafterfinished",
visibility = ["//visibility:public"],
deps = [
"//pkg/controller:go_default_library",
"//pkg/controller/job:go_default_library",
"//pkg/kubectl/scheme:go_default_library",
"//pkg/util/metrics:go_default_library",
"//staging/src/k8s.io/api/batch/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/client-go/informers/batch/v1:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/listers/batch/v1:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
"//staging/src/k8s.io/client-go/tools/record:go_default_library",
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["ttlafterfinished_controller_test.go"],
embed = [":go_default_library"],
deps = [
"//staging/src/k8s.io/api/batch/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
pkg/controller/ttlafterfinished/ttlafterfinished_controller.go
deleted
100644 → 0
View file @
5eb2ec73
This diff is collapsed.
Click to expand it.
pkg/controller/ttlafterfinished/ttlafterfinished_controller_test.go
deleted
100644 → 0
View file @
5eb2ec73
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
ttlafterfinished
import
(
"strings"
"testing"
"time"
batch
"k8s.io/api/batch/v1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
func
newJob
(
completionTime
,
failedTime
metav1
.
Time
,
ttl
*
int32
)
*
batch
.
Job
{
j
:=
&
batch
.
Job
{
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"Job"
},
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foobar"
,
Namespace
:
metav1
.
NamespaceDefault
,
},
Spec
:
batch
.
JobSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
Template
:
v1
.
PodTemplateSpec
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Image
:
"foo/bar"
},
},
},
},
},
}
if
!
completionTime
.
IsZero
()
{
c
:=
batch
.
JobCondition
{
Type
:
batch
.
JobComplete
,
Status
:
v1
.
ConditionTrue
,
LastTransitionTime
:
completionTime
}
j
.
Status
.
Conditions
=
append
(
j
.
Status
.
Conditions
,
c
)
}
if
!
failedTime
.
IsZero
()
{
c
:=
batch
.
JobCondition
{
Type
:
batch
.
JobFailed
,
Status
:
v1
.
ConditionTrue
,
LastTransitionTime
:
failedTime
}
j
.
Status
.
Conditions
=
append
(
j
.
Status
.
Conditions
,
c
)
}
if
ttl
!=
nil
{
j
.
Spec
.
TTLSecondsAfterFinished
=
ttl
}
return
j
}
func
durationPointer
(
n
int
)
*
time
.
Duration
{
s
:=
time
.
Duration
(
n
)
*
time
.
Second
return
&
s
}
func
int32Ptr
(
n
int32
)
*
int32
{
return
&
n
}
func
TestTimeLeft
(
t
*
testing
.
T
)
{
now
:=
metav1
.
Now
()
testCases
:=
[]
struct
{
name
string
completionTime
metav1
.
Time
failedTime
metav1
.
Time
ttl
*
int32
since
*
time
.
Time
expectErr
bool
expectErrStr
string
expectedTimeLeft
*
time
.
Duration
}{
{
name
:
"Error case: Job unfinished"
,
ttl
:
int32Ptr
(
100
),
since
:
&
now
.
Time
,
expectErr
:
true
,
expectErrStr
:
"should not be cleaned up"
,
},
{
name
:
"Error case: Job completed now, no TTL"
,
completionTime
:
now
,
since
:
&
now
.
Time
,
expectErr
:
true
,
expectErrStr
:
"should not be cleaned up"
,
},
{
name
:
"Job completed now, 0s TTL"
,
completionTime
:
now
,
ttl
:
int32Ptr
(
0
),
since
:
&
now
.
Time
,
expectedTimeLeft
:
durationPointer
(
0
),
},
{
name
:
"Job completed now, 10s TTL"
,
completionTime
:
now
,
ttl
:
int32Ptr
(
10
),
since
:
&
now
.
Time
,
expectedTimeLeft
:
durationPointer
(
10
),
},
{
name
:
"Job completed 10s ago, 15s TTL"
,
completionTime
:
metav1
.
NewTime
(
now
.
Add
(
-
10
*
time
.
Second
)),
ttl
:
int32Ptr
(
15
),
since
:
&
now
.
Time
,
expectedTimeLeft
:
durationPointer
(
5
),
},
{
name
:
"Error case: Job failed now, no TTL"
,
failedTime
:
now
,
since
:
&
now
.
Time
,
expectErr
:
true
,
expectErrStr
:
"should not be cleaned up"
,
},
{
name
:
"Job failed now, 0s TTL"
,
failedTime
:
now
,
ttl
:
int32Ptr
(
0
),
since
:
&
now
.
Time
,
expectedTimeLeft
:
durationPointer
(
0
),
},
{
name
:
"Job failed now, 10s TTL"
,
failedTime
:
now
,
ttl
:
int32Ptr
(
10
),
since
:
&
now
.
Time
,
expectedTimeLeft
:
durationPointer
(
10
),
},
{
name
:
"Job failed 10s ago, 15s TTL"
,
failedTime
:
metav1
.
NewTime
(
now
.
Add
(
-
10
*
time
.
Second
)),
ttl
:
int32Ptr
(
15
),
since
:
&
now
.
Time
,
expectedTimeLeft
:
durationPointer
(
5
),
},
}
for
_
,
tc
:=
range
testCases
{
job
:=
newJob
(
tc
.
completionTime
,
tc
.
failedTime
,
tc
.
ttl
)
gotTimeLeft
,
gotErr
:=
timeLeft
(
job
,
tc
.
since
)
if
tc
.
expectErr
!=
(
gotErr
!=
nil
)
{
t
.
Errorf
(
"%s: expected error is %t, got %t, error: %v"
,
tc
.
name
,
tc
.
expectErr
,
gotErr
!=
nil
,
gotErr
)
}
if
tc
.
expectErr
&&
len
(
tc
.
expectErrStr
)
==
0
{
t
.
Errorf
(
"%s: invalid test setup; error message must not be empty for error cases"
,
tc
.
name
)
}
if
tc
.
expectErr
&&
!
strings
.
Contains
(
gotErr
.
Error
(),
tc
.
expectErrStr
)
{
t
.
Errorf
(
"%s: expected error message contains %q, got %v"
,
tc
.
name
,
tc
.
expectErrStr
,
gotErr
)
}
if
!
tc
.
expectErr
{
if
*
gotTimeLeft
!=
*
tc
.
expectedTimeLeft
{
t
.
Errorf
(
"%s: expected time left %v, got %v"
,
tc
.
name
,
tc
.
expectedTimeLeft
,
gotTimeLeft
)
}
}
}
}
pkg/features/kube_features.go
View file @
41e71683
...
...
@@ -251,12 +251,6 @@ const (
// Enable resource quota scope selectors
ResourceQuotaScopeSelectors
utilfeature
.
Feature
=
"ResourceQuotaScopeSelectors"
// owner: @janetkuo
// alpha: v1.12
//
// Allow TTL controller to clean up Pods and Jobs after they finish.
TTLAfterFinished
utilfeature
.
Feature
=
"TTLAfterFinished"
// owner: @dashpole
// alpha: v1.13
//
...
...
@@ -307,7 +301,6 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
PodReadinessGates
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
KubeletPluginsWatcher
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
GA
},
ResourceQuotaScopeSelectors
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
TTLAfterFinished
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
KubeletPodResources
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
...
...
pkg/registry/batch/job/strategy.go
View file @
41e71683
...
...
@@ -30,12 +30,10 @@ import (
"k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/pod"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/batch/validation"
"k8s.io/kubernetes/pkg/features"
)
// jobStrategy implements verification logic for Replication Controllers.
...
...
@@ -62,10 +60,7 @@ func (jobStrategy) NamespaceScoped() bool {
func
(
jobStrategy
)
PrepareForCreate
(
ctx
context
.
Context
,
obj
runtime
.
Object
)
{
job
:=
obj
.
(
*
batch
.
Job
)
job
.
Status
=
batch
.
JobStatus
{}
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
TTLAfterFinished
)
{
job
.
Spec
.
TTLSecondsAfterFinished
=
nil
}
job
.
Spec
.
TTLSecondsAfterFinished
=
nil
pod
.
DropDisabledAlphaFields
(
&
job
.
Spec
.
Template
.
Spec
)
}
...
...
@@ -76,10 +71,8 @@ func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
oldJob
:=
old
.
(
*
batch
.
Job
)
newJob
.
Status
=
oldJob
.
Status
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
TTLAfterFinished
)
{
newJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
oldJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
}
newJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
oldJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
pod
.
DropDisabledAlphaFields
(
&
newJob
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledAlphaFields
(
&
oldJob
.
Spec
.
Template
.
Spec
)
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go
View file @
41e71683
...
...
@@ -340,15 +340,6 @@ func buildControllerRoles() ([]rbacv1.ClusterRole, []rbacv1.ClusterRoleBinding)
eventsRule
(),
},
})
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
TTLAfterFinished
)
{
addControllerRole
(
&
controllerRoles
,
&
controllerRoleBindings
,
rbacv1
.
ClusterRole
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"ttl-after-finished-controller"
},
Rules
:
[]
rbacv1
.
PolicyRule
{
rbacv1helpers
.
NewRule
(
"get"
,
"list"
,
"watch"
,
"delete"
)
.
Groups
(
batchGroup
)
.
Resources
(
"jobs"
)
.
RuleOrDie
(),
eventsRule
(),
},
})
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BoundServiceAccountTokenVolume
)
{
addControllerRole
(
&
controllerRoles
,
&
controllerRoleBindings
,
rbacv1
.
ClusterRole
{
...
...
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