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
d7eec6b5
Commit
d7eec6b5
authored
Aug 31, 2017
by
Antoine Pelisse
Committed by
GitHub
Aug 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Enable batch/v1beta1.CronJobs by default"
parent
72192392
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
157 additions
and
388 deletions
+157
-388
server.go
cmd/kube-apiserver/app/server.go
+4
-2
BUILD
cmd/kube-controller-manager/app/BUILD
+1
-0
batch.go
cmd/kube-controller-manager/app/batch.go
+7
-2
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+10
-8
defaults_test.go
pkg/apis/batch/v1beta1/defaults_test.go
+1
-1
BUILD
pkg/controller/cronjob/BUILD
+2
-2
cronjob_controller.go
pkg/controller/cronjob/cronjob_controller.go
+9
-9
cronjob_controller_test.go
pkg/controller/cronjob/cronjob_controller_test.go
+19
-19
injection.go
pkg/controller/cronjob/injection.go
+8
-8
utils.go
pkg/controller/cronjob/utils.go
+5
-5
utils_test.go
pkg/controller/cronjob/utils_test.go
+9
-9
BUILD
pkg/kubectl/BUILD
+0
-2
BUILD
pkg/kubectl/cmd/BUILD
+0
-1
run.go
pkg/kubectl/cmd/run.go
+1
-6
factory_client_access.go
pkg/kubectl/cmd/util/factory_client_access.go
+0
-2
run.go
pkg/kubectl/run.go
+0
-102
run_test.go
pkg/kubectl/run_test.go
+1
-100
BUILD
pkg/master/BUILD
+1
-2
master.go
pkg/master/master.go
+3
-2
master_test.go
pkg/master/master_test.go
+2
-4
BUILD
pkg/printers/internalversion/BUILD
+1
-1
printers.go
pkg/printers/internalversion/printers.go
+5
-5
BUILD
test/e2e/apimachinery/BUILD
+1
-1
garbage_collector.go
test/e2e/apimachinery/garbage_collector.go
+7
-7
generated_clientset.go
test/e2e/apimachinery/generated_clientset.go
+25
-13
BUILD
test/e2e/apps/BUILD
+2
-1
cronjob.go
test/e2e/apps/cronjob.go
+22
-22
types.go
test/e2e/apps/types.go
+2
-2
BUILD
test/e2e/kubectl/BUILD
+1
-0
kubectl.go
test/e2e/kubectl/kubectl.go
+5
-42
etcd_storage_path_test.go
test/integration/etcd/etcd_storage_path_test.go
+2
-1
master_utils.go
test/integration/framework/master_utils.go
+1
-7
No files found.
cmd/kube-apiserver/app/server.go
View file @
d7eec6b5
...
...
@@ -51,6 +51,7 @@ import (
"k8s.io/apiserver/pkg/server/options/encryptionconfig"
serverstorage
"k8s.io/apiserver/pkg/server/storage"
aggregatorapiserver
"k8s.io/kube-aggregator/pkg/apiserver"
//aggregatorinformers "k8s.io/kube-aggregator/pkg/client/informers/internalversion"
openapi
"k8s.io/kube-openapi/pkg/common"
"k8s.io/apiserver/pkg/storage/etcd3/preflight"
...
...
@@ -556,8 +557,9 @@ func BuildStorageFactory(s *options.ServerRunOptions) (*serverstorage.DefaultSto
storageFactory
,
err
:=
kubeapiserver
.
NewStorageFactory
(
s
.
Etcd
.
StorageConfig
,
s
.
Etcd
.
DefaultStorageMediaType
,
api
.
Codecs
,
serverstorage
.
NewDefaultResourceEncodingConfig
(
api
.
Registry
),
storageGroupsToEncodingVersion
,
// FIXME (soltysh): this GroupVersionResource override should be configurable
[]
schema
.
GroupVersionResource
{
batch
.
Resource
(
"cronjobs"
)
.
WithVersion
(
"v1beta1"
)},
// FIXME: this GroupVersionResource override should be configurable
// TODO we need to update this to batch/v1beta1 when it's enabled by default
[]
schema
.
GroupVersionResource
{
batch
.
Resource
(
"cronjobs"
)
.
WithVersion
(
"v2alpha1"
)},
master
.
DefaultAPIResourceConfigSource
(),
s
.
APIEnablement
.
RuntimeConfig
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error in initializing storage factory: %s"
,
err
)
...
...
cmd/kube-controller-manager/app/BUILD
View file @
d7eec6b5
...
...
@@ -29,6 +29,7 @@ go_library(
"//pkg/apis/authentication/install:go_default_library",
"//pkg/apis/authorization/install:go_default_library",
"//pkg/apis/autoscaling/install:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/batch/install:go_default_library",
"//pkg/apis/certificates/install:go_default_library",
"//pkg/apis/componentconfig:go_default_library",
...
...
cmd/kube-controller-manager/app/batch.go
View file @
d7eec6b5
...
...
@@ -22,6 +22,8 @@ package app
import
(
"k8s.io/apimachinery/pkg/runtime/schema"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/controller/cronjob"
"k8s.io/kubernetes/pkg/controller/job"
)
...
...
@@ -39,11 +41,14 @@ func startJobController(ctx ControllerContext) (bool, error) {
}
func
startCronJobController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
if
!
ctx
.
AvailableResources
[
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v
1bet
a1"
,
Resource
:
"cronjobs"
}]
{
if
!
ctx
.
AvailableResources
[
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v
2alph
a1"
,
Resource
:
"cronjobs"
}]
{
return
false
,
nil
}
// TODO: this is a temp fix for allowing kubeClient list v2alpha1 sj, should switch to using clientset
cronjobConfig
:=
ctx
.
ClientBuilder
.
ConfigOrDie
(
"cronjob-controller"
)
cronjobConfig
.
ContentConfig
.
GroupVersion
=
&
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v2alpha1"
}
go
cronjob
.
NewCronJobController
(
c
tx
.
ClientBuilder
.
ClientOrDie
(
"cronjob-controller"
),
c
lientset
.
NewForConfigOrDie
(
cronjobConfig
),
)
.
Run
(
ctx
.
Stop
)
return
true
,
nil
}
hack/make-rules/test-cmd-util.sh
View file @
d7eec6b5
...
...
@@ -1248,14 +1248,16 @@ run_kubectl_run_tests() {
# Clean up
kubectl delete deployment nginx-apps
"
${
kube_flags
[@]
}
"
# Pre-Condition: no Job exists
kube::test::get_object_assert cronjob.v1beta1.batch
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Command
kubectl run pi
--schedule
=
"*/5 * * * *"
--generator
=
cronjob/v1beta1
"--image=
$IMAGE_PERL
"
--restart
=
OnFailure
--
perl
-Mbignum
=
bpi
-wle
'print bpi(20)'
"
${
kube_flags
[@]
}
"
# Post-Condition: CronJob "pi" is created
kube::test::get_object_assert cronjob.v1beta1.batch
"{{range.items}}{{
$id_field
}}:{{end}}"
'pi:'
# Clean up
kubectl delete cronjob.v1beta1.batch pi
"
${
kube_flags
[@]
}
"
# TODO: enable batch/v1beta1 by default before 1.8 release, after issues
# with CronJobs existing in multiple versions at once is solved
# # Pre-Condition: no Job exists
# kube::test::get_object_assert cronjobs "{{range.items}}{{$id_field}}:{{end}}" ''
# # Command
# kubectl run pi --schedule="*/5 * * * *" --generator=cronjob/v1beta1 "--image=$IMAGE_PERL" --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(20)' "${kube_flags[@]}"
# # Post-Condition: CronJob "pi" is created
# kube::test::get_object_assert cronjobs "{{range.items}}{{$id_field}}:{{end}}" 'pi:'
# # Clean up
# kubectl delete cronjobs pi "${kube_flags[@]}"
set
+o nounset
set
+o errexit
...
...
pkg/apis/batch/v1beta1/defaults_test.go
View file @
d7eec6b5
...
...
@@ -34,7 +34,7 @@ func TestSetDefaultCronJob(t *testing.T) {
original
*
batchv1beta1
.
CronJob
expected
*
batchv1beta1
.
CronJob
}{
"empty batchv
1beta1.CronJob should default batchv1bet
a1.ConcurrencyPolicy and Suspend"
:
{
"empty batchv
2alpha1.CronJob should default batchv2alph
a1.ConcurrencyPolicy and Suspend"
:
{
original
:
&
batchv1beta1
.
CronJob
{},
expected
:
&
batchv1beta1
.
CronJob
{
Spec
:
batchv1beta1
.
CronJobSpec
{
...
...
pkg/controller/cronjob/BUILD
View file @
d7eec6b5
...
...
@@ -20,7 +20,7 @@ go_library(
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/robfig/cron:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v
1bet
a1:go_default_library",
"//vendor/k8s.io/api/batch/v
2alph
a1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
...
...
@@ -50,7 +50,7 @@ go_test(
"//pkg/api/install:go_default_library",
"//pkg/apis/batch/install:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v
1bet
a1:go_default_library",
"//vendor/k8s.io/api/batch/v
2alph
a1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
...
...
pkg/controller/cronjob/cronjob_controller.go
View file @
d7eec6b5
...
...
@@ -36,7 +36,7 @@ import (
"github.com/golang/glog"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -56,7 +56,7 @@ import (
// Utilities for dealing with Jobs and CronJobs and time.
// controllerKind contains the schema.GroupVersionKind for this controller type.
var
controllerKind
=
batchv
1bet
a1
.
SchemeGroupVersion
.
WithKind
(
"CronJob"
)
var
controllerKind
=
batchv
2alph
a1
.
SchemeGroupVersion
.
WithKind
(
"CronJob"
)
type
CronJobController
struct
{
kubeClient
clientset
.
Interface
...
...
@@ -116,7 +116,7 @@ func (jm *CronJobController) syncAll() {
js
:=
jl
.
Items
glog
.
V
(
4
)
.
Infof
(
"Found %d jobs"
,
len
(
js
))
sjl
,
err
:=
jm
.
kubeClient
.
BatchV
1bet
a1
()
.
CronJobs
(
metav1
.
NamespaceAll
)
.
List
(
metav1
.
ListOptions
{})
sjl
,
err
:=
jm
.
kubeClient
.
BatchV
2alph
a1
()
.
CronJobs
(
metav1
.
NamespaceAll
)
.
List
(
metav1
.
ListOptions
{})
if
err
!=
nil
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"can't list CronJobs: %v"
,
err
))
return
...
...
@@ -134,7 +134,7 @@ func (jm *CronJobController) syncAll() {
}
// cleanupFinishedJobs cleanups finished jobs created by a CronJob
func
cleanupFinishedJobs
(
sj
*
batchv
1bet
a1
.
CronJob
,
js
[]
batchv1
.
Job
,
jc
jobControlInterface
,
func
cleanupFinishedJobs
(
sj
*
batchv
2alph
a1
.
CronJob
,
js
[]
batchv1
.
Job
,
jc
jobControlInterface
,
sjc
sjControlInterface
,
pc
podControlInterface
,
recorder
record
.
EventRecorder
)
{
// If neither limits are active, there is no need to do anything.
if
sj
.
Spec
.
FailedJobsHistoryLimit
==
nil
&&
sj
.
Spec
.
SuccessfulJobsHistoryLimit
==
nil
{
...
...
@@ -179,7 +179,7 @@ func cleanupFinishedJobs(sj *batchv1beta1.CronJob, js []batchv1.Job, jc jobContr
}
// removeOldestJobs removes the oldest jobs from a list of jobs
func
removeOldestJobs
(
sj
*
batchv
1bet
a1
.
CronJob
,
js
[]
batchv1
.
Job
,
jc
jobControlInterface
,
func
removeOldestJobs
(
sj
*
batchv
2alph
a1
.
CronJob
,
js
[]
batchv1
.
Job
,
jc
jobControlInterface
,
pc
podControlInterface
,
maxJobs
int32
,
recorder
record
.
EventRecorder
)
{
numToDelete
:=
len
(
js
)
-
int
(
maxJobs
)
if
numToDelete
<=
0
{
...
...
@@ -200,7 +200,7 @@ func removeOldestJobs(sj *batchv1beta1.CronJob, js []batchv1.Job, jc jobControlI
// All known jobs created by "sj" should be included in "js".
// The current time is passed in to facilitate testing.
// It has no receiver, to facilitate testing.
func
syncOne
(
sj
*
batchv
1bet
a1
.
CronJob
,
js
[]
batchv1
.
Job
,
now
time
.
Time
,
jc
jobControlInterface
,
sjc
sjControlInterface
,
pc
podControlInterface
,
recorder
record
.
EventRecorder
)
{
func
syncOne
(
sj
*
batchv
2alph
a1
.
CronJob
,
js
[]
batchv1
.
Job
,
now
time
.
Time
,
jc
jobControlInterface
,
sjc
sjControlInterface
,
pc
podControlInterface
,
recorder
record
.
EventRecorder
)
{
nameForLog
:=
fmt
.
Sprintf
(
"%s/%s"
,
sj
.
Namespace
,
sj
.
Name
)
childrenJobs
:=
make
(
map
[
types
.
UID
]
bool
)
...
...
@@ -284,7 +284,7 @@ func syncOne(sj *batchv1beta1.CronJob, js []batchv1.Job, now time.Time, jc jobCo
// can see easily that there was a missed execution.
return
}
if
sj
.
Spec
.
ConcurrencyPolicy
==
batchv
1bet
a1
.
ForbidConcurrent
&&
len
(
sj
.
Status
.
Active
)
>
0
{
if
sj
.
Spec
.
ConcurrencyPolicy
==
batchv
2alph
a1
.
ForbidConcurrent
&&
len
(
sj
.
Status
.
Active
)
>
0
{
// Regardless which source of information we use for the set of active jobs,
// there is some risk that we won't see an active job when there is one.
// (because we haven't seen the status update to the SJ or the created pod).
...
...
@@ -297,7 +297,7 @@ func syncOne(sj *batchv1beta1.CronJob, js []batchv1.Job, now time.Time, jc jobCo
glog
.
V
(
4
)
.
Infof
(
"Not starting job for %s because of prior execution still running and concurrency policy is Forbid"
,
nameForLog
)
return
}
if
sj
.
Spec
.
ConcurrencyPolicy
==
batchv
1bet
a1
.
ReplaceConcurrent
{
if
sj
.
Spec
.
ConcurrencyPolicy
==
batchv
2alph
a1
.
ReplaceConcurrent
{
for
_
,
j
:=
range
sj
.
Status
.
Active
{
// TODO: this should be replaced with server side job deletion
// currently this mimics JobReaper from pkg/kubectl/stop.go
...
...
@@ -353,7 +353,7 @@ func syncOne(sj *batchv1beta1.CronJob, js []batchv1.Job, now time.Time, jc jobCo
}
// deleteJob reaps a job, deleting the job, the pobs and the reference in the active list
func
deleteJob
(
sj
*
batchv
1bet
a1
.
CronJob
,
job
*
batchv1
.
Job
,
jc
jobControlInterface
,
func
deleteJob
(
sj
*
batchv
2alph
a1
.
CronJob
,
job
*
batchv1
.
Job
,
jc
jobControlInterface
,
pc
podControlInterface
,
recorder
record
.
EventRecorder
,
reason
string
)
bool
{
// TODO: this should be replaced with server side job deletion
// currencontinuetly this mimics JobReaper from pkg/kubectl/stop.go
...
...
pkg/controller/cronjob/cronjob_controller_test.go
View file @
d7eec6b5
...
...
@@ -24,7 +24,7 @@ import (
"time"
batchv1
"k8s.io/api/batch/v1"
batch
V1beta1
"k8s.io/api/batch/v1bet
a1"
batch
v2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
...
...
@@ -96,19 +96,19 @@ func startTimeStringToTime(startTime string) time.Time {
}
// returns a cronJob with some fields filled in.
func
cronJob
()
batch
V1bet
a1
.
CronJob
{
return
batch
V1bet
a1
.
CronJob
{
func
cronJob
()
batch
v2alph
a1
.
CronJob
{
return
batch
v2alph
a1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"mycronjob"
,
Namespace
:
"snazzycats"
,
UID
:
types
.
UID
(
"1a2b3c"
),
SelfLink
:
"/apis/batch/v
1bet
a1/namespaces/snazzycats/cronjobs/mycronjob"
,
SelfLink
:
"/apis/batch/v
2alph
a1/namespaces/snazzycats/cronjobs/mycronjob"
,
CreationTimestamp
:
metav1
.
Time
{
Time
:
justBeforeTheHour
()},
},
Spec
:
batch
V1bet
a1
.
CronJobSpec
{
Spec
:
batch
v2alph
a1
.
CronJobSpec
{
Schedule
:
"* * * * ?"
,
ConcurrencyPolicy
:
batch
V1bet
a1
.
AllowConcurrent
,
JobTemplate
:
batch
V1bet
a1
.
JobTemplateSpec
{
ConcurrencyPolicy
:
batch
v2alph
a1
.
AllowConcurrent
,
JobTemplate
:
batch
v2alph
a1
.
JobTemplateSpec
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
Annotations
:
map
[
string
]
string
{
"x"
:
"y"
},
...
...
@@ -152,15 +152,15 @@ func newJob(UID string) batchv1.Job {
}
var
(
shortDead
int64
=
10
mediumDead
int64
=
2
*
60
*
60
longDead
int64
=
1000000
noDead
int64
=
-
12345
A
batch
V1beta1
.
ConcurrencyPolicy
=
batchV1bet
a1
.
AllowConcurrent
f
batch
V1beta1
.
ConcurrencyPolicy
=
batchV1bet
a1
.
ForbidConcurrent
R
batch
V1beta1
.
ConcurrencyPolicy
=
batchV1bet
a1
.
ReplaceConcurrent
T
bool
=
true
F
bool
=
false
shortDead
int64
=
10
mediumDead
int64
=
2
*
60
*
60
longDead
int64
=
1000000
noDead
int64
=
-
12345
A
batch
v2alpha1
.
ConcurrencyPolicy
=
batchv2alph
a1
.
AllowConcurrent
f
batch
v2alpha1
.
ConcurrencyPolicy
=
batchv2alph
a1
.
ForbidConcurrent
R
batch
v2alpha1
.
ConcurrencyPolicy
=
batchv2alph
a1
.
ReplaceConcurrent
T
bool
=
true
F
bool
=
false
)
func
TestSyncOne_RunOrNot
(
t
*
testing
.
T
)
{
...
...
@@ -179,7 +179,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
testCases
:=
map
[
string
]
struct
{
// sj spec
concurrencyPolicy
batch
V1bet
a1
.
ConcurrencyPolicy
concurrencyPolicy
batch
v2alph
a1
.
ConcurrencyPolicy
suspend
bool
schedule
string
deadline
int64
...
...
@@ -298,7 +298,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
if
controllerRef
==
nil
{
t
.
Errorf
(
"%s: expected job to have ControllerRef: %#v"
,
name
,
job
)
}
else
{
if
got
,
want
:=
controllerRef
.
APIVersion
,
"batch/v
1bet
a1"
;
got
!=
want
{
if
got
,
want
:=
controllerRef
.
APIVersion
,
"batch/v
2alph
a1"
;
got
!=
want
{
t
.
Errorf
(
"%s: controllerRef.APIVersion = %q, want %q"
,
name
,
got
,
want
)
}
if
got
,
want
:=
controllerRef
.
Kind
,
"CronJob"
;
got
!=
want
{
...
...
@@ -596,7 +596,7 @@ func TestSyncOne_Status(t *testing.T) {
testCases
:=
map
[
string
]
struct
{
// sj spec
concurrencyPolicy
batch
V1bet
a1
.
ConcurrencyPolicy
concurrencyPolicy
batch
v2alph
a1
.
ConcurrencyPolicy
suspend
bool
schedule
string
deadline
int64
...
...
pkg/controller/cronjob/injection.go
View file @
d7eec6b5
...
...
@@ -21,7 +21,7 @@ import (
"sync"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
...
...
@@ -33,7 +33,7 @@ import (
// sjControlInterface is an interface that knows how to update CronJob status
// created as an interface to allow testing.
type
sjControlInterface
interface
{
UpdateStatus
(
sj
*
batchv
1beta1
.
CronJob
)
(
*
batchv1bet
a1
.
CronJob
,
error
)
UpdateStatus
(
sj
*
batchv
2alpha1
.
CronJob
)
(
*
batchv2alph
a1
.
CronJob
,
error
)
}
// realSJControl is the default implementation of sjControlInterface.
...
...
@@ -43,18 +43,18 @@ type realSJControl struct {
var
_
sjControlInterface
=
&
realSJControl
{}
func
(
c
*
realSJControl
)
UpdateStatus
(
sj
*
batchv
1beta1
.
CronJob
)
(
*
batchv1bet
a1
.
CronJob
,
error
)
{
return
c
.
KubeClient
.
BatchV
1bet
a1
()
.
CronJobs
(
sj
.
Namespace
)
.
UpdateStatus
(
sj
)
func
(
c
*
realSJControl
)
UpdateStatus
(
sj
*
batchv
2alpha1
.
CronJob
)
(
*
batchv2alph
a1
.
CronJob
,
error
)
{
return
c
.
KubeClient
.
BatchV
2alph
a1
()
.
CronJobs
(
sj
.
Namespace
)
.
UpdateStatus
(
sj
)
}
// fakeSJControl is the default implementation of sjControlInterface.
type
fakeSJControl
struct
{
Updates
[]
batchv
1bet
a1
.
CronJob
Updates
[]
batchv
2alph
a1
.
CronJob
}
var
_
sjControlInterface
=
&
fakeSJControl
{}
func
(
c
*
fakeSJControl
)
UpdateStatus
(
sj
*
batchv
1beta1
.
CronJob
)
(
*
batchv1bet
a1
.
CronJob
,
error
)
{
func
(
c
*
fakeSJControl
)
UpdateStatus
(
sj
*
batchv
2alpha1
.
CronJob
)
(
*
batchv2alph
a1
.
CronJob
,
error
)
{
c
.
Updates
=
append
(
c
.
Updates
,
*
sj
)
return
sj
,
nil
}
...
...
@@ -85,7 +85,7 @@ type realJobControl struct {
var
_
jobControlInterface
=
&
realJobControl
{}
func
copyLabels
(
template
*
batchv
1bet
a1
.
JobTemplateSpec
)
labels
.
Set
{
func
copyLabels
(
template
*
batchv
2alph
a1
.
JobTemplateSpec
)
labels
.
Set
{
l
:=
make
(
labels
.
Set
)
for
k
,
v
:=
range
template
.
Labels
{
l
[
k
]
=
v
...
...
@@ -93,7 +93,7 @@ func copyLabels(template *batchv1beta1.JobTemplateSpec) labels.Set {
return
l
}
func
copyAnnotations
(
template
*
batchv
1bet
a1
.
JobTemplateSpec
)
labels
.
Set
{
func
copyAnnotations
(
template
*
batchv
2alph
a1
.
JobTemplateSpec
)
labels
.
Set
{
a
:=
make
(
labels
.
Set
)
for
k
,
v
:=
range
template
.
Annotations
{
a
[
k
]
=
v
...
...
pkg/controller/cronjob/utils.go
View file @
d7eec6b5
...
...
@@ -24,7 +24,7 @@ import (
"github.com/robfig/cron"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
...
...
@@ -36,7 +36,7 @@ import (
// Utilities for dealing with Jobs and CronJobs and time.
func
inActiveList
(
sj
batchv
1bet
a1
.
CronJob
,
uid
types
.
UID
)
bool
{
func
inActiveList
(
sj
batchv
2alph
a1
.
CronJob
,
uid
types
.
UID
)
bool
{
for
_
,
j
:=
range
sj
.
Status
.
Active
{
if
j
.
UID
==
uid
{
return
true
...
...
@@ -45,7 +45,7 @@ func inActiveList(sj batchv1beta1.CronJob, uid types.UID) bool {
return
false
}
func
deleteFromActiveList
(
sj
*
batchv
1bet
a1
.
CronJob
,
uid
types
.
UID
)
{
func
deleteFromActiveList
(
sj
*
batchv
2alph
a1
.
CronJob
,
uid
types
.
UID
)
{
if
sj
==
nil
{
return
}
...
...
@@ -111,7 +111,7 @@ func getNextStartTimeAfter(schedule string, now time.Time) (time.Time, error) {
//
// If there are too many (>100) unstarted times, just give up and return an empty slice.
// If there were missed times prior to the last known start time, then those are not returned.
func
getRecentUnmetScheduleTimes
(
sj
batchv
1bet
a1
.
CronJob
,
now
time
.
Time
)
([]
time
.
Time
,
error
)
{
func
getRecentUnmetScheduleTimes
(
sj
batchv
2alph
a1
.
CronJob
,
now
time
.
Time
)
([]
time
.
Time
,
error
)
{
starts
:=
[]
time
.
Time
{}
sched
,
err
:=
cron
.
ParseStandard
(
sj
.
Spec
.
Schedule
)
if
err
!=
nil
{
...
...
@@ -170,7 +170,7 @@ func getRecentUnmetScheduleTimes(sj batchv1beta1.CronJob, now time.Time) ([]time
}
// getJobFromTemplate makes a Job from a CronJob
func
getJobFromTemplate
(
sj
*
batchv
1bet
a1
.
CronJob
,
scheduledTime
time
.
Time
)
(
*
batchv1
.
Job
,
error
)
{
func
getJobFromTemplate
(
sj
*
batchv
2alph
a1
.
CronJob
,
scheduledTime
time
.
Time
)
(
*
batchv1
.
Job
,
error
)
{
// TODO: consider adding the following labels:
// nominal-start-time=$RFC_3339_DATE_OF_INTENDED_START -- for user convenience
// scheduled-job-name=$SJ_NAME -- for user convenience
...
...
pkg/controller/cronjob/utils_test.go
View file @
d7eec6b5
...
...
@@ -22,7 +22,7 @@ import (
"time"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
...
...
@@ -37,17 +37,17 @@ func TestGetJobFromTemplate(t *testing.T) {
var
one
int64
=
1
var
no
bool
=
false
sj
:=
batchv
1bet
a1
.
CronJob
{
sj
:=
batchv
2alph
a1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"mycronjob"
,
Namespace
:
"snazzycats"
,
UID
:
types
.
UID
(
"1a2b3c"
),
SelfLink
:
"/apis/batch/v1/namespaces/snazzycats/jobs/mycronjob"
,
},
Spec
:
batchv
1bet
a1
.
CronJobSpec
{
Spec
:
batchv
2alph
a1
.
CronJobSpec
{
Schedule
:
"* * * * ?"
,
ConcurrencyPolicy
:
batchv
1bet
a1
.
AllowConcurrent
,
JobTemplate
:
batchv
1bet
a1
.
JobTemplateSpec
{
ConcurrencyPolicy
:
batchv
2alph
a1
.
AllowConcurrent
,
JobTemplate
:
batchv
2alph
a1
.
JobTemplateSpec
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"a"
:
"b"
},
Annotations
:
map
[
string
]
string
{
"x"
:
"y"
},
...
...
@@ -267,16 +267,16 @@ func TestGetRecentUnmetScheduleTimes(t *testing.T) {
t
.
Errorf
(
"test setup error: %v"
,
err
)
}
sj
:=
batchv
1bet
a1
.
CronJob
{
sj
:=
batchv
2alph
a1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"mycronjob"
,
Namespace
:
metav1
.
NamespaceDefault
,
UID
:
types
.
UID
(
"1a2b3c"
),
},
Spec
:
batchv
1bet
a1
.
CronJobSpec
{
Spec
:
batchv
2alph
a1
.
CronJobSpec
{
Schedule
:
schedule
,
ConcurrencyPolicy
:
batchv
1bet
a1
.
AllowConcurrent
,
JobTemplate
:
batchv
1bet
a1
.
JobTemplateSpec
{},
ConcurrencyPolicy
:
batchv
2alph
a1
.
AllowConcurrent
,
JobTemplate
:
batchv
2alph
a1
.
JobTemplateSpec
{},
},
}
{
...
...
pkg/kubectl/BUILD
View file @
d7eec6b5
...
...
@@ -51,7 +51,6 @@ go_test(
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v1beta1:go_default_library",
"//vendor/k8s.io/api/batch/v2alpha1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
...
...
@@ -144,7 +143,6 @@ go_library(
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v1beta1:go_default_library",
"//vendor/k8s.io/api/batch/v2alpha1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
...
...
pkg/kubectl/cmd/BUILD
View file @
d7eec6b5
...
...
@@ -108,7 +108,6 @@ go_library(
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v1beta1:go_default_library",
"//vendor/k8s.io/api/batch/v2alpha1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
...
...
pkg/kubectl/cmd/run.go
View file @
d7eec6b5
...
...
@@ -24,7 +24,6 @@ import (
"github.com/spf13/cobra"
batchv1
"k8s.io/api/batch/v1"
batchv1beta1
"k8s.io/api/batch/v1beta1"
batchv2alpha1
"k8s.io/api/batch/v2alpha1"
extensionsv1beta1
"k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
...
...
@@ -226,11 +225,7 @@ func RunRun(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *c
generatorName
:=
cmdutil
.
GetFlagString
(
cmd
,
"generator"
)
schedule
:=
cmdutil
.
GetFlagString
(
cmd
,
"schedule"
)
if
len
(
schedule
)
!=
0
&&
len
(
generatorName
)
==
0
{
if
contains
(
resourcesList
,
batchv1beta1
.
SchemeGroupVersion
.
WithResource
(
"cronjobs"
))
{
generatorName
=
cmdutil
.
CronJobV1Beta1GeneratorName
}
else
{
generatorName
=
cmdutil
.
CronJobV2Alpha1GeneratorName
}
generatorName
=
cmdutil
.
CronJobV2Alpha1GeneratorName
}
if
len
(
generatorName
)
==
0
{
switch
restartPolicy
{
...
...
pkg/kubectl/cmd/util/factory_client_access.go
View file @
d7eec6b5
...
...
@@ -479,7 +479,6 @@ const (
DeploymentBasicAppsV1Beta1GeneratorName
=
"deployment-basic/apps.v1beta1"
JobV1GeneratorName
=
"job/v1"
CronJobV2Alpha1GeneratorName
=
"cronjob/v2alpha1"
CronJobV1Beta1GeneratorName
=
"cronjob/v1beta1"
NamespaceV1GeneratorName
=
"namespace/v1"
ResourceQuotaV1GeneratorName
=
"resourcequotas/v1"
SecretV1GeneratorName
=
"secret/v1"
...
...
@@ -529,7 +528,6 @@ func DefaultGenerators(cmdName string) map[string]kubectl.Generator {
DeploymentAppsV1Beta1GeneratorName
:
kubectl
.
DeploymentAppsV1Beta1
{},
JobV1GeneratorName
:
kubectl
.
JobV1
{},
CronJobV2Alpha1GeneratorName
:
kubectl
.
CronJobV2Alpha1
{},
CronJobV1Beta1GeneratorName
:
kubectl
.
CronJobV1Beta1
{},
}
case
"autoscale"
:
generator
=
map
[
string
]
kubectl
.
Generator
{
...
...
pkg/kubectl/run.go
View file @
d7eec6b5
...
...
@@ -23,7 +23,6 @@ import (
appsv1beta1
"k8s.io/api/apps/v1beta1"
batchv1
"k8s.io/api/batch/v1"
batchv1beta1
"k8s.io/api/batch/v1beta1"
batchv2alpha1
"k8s.io/api/batch/v2alpha1"
"k8s.io/api/core/v1"
extensionsv1beta1
"k8s.io/api/extensions/v1beta1"
...
...
@@ -484,107 +483,6 @@ func (CronJobV2Alpha1) Generate(genericParams map[string]interface{}) (runtime.O
return
&
cronJob
,
nil
}
type
CronJobV1Beta1
struct
{}
func
(
CronJobV1Beta1
)
ParamNames
()
[]
GeneratorParam
{
return
[]
GeneratorParam
{
{
"labels"
,
false
},
{
"default-name"
,
false
},
{
"name"
,
true
},
{
"image"
,
true
},
{
"image-pull-policy"
,
false
},
{
"port"
,
false
},
{
"hostport"
,
false
},
{
"stdin"
,
false
},
{
"leave-stdin-open"
,
false
},
{
"tty"
,
false
},
{
"command"
,
false
},
{
"args"
,
false
},
{
"env"
,
false
},
{
"requests"
,
false
},
{
"limits"
,
false
},
{
"restart"
,
false
},
{
"schedule"
,
true
},
{
"serviceaccount"
,
false
},
}
}
func
(
CronJobV1Beta1
)
Generate
(
genericParams
map
[
string
]
interface
{})
(
runtime
.
Object
,
error
)
{
args
,
err
:=
getArgs
(
genericParams
)
if
err
!=
nil
{
return
nil
,
err
}
envs
,
err
:=
getEnvs
(
genericParams
)
if
err
!=
nil
{
return
nil
,
err
}
params
,
err
:=
getParams
(
genericParams
)
if
err
!=
nil
{
return
nil
,
err
}
name
,
err
:=
getName
(
params
)
if
err
!=
nil
{
return
nil
,
err
}
labels
,
err
:=
getLabels
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
podSpec
,
err
:=
makePodSpec
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
imagePullPolicy
:=
v1
.
PullPolicy
(
params
[
"image-pull-policy"
])
if
err
=
updatePodContainers
(
params
,
args
,
envs
,
imagePullPolicy
,
podSpec
);
err
!=
nil
{
return
nil
,
err
}
leaveStdinOpen
,
err
:=
GetBool
(
params
,
"leave-stdin-open"
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
podSpec
.
Containers
[
0
]
.
StdinOnce
=
!
leaveStdinOpen
&&
podSpec
.
Containers
[
0
]
.
Stdin
if
err
:=
updatePodPorts
(
params
,
podSpec
);
err
!=
nil
{
return
nil
,
err
}
restartPolicy
:=
v1
.
RestartPolicy
(
params
[
"restart"
])
if
len
(
restartPolicy
)
==
0
{
restartPolicy
=
v1
.
RestartPolicyNever
}
podSpec
.
RestartPolicy
=
restartPolicy
cronJob
:=
batchv1beta1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
name
,
Labels
:
labels
,
},
Spec
:
batchv1beta1
.
CronJobSpec
{
Schedule
:
params
[
"schedule"
],
ConcurrencyPolicy
:
batchv1beta1
.
AllowConcurrent
,
JobTemplate
:
batchv1beta1
.
JobTemplateSpec
{
Spec
:
batchv1
.
JobSpec
{
Template
:
v1
.
PodTemplateSpec
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
labels
,
},
Spec
:
*
podSpec
,
},
},
},
},
}
return
&
cronJob
,
nil
}
type
BasicReplicationController
struct
{}
func
(
BasicReplicationController
)
ParamNames
()
[]
GeneratorParam
{
...
...
pkg/kubectl/run_test.go
View file @
d7eec6b5
...
...
@@ -22,7 +22,6 @@ import (
appsv1beta1
"k8s.io/api/apps/v1beta1"
batchv1
"k8s.io/api/batch/v1"
batchv1beta1
"k8s.io/api/batch/v1beta1"
batchv2alpha1
"k8s.io/api/batch/v2alpha1"
"k8s.io/api/core/v1"
extensionsv1beta1
"k8s.io/api/extensions/v1beta1"
...
...
@@ -923,7 +922,7 @@ func TestGenerateJob(t *testing.T) {
}
}
func
TestGenerateCronJob
Alpha
(
t
*
testing
.
T
)
{
func
TestGenerateCronJob
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
params
map
[
string
]
interface
{}
expected
*
batchv2alpha1
.
CronJob
...
...
@@ -1021,104 +1020,6 @@ func TestGenerateCronJobAlpha(t *testing.T) {
}
}
func
TestGenerateCronJobBeta
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
params
map
[
string
]
interface
{}
expected
*
batchv1beta1
.
CronJob
expectErr
bool
}{
{
params
:
map
[
string
]
interface
{}{
"labels"
:
"foo=bar,baz=blah"
,
"name"
:
"foo"
,
"image"
:
"someimage"
,
"port"
:
"80"
,
"hostport"
:
"80"
,
"stdin"
:
"true"
,
"leave-stdin-open"
:
"true"
,
"command"
:
"true"
,
"args"
:
[]
string
{
"bar"
,
"baz"
,
"blah"
},
"env"
:
[]
string
{
"a=b"
,
"c=d"
},
"requests"
:
"cpu=100m,memory=100Mi"
,
"limits"
:
"cpu=400m,memory=200Mi"
,
"restart"
:
"OnFailure"
,
"schedule"
:
"0/5 * * * ?"
,
},
expected
:
&
batchv1beta1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"baz"
:
"blah"
},
},
Spec
:
batchv1beta1
.
CronJobSpec
{
Schedule
:
"0/5 * * * ?"
,
ConcurrencyPolicy
:
batchv1beta1
.
AllowConcurrent
,
JobTemplate
:
batchv1beta1
.
JobTemplateSpec
{
Spec
:
batchv1
.
JobSpec
{
Template
:
v1
.
PodTemplateSpec
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"baz"
:
"blah"
},
},
Spec
:
v1
.
PodSpec
{
RestartPolicy
:
v1
.
RestartPolicyOnFailure
,
Containers
:
[]
v1
.
Container
{
{
Name
:
"foo"
,
Image
:
"someimage"
,
Stdin
:
true
,
StdinOnce
:
false
,
Ports
:
[]
v1
.
ContainerPort
{
{
ContainerPort
:
80
,
HostPort
:
80
,
},
},
Command
:
[]
string
{
"bar"
,
"baz"
,
"blah"
},
Env
:
[]
v1
.
EnvVar
{
{
Name
:
"a"
,
Value
:
"b"
,
},
{
Name
:
"c"
,
Value
:
"d"
,
},
},
Resources
:
v1
.
ResourceRequirements
{
Requests
:
v1
.
ResourceList
{
v1
.
ResourceCPU
:
resource
.
MustParse
(
"100m"
),
v1
.
ResourceMemory
:
resource
.
MustParse
(
"100Mi"
),
},
Limits
:
v1
.
ResourceList
{
v1
.
ResourceCPU
:
resource
.
MustParse
(
"400m"
),
v1
.
ResourceMemory
:
resource
.
MustParse
(
"200Mi"
),
},
},
},
},
},
},
},
},
},
},
},
}
generator
:=
CronJobV1Beta1
{}
for
_
,
test
:=
range
tests
{
obj
,
err
:=
generator
.
Generate
(
test
.
params
)
if
!
test
.
expectErr
&&
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
if
test
.
expectErr
&&
err
!=
nil
{
continue
}
if
!
reflect
.
DeepEqual
(
obj
.
(
*
batchv1beta1
.
CronJob
),
test
.
expected
)
{
t
.
Errorf
(
"
\n
expected:
\n
%#v
\n
saw:
\n
%#v"
,
test
.
expected
,
obj
.
(
*
batchv1beta1
.
CronJob
))
}
}
}
func
TestParseEnv
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
envArray
[]
string
...
...
pkg/master/BUILD
View file @
d7eec6b5
...
...
@@ -73,7 +73,6 @@ go_library(
"//vendor/k8s.io/api/authorization/v1beta1:go_default_library",
"//vendor/k8s.io/api/autoscaling/v1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v1beta1:go_default_library",
"//vendor/k8s.io/api/certificates/v1beta1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
...
...
@@ -135,7 +134,7 @@ go_test(
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/autoscaling/v1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v
1bet
a1:go_default_library",
"//vendor/k8s.io/api/batch/v
2alph
a1:go_default_library",
"//vendor/k8s.io/api/certificates/v1beta1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
...
...
pkg/master/master.go
View file @
d7eec6b5
...
...
@@ -32,7 +32,6 @@ import (
authorizationapiv1beta1
"k8s.io/api/authorization/v1beta1"
autoscalingapiv1
"k8s.io/api/autoscaling/v1"
batchapiv1
"k8s.io/api/batch/v1"
batchapiv1beta1
"k8s.io/api/batch/v1beta1"
certificatesapiv1beta1
"k8s.io/api/certificates/v1beta1"
apiv1
"k8s.io/api/core/v1"
extensionsapiv1beta1
"k8s.io/api/extensions/v1beta1"
...
...
@@ -382,7 +381,9 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
apiv1
.
SchemeGroupVersion
,
extensionsapiv1beta1
.
SchemeGroupVersion
,
batchapiv1
.
SchemeGroupVersion
,
batchapiv1beta1
.
SchemeGroupVersion
,
// TODO: enable batch/v1beta1 by default before 1.8 release, after issues
// with CronJobs existing in multiple versions at once is solved
// batchapiv1beta1.SchemeGroupVersion,
authenticationv1
.
SchemeGroupVersion
,
authenticationv1beta1
.
SchemeGroupVersion
,
autoscalingapiv1
.
SchemeGroupVersion
,
...
...
pkg/master/master_test.go
View file @
d7eec6b5
...
...
@@ -29,7 +29,7 @@ import (
appsapiv1beta1
"k8s.io/api/apps/v1beta1"
autoscalingapiv1
"k8s.io/api/autoscaling/v1"
batchapiv1
"k8s.io/api/batch/v1"
batchapiv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchapiv
2alpha1
"k8s.io/api/batch/v2alph
a1"
certificatesapiv1beta1
"k8s.io/api/certificates/v1beta1"
apiv1
"k8s.io/api/core/v1"
extensionsapiv1beta1
"k8s.io/api/extensions/v1beta1"
...
...
@@ -80,8 +80,6 @@ func setUp(t *testing.T) (*etcdtesting.EtcdTestServer, Config, *assert.Assertion
resourceEncoding
.
SetVersionEncoding
(
api
.
GroupName
,
api
.
Registry
.
GroupOrDie
(
api
.
GroupName
)
.
GroupVersion
,
schema
.
GroupVersion
{
Group
:
api
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
autoscaling
.
GroupName
,
*
testapi
.
Autoscaling
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
autoscaling
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
batch
.
GroupName
,
*
testapi
.
Batch
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
// FIXME (soltysh): this GroupVersionResource override should be configurable
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
"batch"
,
Resource
:
"cronjobs"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
apps
.
GroupName
,
*
testapi
.
Apps
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
apps
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
extensions
.
GroupName
,
*
testapi
.
Extensions
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
extensions
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
rbac
.
GroupName
,
*
testapi
.
Rbac
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
rbac
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
...
...
@@ -195,7 +193,7 @@ func limitedAPIResourceConfigSource() *serverstorage.ResourceConfig {
apiv1
.
SchemeGroupVersion
,
extensionsapiv1beta1
.
SchemeGroupVersion
,
batchapiv1
.
SchemeGroupVersion
,
batchapiv
1bet
a1
.
SchemeGroupVersion
,
batchapiv
2alph
a1
.
SchemeGroupVersion
,
appsapiv1beta1
.
SchemeGroupVersion
,
autoscalingapiv1
.
SchemeGroupVersion
,
)
...
...
pkg/printers/internalversion/BUILD
View file @
d7eec6b5
...
...
@@ -88,7 +88,7 @@ go_library(
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/autoscaling/v2alpha1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v
1bet
a1:go_default_library",
"//vendor/k8s.io/api/batch/v
2alph
a1:go_default_library",
"//vendor/k8s.io/api/certificates/v1beta1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
...
...
pkg/printers/internalversion/printers.go
View file @
d7eec6b5
...
...
@@ -29,7 +29,7 @@ import (
appsv1beta1
"k8s.io/api/apps/v1beta1"
autoscalingv2alpha1
"k8s.io/api/autoscaling/v2alpha1"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
certificatesv1beta1
"k8s.io/api/certificates/v1beta1"
apiv1
"k8s.io/api/core/v1"
extensionsv1beta1
"k8s.io/api/extensions/v1beta1"
...
...
@@ -160,10 +160,10 @@ func AddHandlers(h printers.PrintHandler) {
cronJobColumnDefinitions
:=
[]
metav1alpha1
.
TableColumnDefinition
{
{
Name
:
"Name"
,
Type
:
"string"
,
Format
:
"name"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"name"
]},
{
Name
:
"Schedule"
,
Type
:
"string"
,
Description
:
batchv
1bet
a1
.
CronJobSpec
{}
.
SwaggerDoc
()[
"schedule"
]},
{
Name
:
"Suspend"
,
Type
:
"boolean"
,
Description
:
batchv
1bet
a1
.
CronJobSpec
{}
.
SwaggerDoc
()[
"suspend"
]},
{
Name
:
"Active"
,
Type
:
"integer"
,
Description
:
batchv
1bet
a1
.
CronJobStatus
{}
.
SwaggerDoc
()[
"active"
]},
{
Name
:
"Last Schedule"
,
Type
:
"string"
,
Description
:
batchv
1bet
a1
.
CronJobStatus
{}
.
SwaggerDoc
()[
"lastScheduleTime"
]},
{
Name
:
"Schedule"
,
Type
:
"string"
,
Description
:
batchv
2alph
a1
.
CronJobSpec
{}
.
SwaggerDoc
()[
"schedule"
]},
{
Name
:
"Suspend"
,
Type
:
"boolean"
,
Description
:
batchv
2alph
a1
.
CronJobSpec
{}
.
SwaggerDoc
()[
"suspend"
]},
{
Name
:
"Active"
,
Type
:
"integer"
,
Description
:
batchv
2alph
a1
.
CronJobStatus
{}
.
SwaggerDoc
()[
"active"
]},
{
Name
:
"Last Schedule"
,
Type
:
"string"
,
Description
:
batchv
2alph
a1
.
CronJobStatus
{}
.
SwaggerDoc
()[
"lastScheduleTime"
]},
{
Name
:
"Age"
,
Type
:
"string"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"creationTimestamp"
]},
{
Name
:
"Containers"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
"Names of each container in the template."
},
{
Name
:
"Images"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
"Images referenced by each container in the template."
},
...
...
test/e2e/apimachinery/BUILD
View file @
d7eec6b5
...
...
@@ -32,7 +32,7 @@ go_library(
"//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v
1bet
a1:go_default_library",
"//vendor/k8s.io/api/batch/v
2alph
a1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
"//vendor/k8s.io/api/rbac/v1beta1:go_default_library",
...
...
test/e2e/apimachinery/garbage_collector.go
View file @
d7eec6b5
...
...
@@ -21,7 +21,7 @@ import (
"time"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
apiextensionsv1beta1
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
...
...
@@ -66,7 +66,7 @@ func getNonOrphanOptions() *metav1.DeleteOptions {
var
(
zero
=
int64
(
0
)
CronJobGroupVersionResource
=
schema
.
GroupVersionResource
{
Group
:
batchv
1beta1
.
GroupName
,
Version
:
"v1bet
a1"
,
Resource
:
"cronjobs"
}
CronJobGroupVersionResource
=
schema
.
GroupVersionResource
{
Group
:
batchv
2alpha1
.
GroupName
,
Version
:
"v2alph
a1"
,
Resource
:
"cronjobs"
}
)
func
getPodTemplateSpec
(
labels
map
[
string
]
string
)
v1
.
PodTemplateSpec
{
...
...
@@ -264,19 +264,19 @@ func gatherMetrics(f *framework.Framework) {
}
}
func
newCronJob
(
name
,
schedule
string
)
*
batchv
1bet
a1
.
CronJob
{
func
newCronJob
(
name
,
schedule
string
)
*
batchv
2alph
a1
.
CronJob
{
parallelism
:=
int32
(
1
)
completions
:=
int32
(
1
)
return
&
batchv
1bet
a1
.
CronJob
{
return
&
batchv
2alph
a1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
name
,
},
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"CronJob"
,
},
Spec
:
batchv
1bet
a1
.
CronJobSpec
{
Spec
:
batchv
2alph
a1
.
CronJobSpec
{
Schedule
:
schedule
,
JobTemplate
:
batchv
1bet
a1
.
JobTemplateSpec
{
JobTemplate
:
batchv
2alph
a1
.
JobTemplateSpec
{
Spec
:
batchv1
.
JobSpec
{
Parallelism
:
&
parallelism
,
Completions
:
&
completions
,
...
...
@@ -940,7 +940,7 @@ var _ = SIGDescribe("Garbage collector", func() {
By
(
"Create the cronjob"
)
cronJob
:=
newCronJob
(
"simple"
,
"*/1 * * * ?"
)
cronJob
,
err
:=
f
.
ClientSet
.
BatchV
1bet
a1
()
.
CronJobs
(
f
.
Namespace
.
Name
)
.
Create
(
cronJob
)
cronJob
,
err
:=
f
.
ClientSet
.
BatchV
2alph
a1
()
.
CronJobs
(
f
.
Namespace
.
Name
)
.
Create
(
cronJob
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Wait for the CronJob to create new Job"
)
...
...
test/e2e/apimachinery/generated_clientset.go
View file @
d7eec6b5
...
...
@@ -21,7 +21,7 @@ import (
"time"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
...
...
@@ -212,20 +212,20 @@ var _ = SIGDescribe("Generated release_1_5 clientset", func() {
})
})
func
newTestingCronJob
(
name
string
,
value
string
)
*
batchv
1bet
a1
.
CronJob
{
func
newTestingCronJob
(
name
string
,
value
string
)
*
batchv
2alph
a1
.
CronJob
{
parallelism
:=
int32
(
1
)
completions
:=
int32
(
1
)
return
&
batchv
1bet
a1
.
CronJob
{
return
&
batchv
2alph
a1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
name
,
Labels
:
map
[
string
]
string
{
"time"
:
value
,
},
},
Spec
:
batchv
1bet
a1
.
CronJobSpec
{
Spec
:
batchv
2alph
a1
.
CronJobSpec
{
Schedule
:
"*/1 * * * ?"
,
ConcurrencyPolicy
:
batchv
1bet
a1
.
AllowConcurrent
,
JobTemplate
:
batchv
1bet
a1
.
JobTemplateSpec
{
ConcurrencyPolicy
:
batchv
2alph
a1
.
AllowConcurrent
,
JobTemplate
:
batchv
2alph
a1
.
JobTemplateSpec
{
Spec
:
batchv1
.
JobSpec
{
Parallelism
:
&
parallelism
,
Completions
:
&
completions
,
...
...
@@ -262,13 +262,25 @@ func newTestingCronJob(name string, value string) *batchv1beta1.CronJob {
var
_
=
SIGDescribe
(
"Generated release_1_5 clientset"
,
func
()
{
f
:=
framework
.
NewDefaultFramework
(
"clientset"
)
BeforeEach
(
func
()
{
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
CronJobGroupVersionResource
,
f
.
Namespace
.
Name
)
})
It
(
"should create v1beta1 cronJobs, delete cronJobs, watch cronJobs"
,
func
()
{
cronJobClient
:=
f
.
ClientSet
.
BatchV1beta1
()
.
CronJobs
(
f
.
Namespace
.
Name
)
It
(
"should create v2alpha1 cronJobs, delete cronJobs, watch cronJobs"
,
func
()
{
var
enabled
bool
groupList
,
err
:=
f
.
ClientSet
.
Discovery
()
.
ServerGroups
()
framework
.
ExpectNoError
(
err
)
for
_
,
group
:=
range
groupList
.
Groups
{
if
group
.
Name
==
batchv2alpha1
.
GroupName
{
for
_
,
version
:=
range
group
.
Versions
{
if
version
.
Version
==
batchv2alpha1
.
SchemeGroupVersion
.
Version
{
enabled
=
true
break
}
}
}
}
if
!
enabled
{
framework
.
Logf
(
"%s is not enabled, test skipped"
,
batchv2alpha1
.
SchemeGroupVersion
)
return
}
cronJobClient
:=
f
.
ClientSet
.
BatchV2alpha1
()
.
CronJobs
(
f
.
Namespace
.
Name
)
By
(
"constructing the cronJob"
)
name
:=
"cronjob"
+
string
(
uuid
.
NewUUID
())
value
:=
strconv
.
Itoa
(
time
.
Now
()
.
Nanosecond
())
...
...
test/e2e/apps/BUILD
View file @
d7eec6b5
...
...
@@ -24,6 +24,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/api/v1/pod:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/batch/v2alpha1:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/controller:go_default_library",
...
...
@@ -44,7 +45,7 @@ go_library(
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/apps/v1beta2:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v
1bet
a1:go_default_library",
"//vendor/k8s.io/api/batch/v
2alph
a1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
...
...
test/e2e/apps/cronjob.go
View file @
d7eec6b5
...
...
@@ -24,7 +24,7 @@ import (
.
"github.com/onsi/gomega"
batchv1
"k8s.io/api/batch/v1"
batchv
1beta1
"k8s.io/api/batch/v1bet
a1"
batchv
2alpha1
"k8s.io/api/batch/v2alph
a1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -51,13 +51,13 @@ var _ = SIGDescribe("CronJob", func() {
successCommand
:=
[]
string
{
"/bin/true"
}
BeforeEach
(
func
()
{
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
CronJobGroupVersionResource
Beta
,
f
.
Namespace
.
Name
)
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
CronJobGroupVersionResource
,
f
.
Namespace
.
Name
)
})
// multiple jobs running at once
It
(
"should schedule multiple jobs concurrently"
,
func
()
{
By
(
"Creating a cronjob"
)
cronJob
:=
newTestCronJob
(
"concurrent"
,
"*/1 * * * ?"
,
batchv
1bet
a1
.
AllowConcurrent
,
cronJob
:=
newTestCronJob
(
"concurrent"
,
"*/1 * * * ?"
,
batchv
2alph
a1
.
AllowConcurrent
,
sleepCommand
,
nil
)
cronJob
,
err
:=
createCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
@@ -80,7 +80,7 @@ var _ = SIGDescribe("CronJob", func() {
// suspended should not schedule jobs
It
(
"should not schedule jobs when suspended [Slow]"
,
func
()
{
By
(
"Creating a suspended cronjob"
)
cronJob
:=
newTestCronJob
(
"suspended"
,
"*/1 * * * ?"
,
batchv
1bet
a1
.
AllowConcurrent
,
cronJob
:=
newTestCronJob
(
"suspended"
,
"*/1 * * * ?"
,
batchv
2alph
a1
.
AllowConcurrent
,
sleepCommand
,
nil
)
t
:=
true
cronJob
.
Spec
.
Suspend
=
&
t
...
...
@@ -104,7 +104,7 @@ var _ = SIGDescribe("CronJob", func() {
// only single active job is allowed for ForbidConcurrent
It
(
"should not schedule new jobs when ForbidConcurrent [Slow]"
,
func
()
{
By
(
"Creating a ForbidConcurrent cronjob"
)
cronJob
:=
newTestCronJob
(
"forbid"
,
"*/1 * * * ?"
,
batchv
1bet
a1
.
ForbidConcurrent
,
cronJob
:=
newTestCronJob
(
"forbid"
,
"*/1 * * * ?"
,
batchv
2alph
a1
.
ForbidConcurrent
,
sleepCommand
,
nil
)
cronJob
,
err
:=
createCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
@@ -136,7 +136,7 @@ var _ = SIGDescribe("CronJob", func() {
// only single active job is allowed for ReplaceConcurrent
It
(
"should replace jobs when ReplaceConcurrent"
,
func
()
{
By
(
"Creating a ReplaceConcurrent cronjob"
)
cronJob
:=
newTestCronJob
(
"replace"
,
"*/1 * * * ?"
,
batchv
1bet
a1
.
ReplaceConcurrent
,
cronJob
:=
newTestCronJob
(
"replace"
,
"*/1 * * * ?"
,
batchv
2alph
a1
.
ReplaceConcurrent
,
sleepCommand
,
nil
)
cronJob
,
err
:=
createCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
@@ -168,7 +168,7 @@ var _ = SIGDescribe("CronJob", func() {
// shouldn't give us unexpected warnings
It
(
"should not emit unexpected warnings"
,
func
()
{
By
(
"Creating a cronjob"
)
cronJob
:=
newTestCronJob
(
"concurrent"
,
"*/1 * * * ?"
,
batchv
1bet
a1
.
AllowConcurrent
,
cronJob
:=
newTestCronJob
(
"concurrent"
,
"*/1 * * * ?"
,
batchv
2alph
a1
.
AllowConcurrent
,
nil
,
nil
)
cronJob
,
err
:=
createCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
@@ -191,7 +191,7 @@ var _ = SIGDescribe("CronJob", func() {
// deleted jobs should be removed from the active list
It
(
"should remove from active list jobs that have been deleted"
,
func
()
{
By
(
"Creating a ForbidConcurrent cronjob"
)
cronJob
:=
newTestCronJob
(
"forbid"
,
"*/1 * * * ?"
,
batchv
1bet
a1
.
ForbidConcurrent
,
cronJob
:=
newTestCronJob
(
"forbid"
,
"*/1 * * * ?"
,
batchv
2alph
a1
.
ForbidConcurrent
,
sleepCommand
,
nil
)
cronJob
,
err
:=
createCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
@@ -235,7 +235,7 @@ var _ = SIGDescribe("CronJob", func() {
It
(
"should delete successful finished jobs with limit of one successful job"
,
func
()
{
By
(
"Creating a AllowConcurrent cronjob with custom history limits"
)
successLimit
:=
int32
(
1
)
cronJob
:=
newTestCronJob
(
"concurrent-limit"
,
"*/1 * * * ?"
,
batchv
1bet
a1
.
AllowConcurrent
,
cronJob
:=
newTestCronJob
(
"concurrent-limit"
,
"*/1 * * * ?"
,
batchv
2alph
a1
.
AllowConcurrent
,
successCommand
,
&
successLimit
)
cronJob
,
err
:=
createCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
@@ -271,21 +271,21 @@ var _ = SIGDescribe("CronJob", func() {
})
// newTestCronJob returns a cronjob which does one of several testing behaviors.
func
newTestCronJob
(
name
,
schedule
string
,
concurrencyPolicy
batchv
1bet
a1
.
ConcurrencyPolicy
,
command
[]
string
,
successfulJobsHistoryLimit
*
int32
)
*
batchv
1bet
a1
.
CronJob
{
func
newTestCronJob
(
name
,
schedule
string
,
concurrencyPolicy
batchv
2alph
a1
.
ConcurrencyPolicy
,
command
[]
string
,
successfulJobsHistoryLimit
*
int32
)
*
batchv
2alph
a1
.
CronJob
{
parallelism
:=
int32
(
1
)
completions
:=
int32
(
1
)
sj
:=
&
batchv
1bet
a1
.
CronJob
{
sj
:=
&
batchv
2alph
a1
.
CronJob
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
name
,
},
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"CronJob"
,
},
Spec
:
batchv
1bet
a1
.
CronJobSpec
{
Spec
:
batchv
2alph
a1
.
CronJobSpec
{
Schedule
:
schedule
,
ConcurrencyPolicy
:
concurrencyPolicy
,
JobTemplate
:
batchv
1bet
a1
.
JobTemplateSpec
{
JobTemplate
:
batchv
2alph
a1
.
JobTemplateSpec
{
Spec
:
batchv1
.
JobSpec
{
Parallelism
:
&
parallelism
,
Completions
:
&
completions
,
...
...
@@ -325,22 +325,22 @@ func newTestCronJob(name, schedule string, concurrencyPolicy batchv1beta1.Concur
return
sj
}
func
createCronJob
(
c
clientset
.
Interface
,
ns
string
,
cronJob
*
batchv
1beta1
.
CronJob
)
(
*
batchv1bet
a1
.
CronJob
,
error
)
{
return
c
.
BatchV
1bet
a1
()
.
CronJobs
(
ns
)
.
Create
(
cronJob
)
func
createCronJob
(
c
clientset
.
Interface
,
ns
string
,
cronJob
*
batchv
2alpha1
.
CronJob
)
(
*
batchv2alph
a1
.
CronJob
,
error
)
{
return
c
.
BatchV
2alph
a1
()
.
CronJobs
(
ns
)
.
Create
(
cronJob
)
}
func
getCronJob
(
c
clientset
.
Interface
,
ns
,
name
string
)
(
*
batchv
1bet
a1
.
CronJob
,
error
)
{
return
c
.
BatchV
1bet
a1
()
.
CronJobs
(
ns
)
.
Get
(
name
,
metav1
.
GetOptions
{})
func
getCronJob
(
c
clientset
.
Interface
,
ns
,
name
string
)
(
*
batchv
2alph
a1
.
CronJob
,
error
)
{
return
c
.
BatchV
2alph
a1
()
.
CronJobs
(
ns
)
.
Get
(
name
,
metav1
.
GetOptions
{})
}
func
deleteCronJob
(
c
clientset
.
Interface
,
ns
,
name
string
)
error
{
return
c
.
BatchV
1bet
a1
()
.
CronJobs
(
ns
)
.
Delete
(
name
,
nil
)
return
c
.
BatchV
2alph
a1
()
.
CronJobs
(
ns
)
.
Delete
(
name
,
nil
)
}
// Wait for at least given amount of active jobs.
func
waitForActiveJobs
(
c
clientset
.
Interface
,
ns
,
cronJobName
string
,
active
int
)
error
{
return
wait
.
Poll
(
framework
.
Poll
,
cronJobTimeout
,
func
()
(
bool
,
error
)
{
curr
,
err
:=
c
.
BatchV
1bet
a1
()
.
CronJobs
(
ns
)
.
Get
(
cronJobName
,
metav1
.
GetOptions
{})
curr
,
err
:=
c
.
BatchV
2alph
a1
()
.
CronJobs
(
ns
)
.
Get
(
cronJobName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
false
,
err
}
...
...
@@ -354,7 +354,7 @@ func waitForActiveJobs(c clientset.Interface, ns, cronJobName string, active int
// empty after the timeout.
func
waitForNoJobs
(
c
clientset
.
Interface
,
ns
,
jobName
string
,
failIfNonEmpty
bool
)
error
{
return
wait
.
Poll
(
framework
.
Poll
,
cronJobTimeout
,
func
()
(
bool
,
error
)
{
curr
,
err
:=
c
.
BatchV
1bet
a1
()
.
CronJobs
(
ns
)
.
Get
(
jobName
,
metav1
.
GetOptions
{})
curr
,
err
:=
c
.
BatchV
2alph
a1
()
.
CronJobs
(
ns
)
.
Get
(
jobName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
false
,
err
}
...
...
@@ -432,7 +432,7 @@ func waitForAnyFinishedJob(c clientset.Interface, ns string) error {
// checkNoEventWithReason checks no events with a reason within a list has occured
func
checkNoEventWithReason
(
c
clientset
.
Interface
,
ns
,
cronJobName
string
,
reasons
[]
string
)
error
{
sj
,
err
:=
c
.
BatchV
1bet
a1
()
.
CronJobs
(
ns
)
.
Get
(
cronJobName
,
metav1
.
GetOptions
{})
sj
,
err
:=
c
.
BatchV
2alph
a1
()
.
CronJobs
(
ns
)
.
Get
(
cronJobName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error in getting cronjob %s/%s: %v"
,
ns
,
cronJobName
,
err
)
}
...
...
test/e2e/apps/types.go
View file @
d7eec6b5
...
...
@@ -18,6 +18,7 @@ package apps
import
(
"k8s.io/apimachinery/pkg/runtime/schema"
batchv2alpha1
"k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
)
const
(
...
...
@@ -31,6 +32,5 @@ const (
)
var
(
CronJobGroupVersionResourceAlpha
=
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v2alpha1"
,
Resource
:
"cronjobs"
}
CronJobGroupVersionResourceBeta
=
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v1beta1"
,
Resource
:
"cronjobs"
}
CronJobGroupVersionResource
=
schema
.
GroupVersionResource
{
Group
:
batchv2alpha1
.
GroupName
,
Version
:
"v2alpha1"
,
Resource
:
"cronjobs"
}
)
test/e2e/kubectl/BUILD
View file @
d7eec6b5
...
...
@@ -13,6 +13,7 @@ go_library(
"portforward.go",
],
deps = [
"//pkg/apis/batch/v2alpha1:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/kubectl/cmd/util:go_default_library",
"//pkg/util/version:go_default_library",
...
...
test/e2e/kubectl/kubectl.go
View file @
d7eec6b5
...
...
@@ -56,6 +56,7 @@ import (
"k8s.io/apiserver/pkg/authentication/serviceaccount"
genericregistry
"k8s.io/apiserver/pkg/registry/generic/registry"
clientset
"k8s.io/client-go/kubernetes"
batchv2alpha1
"k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
utilversion
"k8s.io/kubernetes/pkg/util/version"
...
...
@@ -144,8 +145,7 @@ var (
// so we don't expect tests that verifies return code to work on kubectl clients before that.
kubectlContainerExitCodeVersion
=
utilversion
.
MustParseSemantic
(
"v1.4.0-alpha.3"
)
CronJobGroupVersionResourceAlpha
=
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v2alpha1"
,
Resource
:
"cronjobs"
}
CronJobGroupVersionResourceBeta
=
schema
.
GroupVersionResource
{
Group
:
"batch"
,
Version
:
"v1beta1"
,
Resource
:
"cronjobs"
}
CronJobGroupVersionResource
=
schema
.
GroupVersionResource
{
Group
:
batchv2alpha1
.
GroupName
,
Version
:
"v2alpha1"
,
Resource
:
"cronjobs"
}
)
// Stops everything from filePath from namespace ns and checks if everything matching selectors from the given namespace is correctly stopped.
...
...
@@ -203,15 +203,15 @@ var _ = SIGDescribe("Kubectl alpha client", func() {
BeforeEach
(
func
()
{
nsFlag
=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
cjName
=
"e2e-test-echo-cronjob
-alpha
"
cjName
=
"e2e-test-echo-cronjob"
})
AfterEach
(
func
()
{
framework
.
RunKubectlOrDie
(
"delete"
,
"cronjob
.v2alpha1.batch
"
,
cjName
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"delete"
,
"cronjob
s
"
,
cjName
,
nsFlag
)
})
It
(
"should create a CronJob"
,
func
()
{
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
CronJobGroupVersionResource
Alpha
,
f
.
Namespace
.
Name
)
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
CronJobGroupVersionResource
,
f
.
Namespace
.
Name
)
schedule
:=
"*/5 * * * ?"
framework
.
RunKubectlOrDie
(
"run"
,
cjName
,
"--restart=OnFailure"
,
"--generator=cronjob/v2alpha1"
,
...
...
@@ -1347,43 +1347,6 @@ metadata:
})
})
framework
.
KubeDescribe
(
"Kubectl run CronJob"
,
func
()
{
var
nsFlag
string
var
cjName
string
BeforeEach
(
func
()
{
nsFlag
=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
cjName
=
"e2e-test-echo-cronjob-beta"
})
AfterEach
(
func
()
{
framework
.
RunKubectlOrDie
(
"delete"
,
"cronjob.v1beta1.batch"
,
cjName
,
nsFlag
)
})
It
(
"should create a CronJob"
,
func
()
{
framework
.
SkipIfMissingResource
(
f
.
ClientPool
,
CronJobGroupVersionResourceBeta
,
f
.
Namespace
.
Name
)
schedule
:=
"*/5 * * * ?"
framework
.
RunKubectlOrDie
(
"run"
,
cjName
,
"--restart=OnFailure"
,
"--generator=cronjob/v1beta1"
,
"--schedule="
+
schedule
,
"--image="
+
busyboxImage
,
nsFlag
)
By
(
"verifying the CronJob "
+
cjName
+
" was created"
)
cj
,
err
:=
c
.
BatchV1beta1
()
.
CronJobs
(
ns
)
.
Get
(
cjName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
framework
.
Failf
(
"Failed getting CronJob %s: %v"
,
cjName
,
err
)
}
if
cj
.
Spec
.
Schedule
!=
schedule
{
framework
.
Failf
(
"Failed creating a CronJob with correct schedule %s"
,
schedule
)
}
containers
:=
cj
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
.
Containers
if
containers
==
nil
||
len
(
containers
)
!=
1
||
containers
[
0
]
.
Image
!=
busyboxImage
{
framework
.
Failf
(
"Failed creating CronJob %s for 1 pod with expected image %s: %#v"
,
cjName
,
busyboxImage
,
containers
)
}
if
cj
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
.
RestartPolicy
!=
v1
.
RestartPolicyOnFailure
{
framework
.
Failf
(
"Failed creating a CronJob with correct restart policy for --restart=OnFailure"
)
}
})
})
framework
.
KubeDescribe
(
"Kubectl run pod"
,
func
()
{
var
nsFlag
string
var
podName
string
...
...
test/integration/etcd/etcd_storage_path_test.go
View file @
d7eec6b5
...
...
@@ -201,6 +201,8 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
gvr
(
"batch"
,
"v1beta1"
,
"cronjobs"
)
:
{
stub
:
`{"metadata": {"name": "cjv1beta1"}, "spec": {"jobTemplate": {"spec": {"template": {"metadata": {"labels": {"controller-uid": "uid0"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container0"}], "dnsPolicy": "ClusterFirst", "restartPolicy": "Never"}}}}, "schedule": "* * * * *"}}`
,
expectedEtcdPath
:
"/registry/cronjobs/etcdstoragepathtestnamespace/cjv1beta1"
,
// TODO this needs to be updated to batch/v1beta1 when it's enabed by default
expectedGVK
:
gvkP
(
"batch"
,
"v2alpha1"
,
"CronJob"
),
},
// --
...
...
@@ -208,7 +210,6 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
gvr
(
"batch"
,
"v2alpha1"
,
"cronjobs"
)
:
{
stub
:
`{"metadata": {"name": "cjv2alpha1"}, "spec": {"jobTemplate": {"spec": {"template": {"metadata": {"labels": {"controller-uid": "uid0"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container0"}], "dnsPolicy": "ClusterFirst", "restartPolicy": "Never"}}}}, "schedule": "* * * * *"}}`
,
expectedEtcdPath
:
"/registry/cronjobs/etcdstoragepathtestnamespace/cjv2alpha1"
,
expectedGVK
:
gvkP
(
"batch"
,
"v1beta1"
,
"CronJob"
),
},
// --
...
...
test/integration/framework/master_utils.go
View file @
d7eec6b5
...
...
@@ -300,13 +300,7 @@ func NewMasterConfig() *master.Config {
info
,
_
:=
runtime
.
SerializerInfoForMediaType
(
api
.
Codecs
.
SupportedMediaTypes
(),
runtime
.
ContentTypeJSON
)
ns
:=
NewSingleContentTypeSerializer
(
api
.
Scheme
,
info
)
resourceEncoding
:=
serverstorage
.
NewDefaultResourceEncodingConfig
(
api
.
Registry
)
// FIXME (soltysh): this GroupVersionResource override should be configurable
// we need to set both for the whole group and for cronjobs, separately
resourceEncoding
.
SetVersionEncoding
(
batch
.
GroupName
,
*
testapi
.
Batch
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
"batch"
,
Resource
:
"cronjobs"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
storageFactory
:=
serverstorage
.
NewDefaultStorageFactory
(
etcdOptions
.
StorageConfig
,
runtime
.
ContentTypeJSON
,
ns
,
resourceEncoding
,
master
.
DefaultAPIResourceConfigSource
())
storageFactory
:=
serverstorage
.
NewDefaultStorageFactory
(
etcdOptions
.
StorageConfig
,
runtime
.
ContentTypeJSON
,
ns
,
serverstorage
.
NewDefaultResourceEncodingConfig
(
api
.
Registry
),
master
.
DefaultAPIResourceConfigSource
())
storageFactory
.
SetSerializer
(
schema
.
GroupResource
{
Group
:
v1
.
GroupName
,
Resource
:
serverstorage
.
AllResources
},
""
,
...
...
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