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
ac88e138
Commit
ac88e138
authored
Feb 26, 2019
by
Peter McAlpine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lint warnings in pkg/controller/cronjob.
parent
6518c0b6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
12 deletions
+14
-12
batch.go
cmd/kube-controller-manager/app/batch.go
+1
-1
.golint_failures
hack/.golint_failures
+0
-1
controller.go
pkg/controller/cronjob/controller.go
+8
-6
utils.go
pkg/controller/cronjob/utils.go
+2
-1
utils_test.go
pkg/controller/cronjob/utils_test.go
+1
-1
cronjob_test.go
test/integration/cronjob/cronjob_test.go
+2
-2
No files found.
cmd/kube-controller-manager/app/batch.go
View file @
ac88e138
...
@@ -46,7 +46,7 @@ func startCronJobController(ctx ControllerContext) (http.Handler, bool, error) {
...
@@ -46,7 +46,7 @@ func startCronJobController(ctx ControllerContext) (http.Handler, bool, error) {
if
!
ctx
.
AvailableResources
[
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v1beta1"
,
Resource
:
"cronjobs"
}]
{
if
!
ctx
.
AvailableResources
[
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v1beta1"
,
Resource
:
"cronjobs"
}]
{
return
nil
,
false
,
nil
return
nil
,
false
,
nil
}
}
cjc
,
err
:=
cronjob
.
NewC
ronJobC
ontroller
(
cjc
,
err
:=
cronjob
.
NewController
(
ctx
.
ClientBuilder
.
ClientOrDie
(
"cronjob-controller"
),
ctx
.
ClientBuilder
.
ClientOrDie
(
"cronjob-controller"
),
)
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
hack/.golint_failures
View file @
ac88e138
...
@@ -79,7 +79,6 @@ pkg/controller/certificates/approver
...
@@ -79,7 +79,6 @@ pkg/controller/certificates/approver
pkg/controller/certificates/signer
pkg/controller/certificates/signer
pkg/controller/cloud
pkg/controller/cloud
pkg/controller/clusterroleaggregation
pkg/controller/clusterroleaggregation
pkg/controller/cronjob
pkg/controller/daemon
pkg/controller/daemon
pkg/controller/deployment
pkg/controller/deployment
pkg/controller/disruption
pkg/controller/disruption
...
...
pkg/controller/cronjob/controller.go
View file @
ac88e138
...
@@ -58,7 +58,8 @@ import (
...
@@ -58,7 +58,8 @@ import (
// controllerKind contains the schema.GroupVersionKind for this controller type.
// controllerKind contains the schema.GroupVersionKind for this controller type.
var
controllerKind
=
batchv1beta1
.
SchemeGroupVersion
.
WithKind
(
"CronJob"
)
var
controllerKind
=
batchv1beta1
.
SchemeGroupVersion
.
WithKind
(
"CronJob"
)
type
CronJobController
struct
{
// Controller is a controller for CronJobs.
type
Controller
struct
{
kubeClient
clientset
.
Interface
kubeClient
clientset
.
Interface
jobControl
jobControlInterface
jobControl
jobControlInterface
sjControl
sjControlInterface
sjControl
sjControlInterface
...
@@ -66,7 +67,8 @@ type CronJobController struct {
...
@@ -66,7 +67,8 @@ type CronJobController struct {
recorder
record
.
EventRecorder
recorder
record
.
EventRecorder
}
}
func
NewCronJobController
(
kubeClient
clientset
.
Interface
)
(
*
CronJobController
,
error
)
{
// NewController creates and initializes a new Controller.
func
NewController
(
kubeClient
clientset
.
Interface
)
(
*
Controller
,
error
)
{
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
.
StartLogging
(
klog
.
Infof
)
eventBroadcaster
.
StartLogging
(
klog
.
Infof
)
eventBroadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
kubeClient
.
CoreV1
()
.
Events
(
""
)})
eventBroadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
kubeClient
.
CoreV1
()
.
Events
(
""
)})
...
@@ -77,7 +79,7 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
...
@@ -77,7 +79,7 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
}
}
}
}
jm
:=
&
C
ronJobC
ontroller
{
jm
:=
&
Controller
{
kubeClient
:
kubeClient
,
kubeClient
:
kubeClient
,
jobControl
:
realJobControl
{
KubeClient
:
kubeClient
},
jobControl
:
realJobControl
{
KubeClient
:
kubeClient
},
sjControl
:
&
realSJControl
{
KubeClient
:
kubeClient
},
sjControl
:
&
realSJControl
{
KubeClient
:
kubeClient
},
...
@@ -88,8 +90,8 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
...
@@ -88,8 +90,8 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
return
jm
,
nil
return
jm
,
nil
}
}
// Run the main goroutine responsible for watching and syncing jobs.
// Run
starts
the main goroutine responsible for watching and syncing jobs.
func
(
jm
*
C
ronJobC
ontroller
)
Run
(
stopCh
<-
chan
struct
{})
{
func
(
jm
*
Controller
)
Run
(
stopCh
<-
chan
struct
{})
{
defer
utilruntime
.
HandleCrash
()
defer
utilruntime
.
HandleCrash
()
klog
.
Infof
(
"Starting CronJob Manager"
)
klog
.
Infof
(
"Starting CronJob Manager"
)
// Check things every 10 second.
// Check things every 10 second.
...
@@ -99,7 +101,7 @@ func (jm *CronJobController) Run(stopCh <-chan struct{}) {
...
@@ -99,7 +101,7 @@ func (jm *CronJobController) Run(stopCh <-chan struct{}) {
}
}
// syncAll lists all the CronJobs and Jobs and reconciles them.
// syncAll lists all the CronJobs and Jobs and reconciles them.
func
(
jm
*
C
ronJobC
ontroller
)
syncAll
()
{
func
(
jm
*
Controller
)
syncAll
()
{
// List children (Jobs) before parents (CronJob).
// List children (Jobs) before parents (CronJob).
// This guarantees that if we see any Job that got orphaned by the GC orphan finalizer,
// This guarantees that if we see any Job that got orphaned by the GC orphan finalizer,
// we must also see that the parent CronJob has non-nil DeletionTimestamp (see #42639).
// we must also see that the parent CronJob has non-nil DeletionTimestamp (see #42639).
...
...
pkg/controller/cronjob/utils.go
View file @
ac88e138
...
@@ -142,7 +142,7 @@ func getRecentUnmetScheduleTimes(sj batchv1beta1.CronJob, now time.Time) ([]time
...
@@ -142,7 +142,7 @@ func getRecentUnmetScheduleTimes(sj batchv1beta1.CronJob, now time.Time) ([]time
// but less than "lots".
// but less than "lots".
if
len
(
starts
)
>
100
{
if
len
(
starts
)
>
100
{
// We can't get the most recent times so just return an empty slice
// We can't get the most recent times so just return an empty slice
return
[]
time
.
Time
{},
fmt
.
Errorf
(
"
Too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew.
"
)
return
[]
time
.
Time
{},
fmt
.
Errorf
(
"
too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew
"
)
}
}
}
}
return
starts
,
nil
return
starts
,
nil
...
@@ -183,6 +183,7 @@ func getFinishedStatus(j *batchv1.Job) (bool, batchv1.JobConditionType) {
...
@@ -183,6 +183,7 @@ func getFinishedStatus(j *batchv1.Job) (bool, batchv1.JobConditionType) {
return
false
,
""
return
false
,
""
}
}
// IsJobFinished returns whether or not a job has completed successfully or failed.
func
IsJobFinished
(
j
*
batchv1
.
Job
)
bool
{
func
IsJobFinished
(
j
*
batchv1
.
Job
)
bool
{
isFinished
,
_
:=
getFinishedStatus
(
j
)
isFinished
,
_
:=
getFinishedStatus
(
j
)
return
isFinished
return
isFinished
...
...
pkg/controller/cronjob/utils_test.go
View file @
ac88e138
...
@@ -35,7 +35,7 @@ func TestGetJobFromTemplate(t *testing.T) {
...
@@ -35,7 +35,7 @@ func TestGetJobFromTemplate(t *testing.T) {
// and other fields, and add a created-by reference.
// and other fields, and add a created-by reference.
var
one
int64
=
1
var
one
int64
=
1
var
no
bool
=
false
var
no
bool
sj
:=
batchv1beta1
.
CronJob
{
sj
:=
batchv1beta1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
test/integration/cronjob/cronjob_test.go
View file @
ac88e138
...
@@ -38,7 +38,7 @@ import (
...
@@ -38,7 +38,7 @@ import (
"k8s.io/kubernetes/test/integration/framework"
"k8s.io/kubernetes/test/integration/framework"
)
)
func
setup
(
t
*
testing
.
T
)
(
*
httptest
.
Server
,
framework
.
CloseFunc
,
*
cronjob
.
C
ronJobC
ontroller
,
*
job
.
JobController
,
informers
.
SharedInformerFactory
,
clientset
.
Interface
,
rest
.
Config
)
{
func
setup
(
t
*
testing
.
T
)
(
*
httptest
.
Server
,
framework
.
CloseFunc
,
*
cronjob
.
Controller
,
*
job
.
JobController
,
informers
.
SharedInformerFactory
,
clientset
.
Interface
,
rest
.
Config
)
{
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
masterConfig
)
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
masterConfig
)
...
@@ -49,7 +49,7 @@ func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.CronJo
...
@@ -49,7 +49,7 @@ func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.CronJo
}
}
resyncPeriod
:=
12
*
time
.
Hour
resyncPeriod
:=
12
*
time
.
Hour
informerSet
:=
informers
.
NewSharedInformerFactory
(
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"cronjob-informers"
)),
resyncPeriod
)
informerSet
:=
informers
.
NewSharedInformerFactory
(
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"cronjob-informers"
)),
resyncPeriod
)
cjc
,
err
:=
cronjob
.
NewC
ronJobC
ontroller
(
clientSet
)
cjc
,
err
:=
cronjob
.
NewController
(
clientSet
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Error creating CronJob controller: %v"
,
err
)
t
.
Fatalf
(
"Error creating CronJob controller: %v"
,
err
)
}
}
...
...
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