Commit 41d88d30 authored by Maciej Szulik's avatar Maciej Szulik

Rename ScheduledJob to CronJob

parent 0c7421fb
......@@ -172,7 +172,7 @@ func Run(s *options.ServerRunOptions) error {
s.GenericServerRunOptions.StorageConfig, s.GenericServerRunOptions.DefaultStorageMediaType, api.Codecs,
genericapiserver.NewDefaultResourceEncodingConfig(), storageGroupsToEncodingVersion,
// FIXME: this GroupVersionResource override should be configurable
[]unversioned.GroupVersionResource{batch.Resource("scheduledjobs").WithVersion("v2alpha1")},
[]unversioned.GroupVersionResource{batch.Resource("cronjobs").WithVersion("v2alpha1")},
master.DefaultAPIResourceConfigSource(), s.GenericServerRunOptions.RuntimeConfig)
if err != nil {
glog.Fatalf("error in initializing storage factory: %s", err)
......
......@@ -41,6 +41,7 @@ go_library(
"//pkg/cloudprovider/providers/vsphere:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller/certificates:go_default_library",
"//pkg/controller/cronjob:go_default_library",
"//pkg/controller/daemon:go_default_library",
"//pkg/controller/deployment:go_default_library",
"//pkg/controller/disruption:go_default_library",
......@@ -59,7 +60,6 @@ go_library(
"//pkg/controller/replication:go_default_library",
"//pkg/controller/resourcequota:go_default_library",
"//pkg/controller/route:go_default_library",
"//pkg/controller/scheduledjob:go_default_library",
"//pkg/controller/service:go_default_library",
"//pkg/controller/serviceaccount:go_default_library",
"//pkg/controller/volume/attachdetach:go_default_library",
......
......@@ -47,6 +47,7 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/controller"
certcontroller "k8s.io/kubernetes/pkg/controller/certificates"
"k8s.io/kubernetes/pkg/controller/cronjob"
"k8s.io/kubernetes/pkg/controller/daemon"
"k8s.io/kubernetes/pkg/controller/deployment"
"k8s.io/kubernetes/pkg/controller/disruption"
......@@ -65,7 +66,6 @@ import (
replicationcontroller "k8s.io/kubernetes/pkg/controller/replication"
resourcequotacontroller "k8s.io/kubernetes/pkg/controller/resourcequota"
routecontroller "k8s.io/kubernetes/pkg/controller/route"
"k8s.io/kubernetes/pkg/controller/scheduledjob"
servicecontroller "k8s.io/kubernetes/pkg/controller/service"
serviceaccountcontroller "k8s.io/kubernetes/pkg/controller/serviceaccount"
"k8s.io/kubernetes/pkg/controller/volume/attachdetach"
......@@ -466,11 +466,11 @@ func StartControllers(s *options.CMServer, kubeconfig *restclient.Config, rootCl
resources, found = resourceMap[groupVersion]
if containsVersion(versions, groupVersion) && found {
glog.Infof("Starting %s apis", groupVersion)
if containsResource(resources, "scheduledjobs") {
glog.Infof("Starting scheduledjob controller")
if containsResource(resources, "cronjobs") {
glog.Infof("Starting cronjob controller")
// // TODO: this is a temp fix for allowing kubeClient list v2alpha1 sj, should switch to using clientset
kubeconfig.ContentConfig.GroupVersion = &unversioned.GroupVersion{Group: batch.GroupName, Version: "v2alpha1"}
go scheduledjob.NewScheduledJobController(client("scheduledjob-controller")).
go cronjob.NewCronJobController(client("cronjob-controller")).
Run(wait.NeverStop)
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))
time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))
......
......@@ -83,11 +83,11 @@ func TestDefaulting(t *testing.T) {
{Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscalerList"}: {},
{Group: "batch", Version: "v1", Kind: "Job"}: {},
{Group: "batch", Version: "v1", Kind: "JobList"}: {},
{Group: "batch", Version: "v2alpha1", Kind: "CronJob"}: {},
{Group: "batch", Version: "v2alpha1", Kind: "CronJobList"}: {},
{Group: "batch", Version: "v2alpha1", Kind: "Job"}: {},
{Group: "batch", Version: "v2alpha1", Kind: "JobList"}: {},
{Group: "batch", Version: "v2alpha1", Kind: "JobTemplate"}: {},
{Group: "batch", Version: "v2alpha1", Kind: "ScheduledJob"}: {},
{Group: "batch", Version: "v2alpha1", Kind: "ScheduledJobList"}: {},
{Group: "componentconfig", Version: "v1alpha1", Kind: "KubeProxyConfiguration"}: {},
{Group: "componentconfig", Version: "v1alpha1", Kind: "KubeSchedulerConfiguration"}: {},
{Group: "componentconfig", Version: "v1alpha1", Kind: "KubeletConfiguration"}: {},
......
......@@ -172,7 +172,7 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source)
j.ManualSelector = nil
}
},
func(sj *batch.ScheduledJobSpec, c fuzz.Continue) {
func(sj *batch.CronJobSpec, c fuzz.Continue) {
c.FuzzNoCustom(sj)
suspend := c.RandBool()
sj.Suspend = &suspend
......
......@@ -49,8 +49,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&Job{},
&JobList{},
&JobTemplate{},
&ScheduledJob{},
&ScheduledJobList{},
&CronJob{},
&CronJobList{},
&api.ListOptions{},
)
return nil
......
......@@ -190,8 +190,8 @@ type JobCondition struct {
// +genclient=true
// ScheduledJob represents the configuration of a single scheduled job.
type ScheduledJob struct {
// CronJob represents the configuration of a single cron job.
type CronJob struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
......@@ -201,28 +201,28 @@ type ScheduledJob struct {
// Spec is a structure defining the expected behavior of a job, including the schedule.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
// +optional
Spec ScheduledJobSpec `json:"spec,omitempty"`
Spec CronJobSpec `json:"spec,omitempty"`
// Status is a structure describing current status of a job.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
// +optional
Status ScheduledJobStatus `json:"status,omitempty"`
Status CronJobStatus `json:"status,omitempty"`
}
// ScheduledJobList is a collection of scheduled jobs.
type ScheduledJobList struct {
// CronJobList is a collection of cron jobs.
type CronJobList struct {
unversioned.TypeMeta `json:",inline"`
// Standard list metadata
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional
unversioned.ListMeta `json:"metadata,omitempty"`
// Items is the list of ScheduledJob.
Items []ScheduledJob `json:"items"`
// Items is the list of CronJob.
Items []CronJob `json:"items"`
}
// ScheduledJobSpec describes how the job execution will look like and when it will actually run.
type ScheduledJobSpec struct {
// CronJobSpec describes how the job execution will look like and when it will actually run.
type CronJobSpec struct {
// Schedule contains the schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
Schedule string `json:"schedule"`
......@@ -242,7 +242,7 @@ type ScheduledJobSpec struct {
Suspend *bool `json:"suspend,omitempty"`
// JobTemplate is the object that describes the job that will be created when
// executing a ScheduledJob.
// executing a CronJob.
JobTemplate JobTemplateSpec `json:"jobTemplate"`
}
......@@ -253,7 +253,7 @@ type ScheduledJobSpec struct {
type ConcurrencyPolicy string
const (
// AllowConcurrent allows ScheduledJobs to run concurrently.
// AllowConcurrent allows CronJobs to run concurrently.
AllowConcurrent ConcurrencyPolicy = "Allow"
// ForbidConcurrent forbids concurrent runs, skipping next run if previous
......@@ -264,8 +264,8 @@ const (
ReplaceConcurrent ConcurrencyPolicy = "Replace"
)
// ScheduledJobStatus represents the current state of a Job.
type ScheduledJobStatus struct {
// CronJobStatus represents the current state of a cron job.
type CronJobStatus struct {
// Active holds pointers to currently running jobs.
// +optional
Active []api.ObjectReference `json:"active,omitempty"`
......
......@@ -37,7 +37,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
}
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
for _, kind := range []string{"Job", "JobTemplate", "ScheduledJob"} {
for _, kind := range []string{"Job", "JobTemplate", "CronJob"} {
err = api.Scheme.AddFieldLabelConversionFunc("batch/v2alpha1", kind,
func(label, value string) (string, string, error) {
switch label {
......
......@@ -24,7 +24,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
RegisterDefaults(scheme)
return scheme.AddDefaultingFuncs(
SetDefaults_Job,
SetDefaults_ScheduledJob,
SetDefaults_CronJob,
)
}
......@@ -47,7 +47,7 @@ func SetDefaults_Job(obj *Job) {
}
}
func SetDefaults_ScheduledJob(obj *ScheduledJob) {
func SetDefaults_CronJob(obj *CronJob) {
if obj.Spec.ConcurrencyPolicy == "" {
obj.Spec.ConcurrencyPolicy = AllowConcurrent
}
......
......@@ -40,8 +40,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&Job{},
&JobList{},
&JobTemplate{},
&ScheduledJob{},
&ScheduledJobList{},
&CronJob{},
&CronJobList{},
&v1.ListOptions{},
&v1.DeleteOptions{},
)
......
......@@ -196,8 +196,8 @@ type JobCondition struct {
// +genclient=true
// ScheduledJob represents the configuration of a single scheduled job.
type ScheduledJob struct {
// CronJob represents the configuration of a single cron job.
type CronJob struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
......@@ -207,28 +207,28 @@ type ScheduledJob struct {
// Spec is a structure defining the expected behavior of a job, including the schedule.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
// +optional
Spec ScheduledJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
// Status is a structure describing current status of a job.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
// +optional
Status ScheduledJobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
Status CronJobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// ScheduledJobList is a collection of scheduled jobs.
type ScheduledJobList struct {
// CronJobList is a collection of cron jobs.
type CronJobList struct {
unversioned.TypeMeta `json:",inline"`
// Standard list metadata
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional
unversioned.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is the list of ScheduledJob.
Items []ScheduledJob `json:"items" protobuf:"bytes,2,rep,name=items"`
// Items is the list of CronJob.
Items []CronJob `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// ScheduledJobSpec describes how the job execution will look like and when it will actually run.
type ScheduledJobSpec struct {
// CronJobSpec describes how the job execution will look like and when it will actually run.
type CronJobSpec struct {
// Schedule contains the schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
Schedule string `json:"schedule" protobuf:"bytes,1,opt,name=schedule"`
......@@ -248,7 +248,7 @@ type ScheduledJobSpec struct {
Suspend *bool `json:"suspend,omitempty" protobuf:"varint,4,opt,name=suspend"`
// JobTemplate is the object that describes the job that will be created when
// executing a ScheduledJob.
// executing a CronJob.
JobTemplate JobTemplateSpec `json:"jobTemplate" protobuf:"bytes,5,opt,name=jobTemplate"`
}
......@@ -259,7 +259,7 @@ type ScheduledJobSpec struct {
type ConcurrencyPolicy string
const (
// AllowConcurrent allows ScheduledJobs to run concurrently.
// AllowConcurrent allows CronJobs to run concurrently.
AllowConcurrent ConcurrencyPolicy = "Allow"
// ForbidConcurrent forbids concurrent runs, skipping next run if previous
......@@ -270,8 +270,8 @@ const (
ReplaceConcurrent ConcurrencyPolicy = "Replace"
)
// ScheduledJobStatus represents the current state of a Job.
type ScheduledJobStatus struct {
// CronJobStatus represents the current state of a cron job.
type CronJobStatus struct {
// Active holds pointers to currently running jobs.
// +optional
Active []v1.ObjectReference `json:"active,omitempty" protobuf:"bytes,1,rep,name=active"`
......
......@@ -110,48 +110,48 @@ func (JobTemplateSpec) SwaggerDoc() map[string]string {
return map_JobTemplateSpec
}
var map_ScheduledJob = map[string]string{
"": "ScheduledJob represents the configuration of a single scheduled job.",
var map_CronJob = map[string]string{
"": "CronJob represents the configuration of a single scheduled job.",
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"spec": "Spec is a structure defining the expected behavior of a job, including the schedule. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
"status": "Status is a structure describing current status of a job. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
}
func (ScheduledJob) SwaggerDoc() map[string]string {
return map_ScheduledJob
func (CronJob) SwaggerDoc() map[string]string {
return map_CronJob
}
var map_ScheduledJobList = map[string]string{
"": "ScheduledJobList is a collection of scheduled jobs.",
var map_CronJobList = map[string]string{
"": "CronJobList is a collection of scheduled jobs.",
"metadata": "Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"items": "Items is the list of ScheduledJob.",
"items": "Items is the list of CronJob.",
}
func (ScheduledJobList) SwaggerDoc() map[string]string {
return map_ScheduledJobList
func (CronJobList) SwaggerDoc() map[string]string {
return map_CronJobList
}
var map_ScheduledJobSpec = map[string]string{
"": "ScheduledJobSpec describes how the job execution will look like and when it will actually run.",
var map_CronJobSpec = map[string]string{
"": "CronJobSpec describes how the job execution will look like and when it will actually run.",
"schedule": "Schedule contains the schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.",
"startingDeadlineSeconds": "Optional deadline in seconds for starting the job if it misses scheduled time for any reason. Missed jobs executions will be counted as failed ones.",
"concurrencyPolicy": "ConcurrencyPolicy specifies how to treat concurrent executions of a Job.",
"suspend": "Suspend flag tells the controller to suspend subsequent executions, it does not apply to already started executions. Defaults to false.",
"jobTemplate": "JobTemplate is the object that describes the job that will be created when executing a ScheduledJob.",
"jobTemplate": "JobTemplate is the object that describes the job that will be created when executing a CronJob.",
}
func (ScheduledJobSpec) SwaggerDoc() map[string]string {
return map_ScheduledJobSpec
func (CronJobSpec) SwaggerDoc() map[string]string {
return map_CronJobSpec
}
var map_ScheduledJobStatus = map[string]string{
"": "ScheduledJobStatus represents the current state of a Job.",
var map_CronJobStatus = map[string]string{
"": "CronJobStatus represents the current state of a Job.",
"active": "Active holds pointers to currently running jobs.",
"lastScheduleTime": "LastScheduleTime keeps information of when was the last time the job was successfully scheduled.",
}
func (ScheduledJobStatus) SwaggerDoc() map[string]string {
return map_ScheduledJobStatus
func (CronJobStatus) SwaggerDoc() map[string]string {
return map_CronJobStatus
}
// AUTO-GENERATED FUNCTIONS END HERE
......@@ -36,6 +36,10 @@ func init() {
// to allow building arbitrary schemes.
func RegisterDeepCopies(scheme *runtime.Scheme) error {
return scheme.AddGeneratedDeepCopyFuncs(
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_CronJob, InType: reflect.TypeOf(&CronJob{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_CronJobList, InType: reflect.TypeOf(&CronJobList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_CronJobSpec, InType: reflect.TypeOf(&CronJobSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_CronJobStatus, InType: reflect.TypeOf(&CronJobStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_Job, InType: reflect.TypeOf(&Job{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_JobCondition, InType: reflect.TypeOf(&JobCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_JobList, InType: reflect.TypeOf(&JobList{})},
......@@ -43,13 +47,99 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_JobStatus, InType: reflect.TypeOf(&JobStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_JobTemplate, InType: reflect.TypeOf(&JobTemplate{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_JobTemplateSpec, InType: reflect.TypeOf(&JobTemplateSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_ScheduledJob, InType: reflect.TypeOf(&ScheduledJob{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_ScheduledJobList, InType: reflect.TypeOf(&ScheduledJobList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_ScheduledJobSpec, InType: reflect.TypeOf(&ScheduledJobSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v2alpha1_ScheduledJobStatus, InType: reflect.TypeOf(&ScheduledJobStatus{})},
)
}
func DeepCopy_v2alpha1_CronJob(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJob)
out := out.(*CronJob)
out.TypeMeta = in.TypeMeta
if err := v1.DeepCopy_v1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := DeepCopy_v2alpha1_CronJobSpec(&in.Spec, &out.Spec, c); err != nil {
return err
}
if err := DeepCopy_v2alpha1_CronJobStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v2alpha1_CronJobList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJobList)
out := out.(*CronJobList)
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]CronJob, len(*in))
for i := range *in {
if err := DeepCopy_v2alpha1_CronJob(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
}
func DeepCopy_v2alpha1_CronJobSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJobSpec)
out := out.(*CronJobSpec)
out.Schedule = in.Schedule
if in.StartingDeadlineSeconds != nil {
in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds
*out = new(int64)
**out = **in
} else {
out.StartingDeadlineSeconds = nil
}
out.ConcurrencyPolicy = in.ConcurrencyPolicy
if in.Suspend != nil {
in, out := &in.Suspend, &out.Suspend
*out = new(bool)
**out = **in
} else {
out.Suspend = nil
}
if err := DeepCopy_v2alpha1_JobTemplateSpec(&in.JobTemplate, &out.JobTemplate, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v2alpha1_CronJobStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJobStatus)
out := out.(*CronJobStatus)
if in.Active != nil {
in, out := &in.Active, &out.Active
*out = make([]v1.ObjectReference, len(*in))
for i := range *in {
(*out)[i] = (*in)[i]
}
} else {
out.Active = nil
}
if in.LastScheduleTime != nil {
in, out := &in.LastScheduleTime, &out.LastScheduleTime
*out = new(unversioned.Time)
**out = (*in).DeepCopy()
} else {
out.LastScheduleTime = nil
}
return nil
}
}
func DeepCopy_v2alpha1_Job(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Job)
......@@ -215,93 +305,3 @@ func DeepCopy_v2alpha1_JobTemplateSpec(in interface{}, out interface{}, c *conve
return nil
}
}
func DeepCopy_v2alpha1_ScheduledJob(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJob)
out := out.(*ScheduledJob)
out.TypeMeta = in.TypeMeta
if err := v1.DeepCopy_v1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := DeepCopy_v2alpha1_ScheduledJobSpec(&in.Spec, &out.Spec, c); err != nil {
return err
}
if err := DeepCopy_v2alpha1_ScheduledJobStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v2alpha1_ScheduledJobList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJobList)
out := out.(*ScheduledJobList)
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ScheduledJob, len(*in))
for i := range *in {
if err := DeepCopy_v2alpha1_ScheduledJob(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
}
func DeepCopy_v2alpha1_ScheduledJobSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJobSpec)
out := out.(*ScheduledJobSpec)
out.Schedule = in.Schedule
if in.StartingDeadlineSeconds != nil {
in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds
*out = new(int64)
**out = **in
} else {
out.StartingDeadlineSeconds = nil
}
out.ConcurrencyPolicy = in.ConcurrencyPolicy
if in.Suspend != nil {
in, out := &in.Suspend, &out.Suspend
*out = new(bool)
**out = **in
} else {
out.Suspend = nil
}
if err := DeepCopy_v2alpha1_JobTemplateSpec(&in.JobTemplate, &out.JobTemplate, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_v2alpha1_ScheduledJobStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJobStatus)
out := out.(*ScheduledJobStatus)
if in.Active != nil {
in, out := &in.Active, &out.Active
*out = make([]v1.ObjectReference, len(*in))
for i := range *in {
(*out)[i] = (*in)[i]
}
} else {
out.Active = nil
}
if in.LastScheduleTime != nil {
in, out := &in.LastScheduleTime, &out.LastScheduleTime
*out = new(unversioned.Time)
**out = (*in).DeepCopy()
} else {
out.LastScheduleTime = nil
}
return nil
}
}
......@@ -29,19 +29,19 @@ import (
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
scheme.AddTypeDefaultingFunc(&CronJob{}, func(obj interface{}) { SetObjectDefaults_CronJob(obj.(*CronJob)) })
scheme.AddTypeDefaultingFunc(&CronJobList{}, func(obj interface{}) { SetObjectDefaults_CronJobList(obj.(*CronJobList)) })
scheme.AddTypeDefaultingFunc(&Job{}, func(obj interface{}) { SetObjectDefaults_Job(obj.(*Job)) })
scheme.AddTypeDefaultingFunc(&JobList{}, func(obj interface{}) { SetObjectDefaults_JobList(obj.(*JobList)) })
scheme.AddTypeDefaultingFunc(&JobTemplate{}, func(obj interface{}) { SetObjectDefaults_JobTemplate(obj.(*JobTemplate)) })
scheme.AddTypeDefaultingFunc(&ScheduledJob{}, func(obj interface{}) { SetObjectDefaults_ScheduledJob(obj.(*ScheduledJob)) })
scheme.AddTypeDefaultingFunc(&ScheduledJobList{}, func(obj interface{}) { SetObjectDefaults_ScheduledJobList(obj.(*ScheduledJobList)) })
return nil
}
func SetObjectDefaults_Job(in *Job) {
SetDefaults_Job(in)
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
for i := range in.Spec.Template.Spec.Volumes {
a := &in.Spec.Template.Spec.Volumes[i]
func SetObjectDefaults_CronJob(in *CronJob) {
SetDefaults_CronJob(in)
v1.SetDefaults_PodSpec(&in.Spec.JobTemplate.Spec.Template.Spec)
for i := range in.Spec.JobTemplate.Spec.Template.Spec.Volumes {
a := &in.Spec.JobTemplate.Spec.Template.Spec.Volumes[i]
v1.SetDefaults_Volume(a)
if a.VolumeSource.Secret != nil {
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
......@@ -68,8 +68,8 @@ func SetObjectDefaults_Job(in *Job) {
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
}
}
for i := range in.Spec.Template.Spec.InitContainers {
a := &in.Spec.Template.Spec.InitContainers[i]
for i := range in.Spec.JobTemplate.Spec.Template.Spec.InitContainers {
a := &in.Spec.JobTemplate.Spec.Template.Spec.InitContainers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
......@@ -110,8 +110,8 @@ func SetObjectDefaults_Job(in *Job) {
}
}
}
for i := range in.Spec.Template.Spec.Containers {
a := &in.Spec.Template.Spec.Containers[i]
for i := range in.Spec.JobTemplate.Spec.Template.Spec.Containers {
a := &in.Spec.JobTemplate.Spec.Template.Spec.Containers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
......@@ -154,17 +154,18 @@ func SetObjectDefaults_Job(in *Job) {
}
}
func SetObjectDefaults_JobList(in *JobList) {
func SetObjectDefaults_CronJobList(in *CronJobList) {
for i := range in.Items {
a := &in.Items[i]
SetObjectDefaults_Job(a)
SetObjectDefaults_CronJob(a)
}
}
func SetObjectDefaults_JobTemplate(in *JobTemplate) {
v1.SetDefaults_PodSpec(&in.Template.Spec.Template.Spec)
for i := range in.Template.Spec.Template.Spec.Volumes {
a := &in.Template.Spec.Template.Spec.Volumes[i]
func SetObjectDefaults_Job(in *Job) {
SetDefaults_Job(in)
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
for i := range in.Spec.Template.Spec.Volumes {
a := &in.Spec.Template.Spec.Volumes[i]
v1.SetDefaults_Volume(a)
if a.VolumeSource.Secret != nil {
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
......@@ -191,8 +192,8 @@ func SetObjectDefaults_JobTemplate(in *JobTemplate) {
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
}
}
for i := range in.Template.Spec.Template.Spec.InitContainers {
a := &in.Template.Spec.Template.Spec.InitContainers[i]
for i := range in.Spec.Template.Spec.InitContainers {
a := &in.Spec.Template.Spec.InitContainers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
......@@ -233,8 +234,8 @@ func SetObjectDefaults_JobTemplate(in *JobTemplate) {
}
}
}
for i := range in.Template.Spec.Template.Spec.Containers {
a := &in.Template.Spec.Template.Spec.Containers[i]
for i := range in.Spec.Template.Spec.Containers {
a := &in.Spec.Template.Spec.Containers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
......@@ -277,11 +278,17 @@ func SetObjectDefaults_JobTemplate(in *JobTemplate) {
}
}
func SetObjectDefaults_ScheduledJob(in *ScheduledJob) {
SetDefaults_ScheduledJob(in)
v1.SetDefaults_PodSpec(&in.Spec.JobTemplate.Spec.Template.Spec)
for i := range in.Spec.JobTemplate.Spec.Template.Spec.Volumes {
a := &in.Spec.JobTemplate.Spec.Template.Spec.Volumes[i]
func SetObjectDefaults_JobList(in *JobList) {
for i := range in.Items {
a := &in.Items[i]
SetObjectDefaults_Job(a)
}
}
func SetObjectDefaults_JobTemplate(in *JobTemplate) {
v1.SetDefaults_PodSpec(&in.Template.Spec.Template.Spec)
for i := range in.Template.Spec.Template.Spec.Volumes {
a := &in.Template.Spec.Template.Spec.Volumes[i]
v1.SetDefaults_Volume(a)
if a.VolumeSource.Secret != nil {
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
......@@ -308,8 +315,8 @@ func SetObjectDefaults_ScheduledJob(in *ScheduledJob) {
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
}
}
for i := range in.Spec.JobTemplate.Spec.Template.Spec.InitContainers {
a := &in.Spec.JobTemplate.Spec.Template.Spec.InitContainers[i]
for i := range in.Template.Spec.Template.Spec.InitContainers {
a := &in.Template.Spec.Template.Spec.InitContainers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
......@@ -350,8 +357,8 @@ func SetObjectDefaults_ScheduledJob(in *ScheduledJob) {
}
}
}
for i := range in.Spec.JobTemplate.Spec.Template.Spec.Containers {
a := &in.Spec.JobTemplate.Spec.Template.Spec.Containers[i]
for i := range in.Template.Spec.Template.Spec.Containers {
a := &in.Template.Spec.Template.Spec.Containers[i]
v1.SetDefaults_Container(a)
for j := range a.Ports {
b := &a.Ports[j]
......@@ -393,10 +400,3 @@ func SetObjectDefaults_ScheduledJob(in *ScheduledJob) {
}
}
}
func SetObjectDefaults_ScheduledJobList(in *ScheduledJobList) {
for i := range in.Items {
a := &in.Items[i]
SetObjectDefaults_ScheduledJob(a)
}
}
......@@ -158,14 +158,14 @@ func ValidateJobStatusUpdate(status, oldStatus batch.JobStatus) field.ErrorList
return allErrs
}
func ValidateScheduledJob(scheduledJob *batch.ScheduledJob) field.ErrorList {
// ScheduledJobs and rcs have the same name validation
func ValidateCronJob(scheduledJob *batch.CronJob) field.ErrorList {
// CronJobs and rcs have the same name validation
allErrs := apivalidation.ValidateObjectMeta(&scheduledJob.ObjectMeta, true, apivalidation.ValidateReplicationControllerName, field.NewPath("metadata"))
allErrs = append(allErrs, ValidateScheduledJobSpec(&scheduledJob.Spec, field.NewPath("spec"))...)
allErrs = append(allErrs, ValidateCronJobSpec(&scheduledJob.Spec, field.NewPath("spec"))...)
return allErrs
}
func ValidateScheduledJobSpec(spec *batch.ScheduledJobSpec, fldPath *field.Path) field.ErrorList {
func ValidateCronJobSpec(spec *batch.CronJobSpec, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(spec.Schedule) == 0 {
......
......@@ -304,19 +304,19 @@ func TestValidateJobUpdateStatus(t *testing.T) {
}
}
func TestValidateScheduledJob(t *testing.T) {
func TestValidateCronJob(t *testing.T) {
validManualSelector := getValidManualSelector()
validPodTemplateSpec := getValidPodTemplateSpecForGenerated(getValidGeneratedSelector())
validPodTemplateSpec.Labels = map[string]string{}
successCases := map[string]batch.ScheduledJob{
successCases := map[string]batch.CronJob{
"basic scheduled job": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -328,11 +328,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"non-standard scheduled": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "@hourly",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -344,7 +344,7 @@ func TestValidateScheduledJob(t *testing.T) {
},
}
for k, v := range successCases {
if errs := ValidateScheduledJob(&v); len(errs) != 0 {
if errs := ValidateCronJob(&v); len(errs) != 0 {
t.Errorf("expected success for %s: %v", k, errs)
}
}
......@@ -352,14 +352,14 @@ func TestValidateScheduledJob(t *testing.T) {
negative := int32(-1)
negative64 := int64(-1)
errorCases := map[string]batch.ScheduledJob{
errorCases := map[string]batch.CronJob{
"spec.schedule: Invalid value": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "error",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -371,11 +371,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.schedule: Required value": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -387,11 +387,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.startingDeadlineSeconds:must be greater than or equal to 0": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
StartingDeadlineSeconds: &negative64,
......@@ -404,11 +404,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.concurrencyPolicy: Required value": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
JobTemplate: batch.JobTemplateSpec{
Spec: batch.JobSpec{
......@@ -419,11 +419,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.jobTemplate.spec.parallelism:must be greater than or equal to 0": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -436,11 +436,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.jobTemplate.spec.completions:must be greater than or equal to 0": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -454,11 +454,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.jobTemplate.spec.activeDeadlineSeconds:must be greater than or equal to 0": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -471,11 +471,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.jobTemplate.spec.selector: Invalid value: {\"matchLabels\":{\"a\":\"b\"}}: `selector` will be auto-generated": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -488,11 +488,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.jobTemplate.spec.manualSelector: Unsupported value": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -505,11 +505,11 @@ func TestValidateScheduledJob(t *testing.T) {
},
"spec.jobTemplate.spec.template.spec.restartPolicy: Unsupported value": {
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -528,7 +528,7 @@ func TestValidateScheduledJob(t *testing.T) {
}
for k, v := range errorCases {
errs := ValidateScheduledJob(&v)
errs := ValidateCronJob(&v)
if len(errs) == 0 {
t.Errorf("expected failure for %s", k)
} else {
......
......@@ -36,6 +36,10 @@ func init() {
// to allow building arbitrary schemes.
func RegisterDeepCopies(scheme *runtime.Scheme) error {
return scheme.AddGeneratedDeepCopyFuncs(
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_CronJob, InType: reflect.TypeOf(&CronJob{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_CronJobList, InType: reflect.TypeOf(&CronJobList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_CronJobSpec, InType: reflect.TypeOf(&CronJobSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_CronJobStatus, InType: reflect.TypeOf(&CronJobStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_Job, InType: reflect.TypeOf(&Job{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_JobCondition, InType: reflect.TypeOf(&JobCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_JobList, InType: reflect.TypeOf(&JobList{})},
......@@ -43,13 +47,99 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_JobStatus, InType: reflect.TypeOf(&JobStatus{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_JobTemplate, InType: reflect.TypeOf(&JobTemplate{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_JobTemplateSpec, InType: reflect.TypeOf(&JobTemplateSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_ScheduledJob, InType: reflect.TypeOf(&ScheduledJob{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_ScheduledJobList, InType: reflect.TypeOf(&ScheduledJobList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_ScheduledJobSpec, InType: reflect.TypeOf(&ScheduledJobSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_batch_ScheduledJobStatus, InType: reflect.TypeOf(&ScheduledJobStatus{})},
)
}
func DeepCopy_batch_CronJob(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJob)
out := out.(*CronJob)
out.TypeMeta = in.TypeMeta
if err := api.DeepCopy_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := DeepCopy_batch_CronJobSpec(&in.Spec, &out.Spec, c); err != nil {
return err
}
if err := DeepCopy_batch_CronJobStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_batch_CronJobList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJobList)
out := out.(*CronJobList)
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]CronJob, len(*in))
for i := range *in {
if err := DeepCopy_batch_CronJob(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
}
func DeepCopy_batch_CronJobSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJobSpec)
out := out.(*CronJobSpec)
out.Schedule = in.Schedule
if in.StartingDeadlineSeconds != nil {
in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds
*out = new(int64)
**out = **in
} else {
out.StartingDeadlineSeconds = nil
}
out.ConcurrencyPolicy = in.ConcurrencyPolicy
if in.Suspend != nil {
in, out := &in.Suspend, &out.Suspend
*out = new(bool)
**out = **in
} else {
out.Suspend = nil
}
if err := DeepCopy_batch_JobTemplateSpec(&in.JobTemplate, &out.JobTemplate, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_batch_CronJobStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CronJobStatus)
out := out.(*CronJobStatus)
if in.Active != nil {
in, out := &in.Active, &out.Active
*out = make([]api.ObjectReference, len(*in))
for i := range *in {
(*out)[i] = (*in)[i]
}
} else {
out.Active = nil
}
if in.LastScheduleTime != nil {
in, out := &in.LastScheduleTime, &out.LastScheduleTime
*out = new(unversioned.Time)
**out = (*in).DeepCopy()
} else {
out.LastScheduleTime = nil
}
return nil
}
}
func DeepCopy_batch_Job(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*Job)
......@@ -215,93 +305,3 @@ func DeepCopy_batch_JobTemplateSpec(in interface{}, out interface{}, c *conversi
return nil
}
}
func DeepCopy_batch_ScheduledJob(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJob)
out := out.(*ScheduledJob)
out.TypeMeta = in.TypeMeta
if err := api.DeepCopy_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := DeepCopy_batch_ScheduledJobSpec(&in.Spec, &out.Spec, c); err != nil {
return err
}
if err := DeepCopy_batch_ScheduledJobStatus(&in.Status, &out.Status, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_batch_ScheduledJobList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJobList)
out := out.(*ScheduledJobList)
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ScheduledJob, len(*in))
for i := range *in {
if err := DeepCopy_batch_ScheduledJob(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
}
func DeepCopy_batch_ScheduledJobSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJobSpec)
out := out.(*ScheduledJobSpec)
out.Schedule = in.Schedule
if in.StartingDeadlineSeconds != nil {
in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds
*out = new(int64)
**out = **in
} else {
out.StartingDeadlineSeconds = nil
}
out.ConcurrencyPolicy = in.ConcurrencyPolicy
if in.Suspend != nil {
in, out := &in.Suspend, &out.Suspend
*out = new(bool)
**out = **in
} else {
out.Suspend = nil
}
if err := DeepCopy_batch_JobTemplateSpec(&in.JobTemplate, &out.JobTemplate, c); err != nil {
return err
}
return nil
}
}
func DeepCopy_batch_ScheduledJobStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*ScheduledJobStatus)
out := out.(*ScheduledJobStatus)
if in.Active != nil {
in, out := &in.Active, &out.Active
*out = make([]api.ObjectReference, len(*in))
for i := range *in {
(*out)[i] = (*in)[i]
}
} else {
out.Active = nil
}
if in.LastScheduleTime != nil {
in, out := &in.LastScheduleTime, &out.LastScheduleTime
*out = new(unversioned.Time)
**out = (*in).DeepCopy()
} else {
out.LastScheduleTime = nil
}
return nil
}
}
......@@ -14,10 +14,10 @@ go_library(
name = "go_default_library",
srcs = [
"batch_client.go",
"cronjob.go",
"doc.go",
"generated_expansion.go",
"job.go",
"scheduledjob.go",
],
tags = ["automanaged"],
deps = [
......
......@@ -25,7 +25,7 @@ import (
type BatchInterface interface {
RESTClient() restclient.Interface
JobsGetter
ScheduledJobsGetter
CronJobsGetter
}
// BatchClient is used to interact with features provided by the k8s.io/kubernetes/pkg/apimachinery/registered.Group group.
......@@ -37,8 +37,8 @@ func (c *BatchClient) Jobs(namespace string) JobInterface {
return newJobs(c, namespace)
}
func (c *BatchClient) ScheduledJobs(namespace string) ScheduledJobInterface {
return newScheduledJobs(c, namespace)
func (c *BatchClient) CronJobs(namespace string) CronJobInterface {
return newCronJobs(c, namespace)
}
// NewForConfig creates a new BatchClient for the given config.
......
......@@ -23,34 +23,34 @@ import (
watch "k8s.io/kubernetes/pkg/watch"
)
// ScheduledJobsGetter has a method to return a ScheduledJobInterface.
// CronJobsGetter has a method to return a CronJobInterface.
// A group's client should implement this interface.
type ScheduledJobsGetter interface {
ScheduledJobs(namespace string) ScheduledJobInterface
type CronJobsGetter interface {
CronJobs(namespace string) CronJobInterface
}
// ScheduledJobInterface has methods to work with ScheduledJob resources.
type ScheduledJobInterface interface {
Create(*batch.ScheduledJob) (*batch.ScheduledJob, error)
Update(*batch.ScheduledJob) (*batch.ScheduledJob, error)
UpdateStatus(*batch.ScheduledJob) (*batch.ScheduledJob, error)
// CronJobInterface has methods to work with CronJob resources.
type CronJobInterface interface {
Create(*batch.CronJob) (*batch.CronJob, error)
Update(*batch.CronJob) (*batch.CronJob, error)
UpdateStatus(*batch.CronJob) (*batch.CronJob, error)
Delete(name string, options *api.DeleteOptions) error
DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error
Get(name string) (*batch.ScheduledJob, error)
List(opts api.ListOptions) (*batch.ScheduledJobList, error)
Get(name string) (*batch.CronJob, error)
List(opts api.ListOptions) (*batch.CronJobList, error)
Watch(opts api.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *batch.ScheduledJob, err error)
ScheduledJobExpansion
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *batch.CronJob, err error)
CronJobExpansion
}
// scheduledJobs implements ScheduledJobInterface
// scheduledJobs implements CronJobInterface
type scheduledJobs struct {
client restclient.Interface
ns string
}
// newScheduledJobs returns a ScheduledJobs
func newScheduledJobs(c *BatchClient, namespace string) *scheduledJobs {
// newCronJobs returns a CronJobs
func newCronJobs(c *BatchClient, namespace string) *scheduledJobs {
return &scheduledJobs{
client: c.RESTClient(),
ns: namespace,
......@@ -58,11 +58,11 @@ func newScheduledJobs(c *BatchClient, namespace string) *scheduledJobs {
}
// Create takes the representation of a scheduledJob and creates it. Returns the server's representation of the scheduledJob, and an error, if there is any.
func (c *scheduledJobs) Create(scheduledJob *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
func (c *scheduledJobs) Create(scheduledJob *batch.CronJob) (result *batch.CronJob, err error) {
result = &batch.CronJob{}
err = c.client.Post().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
Body(scheduledJob).
Do().
Into(result)
......@@ -70,11 +70,11 @@ func (c *scheduledJobs) Create(scheduledJob *batch.ScheduledJob) (result *batch.
}
// Update takes the representation of a scheduledJob and updates it. Returns the server's representation of the scheduledJob, and an error, if there is any.
func (c *scheduledJobs) Update(scheduledJob *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
func (c *scheduledJobs) Update(scheduledJob *batch.CronJob) (result *batch.CronJob, err error) {
result = &batch.CronJob{}
err = c.client.Put().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
Name(scheduledJob.Name).
Body(scheduledJob).
Do().
......@@ -82,11 +82,11 @@ func (c *scheduledJobs) Update(scheduledJob *batch.ScheduledJob) (result *batch.
return
}
func (c *scheduledJobs) UpdateStatus(scheduledJob *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
func (c *scheduledJobs) UpdateStatus(scheduledJob *batch.CronJob) (result *batch.CronJob, err error) {
result = &batch.CronJob{}
err = c.client.Put().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
Name(scheduledJob.Name).
SubResource("status").
Body(scheduledJob).
......@@ -99,7 +99,7 @@ func (c *scheduledJobs) UpdateStatus(scheduledJob *batch.ScheduledJob) (result *
func (c *scheduledJobs) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
Name(name).
Body(options).
Do().
......@@ -110,7 +110,7 @@ func (c *scheduledJobs) Delete(name string, options *api.DeleteOptions) error {
func (c *scheduledJobs) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
VersionedParams(&listOptions, api.ParameterCodec).
Body(options).
Do().
......@@ -118,23 +118,23 @@ func (c *scheduledJobs) DeleteCollection(options *api.DeleteOptions, listOptions
}
// Get takes name of the scheduledJob, and returns the corresponding scheduledJob object, and an error if there is any.
func (c *scheduledJobs) Get(name string) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
func (c *scheduledJobs) Get(name string) (result *batch.CronJob, err error) {
result = &batch.CronJob{}
err = c.client.Get().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
Name(name).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ScheduledJobs that match those selectors.
func (c *scheduledJobs) List(opts api.ListOptions) (result *batch.ScheduledJobList, err error) {
result = &batch.ScheduledJobList{}
// List takes label and field selectors, and returns the list of CronJobs that match those selectors.
func (c *scheduledJobs) List(opts api.ListOptions) (result *batch.CronJobList, err error) {
result = &batch.CronJobList{}
err = c.client.Get().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
VersionedParams(&opts, api.ParameterCodec).
Do().
Into(result)
......@@ -146,17 +146,17 @@ func (c *scheduledJobs) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}
// Patch applies the patch and returns the patched scheduledJob.
func (c *scheduledJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *batch.ScheduledJob, err error) {
result = &batch.ScheduledJob{}
func (c *scheduledJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *batch.CronJob, err error) {
result = &batch.CronJob{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
SubResource(subresources...).
Name(name).
Body(data).
......
......@@ -15,8 +15,8 @@ go_library(
srcs = [
"doc.go",
"fake_batch_client.go",
"fake_cronjob.go",
"fake_job.go",
"fake_scheduledjob.go",
],
tags = ["automanaged"],
deps = [
......
......@@ -30,8 +30,8 @@ func (c *FakeBatch) Jobs(namespace string) internalversion.JobInterface {
return &FakeJobs{c, namespace}
}
func (c *FakeBatch) ScheduledJobs(namespace string) internalversion.ScheduledJobInterface {
return &FakeScheduledJobs{c, namespace}
func (c *FakeBatch) CronJobs(namespace string) internalversion.CronJobInterface {
return &FakeCronJobs{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
......
......@@ -25,71 +25,71 @@ import (
watch "k8s.io/kubernetes/pkg/watch"
)
// FakeScheduledJobs implements ScheduledJobInterface
type FakeScheduledJobs struct {
// FakeCronJobs implements CronJobInterface
type FakeCronJobs struct {
Fake *FakeBatch
ns string
}
var scheduledjobsResource = unversioned.GroupVersionResource{Group: "batch", Version: "", Resource: "scheduledjobs"}
var cronjobsResource = unversioned.GroupVersionResource{Group: "batch", Version: "", Resource: "cronjobs"}
func (c *FakeScheduledJobs) Create(scheduledJob *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
func (c *FakeCronJobs) Create(scheduledJob *batch.CronJob) (result *batch.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewCreateAction(scheduledjobsResource, c.ns, scheduledJob), &batch.ScheduledJob{})
Invokes(core.NewCreateAction(cronjobsResource, c.ns, scheduledJob), &batch.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
return obj.(*batch.CronJob), err
}
func (c *FakeScheduledJobs) Update(scheduledJob *batch.ScheduledJob) (result *batch.ScheduledJob, err error) {
func (c *FakeCronJobs) Update(scheduledJob *batch.CronJob) (result *batch.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewUpdateAction(scheduledjobsResource, c.ns, scheduledJob), &batch.ScheduledJob{})
Invokes(core.NewUpdateAction(cronjobsResource, c.ns, scheduledJob), &batch.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
return obj.(*batch.CronJob), err
}
func (c *FakeScheduledJobs) UpdateStatus(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) {
func (c *FakeCronJobs) UpdateStatus(scheduledJob *batch.CronJob) (*batch.CronJob, error) {
obj, err := c.Fake.
Invokes(core.NewUpdateSubresourceAction(scheduledjobsResource, "status", c.ns, scheduledJob), &batch.ScheduledJob{})
Invokes(core.NewUpdateSubresourceAction(cronjobsResource, "status", c.ns, scheduledJob), &batch.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
return obj.(*batch.CronJob), err
}
func (c *FakeScheduledJobs) Delete(name string, options *api.DeleteOptions) error {
func (c *FakeCronJobs) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(scheduledjobsResource, c.ns, name), &batch.ScheduledJob{})
Invokes(core.NewDeleteAction(cronjobsResource, c.ns, name), &batch.CronJob{})
return err
}
func (c *FakeScheduledJobs) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
action := core.NewDeleteCollectionAction(scheduledjobsResource, c.ns, listOptions)
func (c *FakeCronJobs) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
action := core.NewDeleteCollectionAction(cronjobsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &batch.ScheduledJobList{})
_, err := c.Fake.Invokes(action, &batch.CronJobList{})
return err
}
func (c *FakeScheduledJobs) Get(name string) (result *batch.ScheduledJob, err error) {
func (c *FakeCronJobs) Get(name string) (result *batch.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewGetAction(scheduledjobsResource, c.ns, name), &batch.ScheduledJob{})
Invokes(core.NewGetAction(cronjobsResource, c.ns, name), &batch.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
return obj.(*batch.CronJob), err
}
func (c *FakeScheduledJobs) List(opts api.ListOptions) (result *batch.ScheduledJobList, err error) {
func (c *FakeCronJobs) List(opts api.ListOptions) (result *batch.CronJobList, err error) {
obj, err := c.Fake.
Invokes(core.NewListAction(scheduledjobsResource, c.ns, opts), &batch.ScheduledJobList{})
Invokes(core.NewListAction(cronjobsResource, c.ns, opts), &batch.CronJobList{})
if obj == nil {
return nil, err
......@@ -99,8 +99,8 @@ func (c *FakeScheduledJobs) List(opts api.ListOptions) (result *batch.ScheduledJ
if label == nil {
label = labels.Everything()
}
list := &batch.ScheduledJobList{}
for _, item := range obj.(*batch.ScheduledJobList).Items {
list := &batch.CronJobList{}
for _, item := range obj.(*batch.CronJobList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
......@@ -109,19 +109,19 @@ func (c *FakeScheduledJobs) List(opts api.ListOptions) (result *batch.ScheduledJ
}
// Watch returns a watch.Interface that watches the requested scheduledJobs.
func (c *FakeScheduledJobs) Watch(opts api.ListOptions) (watch.Interface, error) {
func (c *FakeCronJobs) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(core.NewWatchAction(scheduledjobsResource, c.ns, opts))
InvokesWatch(core.NewWatchAction(cronjobsResource, c.ns, opts))
}
// Patch applies the patch and returns the patched scheduledJob.
func (c *FakeScheduledJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *batch.ScheduledJob, err error) {
func (c *FakeCronJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *batch.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewPatchSubresourceAction(scheduledjobsResource, c.ns, name, data, subresources...), &batch.ScheduledJob{})
Invokes(core.NewPatchSubresourceAction(cronjobsResource, c.ns, name, data, subresources...), &batch.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*batch.ScheduledJob), err
return obj.(*batch.CronJob), err
}
......@@ -18,4 +18,4 @@ package internalversion
type JobExpansion interface{}
type ScheduledJobExpansion interface{}
type CronJobExpansion interface{}
......@@ -14,10 +14,10 @@ go_library(
name = "go_default_library",
srcs = [
"batch_client.go",
"cronjob.go",
"doc.go",
"generated_expansion.go",
"job.go",
"scheduledjob.go",
],
tags = ["automanaged"],
deps = [
......
......@@ -28,7 +28,7 @@ import (
type BatchV2alpha1Interface interface {
RESTClient() restclient.Interface
JobsGetter
ScheduledJobsGetter
CronJobsGetter
}
// BatchV2alpha1Client is used to interact with features provided by the k8s.io/kubernetes/pkg/apimachinery/registered.Group group.
......@@ -40,8 +40,8 @@ func (c *BatchV2alpha1Client) Jobs(namespace string) JobInterface {
return newJobs(c, namespace)
}
func (c *BatchV2alpha1Client) ScheduledJobs(namespace string) ScheduledJobInterface {
return newScheduledJobs(c, namespace)
func (c *BatchV2alpha1Client) CronJobs(namespace string) CronJobInterface {
return newCronJobs(c, namespace)
}
// NewForConfig creates a new BatchV2alpha1Client for the given config.
......
......@@ -24,83 +24,83 @@ import (
watch "k8s.io/kubernetes/pkg/watch"
)
// ScheduledJobsGetter has a method to return a ScheduledJobInterface.
// CronJobsGetter has a method to return a CronJobInterface.
// A group's client should implement this interface.
type ScheduledJobsGetter interface {
ScheduledJobs(namespace string) ScheduledJobInterface
type CronJobsGetter interface {
CronJobs(namespace string) CronJobInterface
}
// ScheduledJobInterface has methods to work with ScheduledJob resources.
type ScheduledJobInterface interface {
Create(*v2alpha1.ScheduledJob) (*v2alpha1.ScheduledJob, error)
Update(*v2alpha1.ScheduledJob) (*v2alpha1.ScheduledJob, error)
UpdateStatus(*v2alpha1.ScheduledJob) (*v2alpha1.ScheduledJob, error)
// CronJobInterface has methods to work with CronJob resources.
type CronJobInterface interface {
Create(*v2alpha1.CronJob) (*v2alpha1.CronJob, error)
Update(*v2alpha1.CronJob) (*v2alpha1.CronJob, error)
UpdateStatus(*v2alpha1.CronJob) (*v2alpha1.CronJob, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v2alpha1.ScheduledJob, error)
List(opts v1.ListOptions) (*v2alpha1.ScheduledJobList, error)
Get(name string) (*v2alpha1.CronJob, error)
List(opts v1.ListOptions) (*v2alpha1.CronJobList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.ScheduledJob, err error)
ScheduledJobExpansion
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.CronJob, err error)
CronJobExpansion
}
// scheduledJobs implements ScheduledJobInterface
type scheduledJobs struct {
// cronJobs implements CronJobInterface
type cronJobs struct {
client restclient.Interface
ns string
}
// newScheduledJobs returns a ScheduledJobs
func newScheduledJobs(c *BatchV2alpha1Client, namespace string) *scheduledJobs {
return &scheduledJobs{
// newCronJobs returns a CronJobs
func newCronJobs(c *BatchV2alpha1Client, namespace string) *cronJobs {
return &cronJobs{
client: c.RESTClient(),
ns: namespace,
}
}
// Create takes the representation of a scheduledJob and creates it. Returns the server's representation of the scheduledJob, and an error, if there is any.
func (c *scheduledJobs) Create(scheduledJob *v2alpha1.ScheduledJob) (result *v2alpha1.ScheduledJob, err error) {
result = &v2alpha1.ScheduledJob{}
// Create takes the representation of a cronJob and creates it. Returns the server's representation of the cronJob, and an error, if there is any.
func (c *cronJobs) Create(cronJob *v2alpha1.CronJob) (result *v2alpha1.CronJob, err error) {
result = &v2alpha1.CronJob{}
err = c.client.Post().
Namespace(c.ns).
Resource("scheduledjobs").
Body(scheduledJob).
Resource("cronjobs").
Body(cronJob).
Do().
Into(result)
return
}
// Update takes the representation of a scheduledJob and updates it. Returns the server's representation of the scheduledJob, and an error, if there is any.
func (c *scheduledJobs) Update(scheduledJob *v2alpha1.ScheduledJob) (result *v2alpha1.ScheduledJob, err error) {
result = &v2alpha1.ScheduledJob{}
// Update takes the representation of a cronJob and updates it. Returns the server's representation of the cronJob, and an error, if there is any.
func (c *cronJobs) Update(cronJob *v2alpha1.CronJob) (result *v2alpha1.CronJob, err error) {
result = &v2alpha1.CronJob{}
err = c.client.Put().
Namespace(c.ns).
Resource("scheduledjobs").
Name(scheduledJob.Name).
Body(scheduledJob).
Resource("cronjobs").
Name(cronJob.Name).
Body(cronJob).
Do().
Into(result)
return
}
func (c *scheduledJobs) UpdateStatus(scheduledJob *v2alpha1.ScheduledJob) (result *v2alpha1.ScheduledJob, err error) {
result = &v2alpha1.ScheduledJob{}
func (c *cronJobs) UpdateStatus(cronJob *v2alpha1.CronJob) (result *v2alpha1.CronJob, err error) {
result = &v2alpha1.CronJob{}
err = c.client.Put().
Namespace(c.ns).
Resource("scheduledjobs").
Name(scheduledJob.Name).
Resource("cronjobs").
Name(cronJob.Name).
SubResource("status").
Body(scheduledJob).
Body(cronJob).
Do().
Into(result)
return
}
// Delete takes name of the scheduledJob and deletes it. Returns an error if one occurs.
func (c *scheduledJobs) Delete(name string, options *v1.DeleteOptions) error {
// Delete takes name of the cronJob and deletes it. Returns an error if one occurs.
func (c *cronJobs) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
Name(name).
Body(options).
Do().
......@@ -108,56 +108,56 @@ func (c *scheduledJobs) Delete(name string, options *v1.DeleteOptions) error {
}
// DeleteCollection deletes a collection of objects.
func (c *scheduledJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
func (c *cronJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
VersionedParams(&listOptions, api.ParameterCodec).
Body(options).
Do().
Error()
}
// Get takes name of the scheduledJob, and returns the corresponding scheduledJob object, and an error if there is any.
func (c *scheduledJobs) Get(name string) (result *v2alpha1.ScheduledJob, err error) {
result = &v2alpha1.ScheduledJob{}
// Get takes name of the cronJob, and returns the corresponding cronJob object, and an error if there is any.
func (c *cronJobs) Get(name string) (result *v2alpha1.CronJob, err error) {
result = &v2alpha1.CronJob{}
err = c.client.Get().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
Name(name).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ScheduledJobs that match those selectors.
func (c *scheduledJobs) List(opts v1.ListOptions) (result *v2alpha1.ScheduledJobList, err error) {
result = &v2alpha1.ScheduledJobList{}
// List takes label and field selectors, and returns the list of CronJobs that match those selectors.
func (c *cronJobs) List(opts v1.ListOptions) (result *v2alpha1.CronJobList, err error) {
result = &v2alpha1.CronJobList{}
err = c.client.Get().
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
VersionedParams(&opts, api.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested scheduledJobs.
func (c *scheduledJobs) Watch(opts v1.ListOptions) (watch.Interface, error) {
// Watch returns a watch.Interface that watches the requested cronJobs.
func (c *cronJobs) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}
// Patch applies the patch and returns the patched scheduledJob.
func (c *scheduledJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.ScheduledJob, err error) {
result = &v2alpha1.ScheduledJob{}
// Patch applies the patch and returns the patched cronJob.
func (c *cronJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.CronJob, err error) {
result = &v2alpha1.CronJob{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("scheduledjobs").
Resource("cronjobs").
SubResource(subresources...).
Name(name).
Body(data).
......
......@@ -15,8 +15,8 @@ go_library(
srcs = [
"doc.go",
"fake_batch_client.go",
"fake_cronjob.go",
"fake_job.go",
"fake_scheduledjob.go",
],
tags = ["automanaged"],
deps = [
......
......@@ -30,8 +30,8 @@ func (c *FakeBatchV2alpha1) Jobs(namespace string) v2alpha1.JobInterface {
return &FakeJobs{c, namespace}
}
func (c *FakeBatchV2alpha1) ScheduledJobs(namespace string) v2alpha1.ScheduledJobInterface {
return &FakeScheduledJobs{c, namespace}
func (c *FakeBatchV2alpha1) CronJobs(namespace string) v2alpha1.CronJobInterface {
return &FakeCronJobs{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
......
......@@ -26,71 +26,71 @@ import (
watch "k8s.io/kubernetes/pkg/watch"
)
// FakeScheduledJobs implements ScheduledJobInterface
type FakeScheduledJobs struct {
// FakeCronJobs implements CronJobInterface
type FakeCronJobs struct {
Fake *FakeBatchV2alpha1
ns string
}
var scheduledjobsResource = unversioned.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "scheduledjobs"}
var cronjobsResource = unversioned.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}
func (c *FakeScheduledJobs) Create(scheduledJob *v2alpha1.ScheduledJob) (result *v2alpha1.ScheduledJob, err error) {
func (c *FakeCronJobs) Create(cronJob *v2alpha1.CronJob) (result *v2alpha1.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewCreateAction(scheduledjobsResource, c.ns, scheduledJob), &v2alpha1.ScheduledJob{})
Invokes(core.NewCreateAction(cronjobsResource, c.ns, cronJob), &v2alpha1.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.ScheduledJob), err
return obj.(*v2alpha1.CronJob), err
}
func (c *FakeScheduledJobs) Update(scheduledJob *v2alpha1.ScheduledJob) (result *v2alpha1.ScheduledJob, err error) {
func (c *FakeCronJobs) Update(cronJob *v2alpha1.CronJob) (result *v2alpha1.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewUpdateAction(scheduledjobsResource, c.ns, scheduledJob), &v2alpha1.ScheduledJob{})
Invokes(core.NewUpdateAction(cronjobsResource, c.ns, cronJob), &v2alpha1.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.ScheduledJob), err
return obj.(*v2alpha1.CronJob), err
}
func (c *FakeScheduledJobs) UpdateStatus(scheduledJob *v2alpha1.ScheduledJob) (*v2alpha1.ScheduledJob, error) {
func (c *FakeCronJobs) UpdateStatus(cronJob *v2alpha1.CronJob) (*v2alpha1.CronJob, error) {
obj, err := c.Fake.
Invokes(core.NewUpdateSubresourceAction(scheduledjobsResource, "status", c.ns, scheduledJob), &v2alpha1.ScheduledJob{})
Invokes(core.NewUpdateSubresourceAction(cronjobsResource, "status", c.ns, cronJob), &v2alpha1.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.ScheduledJob), err
return obj.(*v2alpha1.CronJob), err
}
func (c *FakeScheduledJobs) Delete(name string, options *v1.DeleteOptions) error {
func (c *FakeCronJobs) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(scheduledjobsResource, c.ns, name), &v2alpha1.ScheduledJob{})
Invokes(core.NewDeleteAction(cronjobsResource, c.ns, name), &v2alpha1.CronJob{})
return err
}
func (c *FakeScheduledJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := core.NewDeleteCollectionAction(scheduledjobsResource, c.ns, listOptions)
func (c *FakeCronJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := core.NewDeleteCollectionAction(cronjobsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v2alpha1.ScheduledJobList{})
_, err := c.Fake.Invokes(action, &v2alpha1.CronJobList{})
return err
}
func (c *FakeScheduledJobs) Get(name string) (result *v2alpha1.ScheduledJob, err error) {
func (c *FakeCronJobs) Get(name string) (result *v2alpha1.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewGetAction(scheduledjobsResource, c.ns, name), &v2alpha1.ScheduledJob{})
Invokes(core.NewGetAction(cronjobsResource, c.ns, name), &v2alpha1.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.ScheduledJob), err
return obj.(*v2alpha1.CronJob), err
}
func (c *FakeScheduledJobs) List(opts v1.ListOptions) (result *v2alpha1.ScheduledJobList, err error) {
func (c *FakeCronJobs) List(opts v1.ListOptions) (result *v2alpha1.CronJobList, err error) {
obj, err := c.Fake.
Invokes(core.NewListAction(scheduledjobsResource, c.ns, opts), &v2alpha1.ScheduledJobList{})
Invokes(core.NewListAction(cronjobsResource, c.ns, opts), &v2alpha1.CronJobList{})
if obj == nil {
return nil, err
......@@ -100,8 +100,8 @@ func (c *FakeScheduledJobs) List(opts v1.ListOptions) (result *v2alpha1.Schedule
if label == nil {
label = labels.Everything()
}
list := &v2alpha1.ScheduledJobList{}
for _, item := range obj.(*v2alpha1.ScheduledJobList).Items {
list := &v2alpha1.CronJobList{}
for _, item := range obj.(*v2alpha1.CronJobList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
......@@ -109,20 +109,20 @@ func (c *FakeScheduledJobs) List(opts v1.ListOptions) (result *v2alpha1.Schedule
return list, err
}
// Watch returns a watch.Interface that watches the requested scheduledJobs.
func (c *FakeScheduledJobs) Watch(opts v1.ListOptions) (watch.Interface, error) {
// Watch returns a watch.Interface that watches the requested cronJobs.
func (c *FakeCronJobs) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(core.NewWatchAction(scheduledjobsResource, c.ns, opts))
InvokesWatch(core.NewWatchAction(cronjobsResource, c.ns, opts))
}
// Patch applies the patch and returns the patched scheduledJob.
func (c *FakeScheduledJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.ScheduledJob, err error) {
// Patch applies the patch and returns the patched cronJob.
func (c *FakeCronJobs) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.CronJob, err error) {
obj, err := c.Fake.
Invokes(core.NewPatchSubresourceAction(scheduledjobsResource, c.ns, name, data, subresources...), &v2alpha1.ScheduledJob{})
Invokes(core.NewPatchSubresourceAction(cronjobsResource, c.ns, name, data, subresources...), &v2alpha1.CronJob{})
if obj == nil {
return nil, err
}
return obj.(*v2alpha1.ScheduledJob), err
return obj.(*v2alpha1.CronJob), err
}
......@@ -18,4 +18,4 @@ package v2alpha1
type JobExpansion interface{}
type ScheduledJobExpansion interface{}
type CronJobExpansion interface{}
......@@ -13,10 +13,10 @@ load(
go_library(
name = "go_default_library",
srcs = [
"cronjob.go",
"expansion_generated.go",
"job.go",
"job_expansion.go",
"scheduledjob.go",
],
tags = ["automanaged"],
deps = [
......
......@@ -25,70 +25,70 @@ import (
"k8s.io/kubernetes/pkg/labels"
)
// ScheduledJobLister helps list ScheduledJobs.
type ScheduledJobLister interface {
// List lists all ScheduledJobs in the indexer.
List(selector labels.Selector) (ret []*batch.ScheduledJob, err error)
// ScheduledJobs returns an object that can list and get ScheduledJobs.
ScheduledJobs(namespace string) ScheduledJobNamespaceLister
ScheduledJobListerExpansion
// CronJobLister helps list CronJobs.
type CronJobLister interface {
// List lists all CronJobs in the indexer.
List(selector labels.Selector) (ret []*batch.CronJob, err error)
// CronJobs returns an object that can list and get CronJobs.
CronJobs(namespace string) CronJobNamespaceLister
CronJobListerExpansion
}
// scheduledJobLister implements the ScheduledJobLister interface.
type scheduledJobLister struct {
// cronJobLister implements the CronJobLister interface.
type cronJobLister struct {
indexer cache.Indexer
}
// NewScheduledJobLister returns a new ScheduledJobLister.
func NewScheduledJobLister(indexer cache.Indexer) ScheduledJobLister {
return &scheduledJobLister{indexer: indexer}
// NewCronJobLister returns a new CronJobLister.
func NewCronJobLister(indexer cache.Indexer) CronJobLister {
return &cronJobLister{indexer: indexer}
}
// List lists all ScheduledJobs in the indexer.
func (s *scheduledJobLister) List(selector labels.Selector) (ret []*batch.ScheduledJob, err error) {
// List lists all CronJobs in the indexer.
func (s *cronJobLister) List(selector labels.Selector) (ret []*batch.CronJob, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*batch.ScheduledJob))
ret = append(ret, m.(*batch.CronJob))
})
return ret, err
}
// ScheduledJobs returns an object that can list and get ScheduledJobs.
func (s *scheduledJobLister) ScheduledJobs(namespace string) ScheduledJobNamespaceLister {
return scheduledJobNamespaceLister{indexer: s.indexer, namespace: namespace}
// CronJobs returns an object that can list and get CronJobs.
func (s *cronJobLister) CronJobs(namespace string) CronJobNamespaceLister {
return cronJobNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ScheduledJobNamespaceLister helps list and get ScheduledJobs.
type ScheduledJobNamespaceLister interface {
// List lists all ScheduledJobs in the indexer for a given namespace.
List(selector labels.Selector) (ret []*batch.ScheduledJob, err error)
// Get retrieves the ScheduledJob from the indexer for a given namespace and name.
Get(name string) (*batch.ScheduledJob, error)
ScheduledJobNamespaceListerExpansion
// CronJobNamespaceLister helps list and get CronJobs.
type CronJobNamespaceLister interface {
// List lists all CronJobs in the indexer for a given namespace.
List(selector labels.Selector) (ret []*batch.CronJob, err error)
// Get retrieves the CronJob from the indexer for a given namespace and name.
Get(name string) (*batch.CronJob, error)
CronJobNamespaceListerExpansion
}
// scheduledJobNamespaceLister implements the ScheduledJobNamespaceLister
// cronJobNamespaceLister implements the CronJobNamespaceLister
// interface.
type scheduledJobNamespaceLister struct {
type cronJobNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ScheduledJobs in the indexer for a given namespace.
func (s scheduledJobNamespaceLister) List(selector labels.Selector) (ret []*batch.ScheduledJob, err error) {
// List lists all CronJobs in the indexer for a given namespace.
func (s cronJobNamespaceLister) List(selector labels.Selector) (ret []*batch.CronJob, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*batch.ScheduledJob))
ret = append(ret, m.(*batch.CronJob))
})
return ret, err
}
// Get retrieves the ScheduledJob from the indexer for a given namespace and name.
func (s scheduledJobNamespaceLister) Get(name string) (*batch.ScheduledJob, error) {
// Get retrieves the CronJob from the indexer for a given namespace and name.
func (s cronJobNamespaceLister) Get(name string) (*batch.CronJob, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(batch.Resource("scheduledjob"), name)
return nil, errors.NewNotFound(batch.Resource("cronjob"), name)
}
return obj.(*batch.ScheduledJob), nil
return obj.(*batch.CronJob), nil
}
......@@ -18,10 +18,10 @@ limitations under the License.
package internalversion
// ScheduledJobListerExpansion allows custom methods to be added to
// ScheduledJobLister.
type ScheduledJobListerExpansion interface{}
// CronJobListerExpansion allows custom methods to be added to
// CronJobLister.
type CronJobListerExpansion interface{}
// ScheduledJobNamespaceListerExpansion allows custom methods to be added to
// ScheduledJobNamespaeLister.
type ScheduledJobNamespaceListerExpansion interface{}
// CronJobNamespaceListerExpansion allows custom methods to be added to
// CronJobNamespaeLister.
type CronJobNamespaceListerExpansion interface{}
......@@ -13,9 +13,9 @@ load(
go_library(
name = "go_default_library",
srcs = [
"cronjob.go",
"expansion_generated.go",
"job.go",
"scheduledjob.go",
],
tags = ["automanaged"],
deps = [
......
......@@ -26,70 +26,70 @@ import (
"k8s.io/kubernetes/pkg/labels"
)
// ScheduledJobLister helps list ScheduledJobs.
type ScheduledJobLister interface {
// List lists all ScheduledJobs in the indexer.
List(selector labels.Selector) (ret []*v2alpha1.ScheduledJob, err error)
// ScheduledJobs returns an object that can list and get ScheduledJobs.
ScheduledJobs(namespace string) ScheduledJobNamespaceLister
ScheduledJobListerExpansion
// CronJobLister helps list CronJobs.
type CronJobLister interface {
// List lists all CronJobs in the indexer.
List(selector labels.Selector) (ret []*v2alpha1.CronJob, err error)
// CronJobs returns an object that can list and get CronJobs.
CronJobs(namespace string) CronJobNamespaceLister
CronJobListerExpansion
}
// scheduledJobLister implements the ScheduledJobLister interface.
type scheduledJobLister struct {
// cronJobLister implements the CronJobLister interface.
type cronJobLister struct {
indexer cache.Indexer
}
// NewScheduledJobLister returns a new ScheduledJobLister.
func NewScheduledJobLister(indexer cache.Indexer) ScheduledJobLister {
return &scheduledJobLister{indexer: indexer}
// NewCronJobLister returns a new CronJobLister.
func NewCronJobLister(indexer cache.Indexer) CronJobLister {
return &cronJobLister{indexer: indexer}
}
// List lists all ScheduledJobs in the indexer.
func (s *scheduledJobLister) List(selector labels.Selector) (ret []*v2alpha1.ScheduledJob, err error) {
// List lists all CronJobs in the indexer.
func (s *cronJobLister) List(selector labels.Selector) (ret []*v2alpha1.CronJob, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2alpha1.ScheduledJob))
ret = append(ret, m.(*v2alpha1.CronJob))
})
return ret, err
}
// ScheduledJobs returns an object that can list and get ScheduledJobs.
func (s *scheduledJobLister) ScheduledJobs(namespace string) ScheduledJobNamespaceLister {
return scheduledJobNamespaceLister{indexer: s.indexer, namespace: namespace}
// CronJobs returns an object that can list and get CronJobs.
func (s *cronJobLister) CronJobs(namespace string) CronJobNamespaceLister {
return cronJobNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ScheduledJobNamespaceLister helps list and get ScheduledJobs.
type ScheduledJobNamespaceLister interface {
// List lists all ScheduledJobs in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v2alpha1.ScheduledJob, err error)
// Get retrieves the ScheduledJob from the indexer for a given namespace and name.
Get(name string) (*v2alpha1.ScheduledJob, error)
ScheduledJobNamespaceListerExpansion
// CronJobNamespaceLister helps list and get CronJobs.
type CronJobNamespaceLister interface {
// List lists all CronJobs in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v2alpha1.CronJob, err error)
// Get retrieves the CronJob from the indexer for a given namespace and name.
Get(name string) (*v2alpha1.CronJob, error)
CronJobNamespaceListerExpansion
}
// scheduledJobNamespaceLister implements the ScheduledJobNamespaceLister
// cronJobNamespaceLister implements the CronJobNamespaceLister
// interface.
type scheduledJobNamespaceLister struct {
type cronJobNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ScheduledJobs in the indexer for a given namespace.
func (s scheduledJobNamespaceLister) List(selector labels.Selector) (ret []*v2alpha1.ScheduledJob, err error) {
// List lists all CronJobs in the indexer for a given namespace.
func (s cronJobNamespaceLister) List(selector labels.Selector) (ret []*v2alpha1.CronJob, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v2alpha1.ScheduledJob))
ret = append(ret, m.(*v2alpha1.CronJob))
})
return ret, err
}
// Get retrieves the ScheduledJob from the indexer for a given namespace and name.
func (s scheduledJobNamespaceLister) Get(name string) (*v2alpha1.ScheduledJob, error) {
// Get retrieves the CronJob from the indexer for a given namespace and name.
func (s cronJobNamespaceLister) Get(name string) (*v2alpha1.CronJob, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(batch.Resource("scheduledjob"), name)
return nil, errors.NewNotFound(batch.Resource("cronjob"), name)
}
return obj.(*v2alpha1.ScheduledJob), nil
return obj.(*v2alpha1.CronJob), nil
}
......@@ -26,10 +26,10 @@ type JobListerExpansion interface{}
// JobNamespaeLister.
type JobNamespaceListerExpansion interface{}
// ScheduledJobListerExpansion allows custom methods to be added to
// ScheduledJobLister.
type ScheduledJobListerExpansion interface{}
// CronJobListerExpansion allows custom methods to be added to
// CronJobLister.
type CronJobListerExpansion interface{}
// ScheduledJobNamespaceListerExpansion allows custom methods to be added to
// ScheduledJobNamespaeLister.
type ScheduledJobNamespaceListerExpansion interface{}
// CronJobNamespaceListerExpansion allows custom methods to be added to
// CronJobNamespaeLister.
type CronJobNamespaceListerExpansion interface{}
......@@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scheduledjob
package cronjob
/*
I did not use watch or expectations. Those add a lot of corner cases, and we aren't
expecting a large volume of jobs or scheduledJobs. (We are favoring correctness
over scalability. If we find a single controller thread is too slow because
there are a lot of Jobs or ScheduledJobs, we we can parallelize by Namespace.
there are a lot of Jobs or CronJobs, we we can parallelize by Namespace.
If we find the load on the API server is too high, we can use a watch and
UndeltaStore.)
......@@ -49,9 +49,9 @@ import (
"k8s.io/kubernetes/pkg/util/wait"
)
// Utilities for dealing with Jobs and ScheduledJobs and time.
// Utilities for dealing with Jobs and CronJobs and time.
type ScheduledJobController struct {
type CronJobController struct {
kubeClient clientset.Interface
jobControl jobControlInterface
sjControl sjControlInterface
......@@ -59,51 +59,51 @@ type ScheduledJobController struct {
recorder record.EventRecorder
}
func NewScheduledJobController(kubeClient clientset.Interface) *ScheduledJobController {
func NewCronJobController(kubeClient clientset.Interface) *CronJobController {
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof)
// TODO: remove the wrapper when every clients have moved to use the clientset.
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{Interface: kubeClient.Core().Events("")})
if kubeClient != nil && kubeClient.Core().RESTClient().GetRateLimiter() != nil {
metrics.RegisterMetricAndTrackRateLimiterUsage("scheduledjob_controller", kubeClient.Core().RESTClient().GetRateLimiter())
metrics.RegisterMetricAndTrackRateLimiterUsage("cronjob_controller", kubeClient.Core().RESTClient().GetRateLimiter())
}
jm := &ScheduledJobController{
jm := &CronJobController{
kubeClient: kubeClient,
jobControl: realJobControl{KubeClient: kubeClient},
sjControl: &realSJControl{KubeClient: kubeClient},
podControl: &realPodControl{KubeClient: kubeClient},
recorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "scheduledjob-controller"}),
recorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "cronjob-controller"}),
}
return jm
}
func NewScheduledJobControllerFromClient(kubeClient clientset.Interface) *ScheduledJobController {
jm := NewScheduledJobController(kubeClient)
func NewCronJobControllerFromClient(kubeClient clientset.Interface) *CronJobController {
jm := NewCronJobController(kubeClient)
return jm
}
// Run the main goroutine responsible for watching and syncing jobs.
func (jm *ScheduledJobController) Run(stopCh <-chan struct{}) {
func (jm *CronJobController) Run(stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
glog.Infof("Starting ScheduledJob Manager")
glog.Infof("Starting CronJob Manager")
// Check things every 10 second.
go wait.Until(jm.SyncAll, 10*time.Second, stopCh)
<-stopCh
glog.Infof("Shutting down ScheduledJob Manager")
glog.Infof("Shutting down CronJob Manager")
}
// SyncAll lists all the ScheduledJobs and Jobs and reconciles them.
func (jm *ScheduledJobController) SyncAll() {
sjl, err := jm.kubeClient.Batch().ScheduledJobs(api.NamespaceAll).List(api.ListOptions{})
// SyncAll lists all the CronJobs and Jobs and reconciles them.
func (jm *CronJobController) SyncAll() {
sjl, err := jm.kubeClient.Batch().CronJobs(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
glog.Errorf("Error listing scheduledjobs: %v", err)
glog.Errorf("Error listing cronjobs: %v", err)
return
}
sjs := sjl.Items
glog.V(4).Infof("Found %d scheduledjobs", len(sjs))
glog.V(4).Infof("Found %d cronjobs", len(sjs))
jl, err := jm.kubeClient.Batch().Jobs(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
......@@ -121,11 +121,11 @@ func (jm *ScheduledJobController) SyncAll() {
}
}
// SyncOne reconciles a ScheduledJob with a list of any Jobs that it created.
// SyncOne reconciles a CronJob with a list of any Jobs that it created.
// 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 batch.ScheduledJob, js []batch.Job, now time.Time, jc jobControlInterface, sjc sjControlInterface, pc podControlInterface, recorder record.EventRecorder) {
func SyncOne(sj batch.CronJob, js []batch.Job, now time.Time, jc jobControlInterface, sjc sjControlInterface, pc podControlInterface, recorder record.EventRecorder) {
nameForLog := fmt.Sprintf("%s/%s", sj.Namespace, sj.Name)
for i := range js {
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scheduledjob
package cronjob
import (
"testing"
......@@ -72,17 +72,17 @@ func justAfterThePriorHour() time.Time {
return T1
}
// returns a scheduledJob with some fields filled in.
func scheduledJob() batch.ScheduledJob {
return batch.ScheduledJob{
// returns a cronJob with some fields filled in.
func cronJob() batch.CronJob {
return batch.CronJob{
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: "snazzycats",
UID: types.UID("1a2b3c"),
SelfLink: "/apis/batch/v2alpha1/namespaces/snazzycats/scheduledjobs/myscheduledjob",
SelfLink: "/apis/batch/v2alpha1/namespaces/snazzycats/cronjobs/mycronjob",
CreationTimestamp: unversioned.Time{Time: justBeforeTheHour()},
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -190,7 +190,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
"still active, is time, not past deadline": {A, F, onTheHour, longDead, T, T, justAfterTheHour(), T, F, 2},
}
for name, tc := range testCases {
sj := scheduledJob()
sj := cronJob()
sj.Spec.ConcurrencyPolicy = tc.concurrencyPolicy
sj.Spec.Suspend = &tc.suspend
sj.Spec.Schedule = tc.schedule
......@@ -338,7 +338,7 @@ func TestSyncOne_Status(t *testing.T) {
for name, tc := range testCases {
// Setup the test
sj := scheduledJob()
sj := cronJob()
sj.Spec.ConcurrencyPolicy = tc.concurrencyPolicy
sj.Spec.Suspend = &tc.suspend
sj.Spec.Schedule = tc.schedule
......
......@@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package scheduledjob contains the controller for ScheduledJob objects.
package scheduledjob
// Package cronjob contains the controller for CronJob objects.
package cronjob
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scheduledjob
package cronjob
import (
"fmt"
......@@ -27,10 +27,10 @@ import (
"k8s.io/kubernetes/pkg/labels"
)
// sjControlInterface is an interface that knows how to update ScheduledJob status
// sjControlInterface is an interface that knows how to update CronJob status
// created as an interface to allow testing.
type sjControlInterface interface {
UpdateStatus(sj *batch.ScheduledJob) (*batch.ScheduledJob, error)
UpdateStatus(sj *batch.CronJob) (*batch.CronJob, error)
}
// realSJControl is the default implementation of sjControlInterface.
......@@ -40,18 +40,18 @@ type realSJControl struct {
var _ sjControlInterface = &realSJControl{}
func (c *realSJControl) UpdateStatus(sj *batch.ScheduledJob) (*batch.ScheduledJob, error) {
return c.KubeClient.Batch().ScheduledJobs(sj.Namespace).UpdateStatus(sj)
func (c *realSJControl) UpdateStatus(sj *batch.CronJob) (*batch.CronJob, error) {
return c.KubeClient.Batch().CronJobs(sj.Namespace).UpdateStatus(sj)
}
// fakeSJControl is the default implementation of sjControlInterface.
type fakeSJControl struct {
Updates []batch.ScheduledJob
Updates []batch.CronJob
}
var _ sjControlInterface = &fakeSJControl{}
func (c *fakeSJControl) UpdateStatus(sj *batch.ScheduledJob) (*batch.ScheduledJob, error) {
func (c *fakeSJControl) UpdateStatus(sj *batch.CronJob) (*batch.CronJob, error) {
c.Updates = append(c.Updates, *sj)
return sj, nil
}
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scheduledjob
package cronjob
import (
"encoding/json"
......@@ -33,9 +33,9 @@ import (
hashutil "k8s.io/kubernetes/pkg/util/hash"
)
// Utilities for dealing with Jobs and ScheduledJobs and time.
// Utilities for dealing with Jobs and CronJobs and time.
func inActiveList(sj batch.ScheduledJob, uid types.UID) bool {
func inActiveList(sj batch.CronJob, uid types.UID) bool {
for _, j := range sj.Status.Active {
if j.UID == uid {
return true
......@@ -44,7 +44,7 @@ func inActiveList(sj batch.ScheduledJob, uid types.UID) bool {
return false
}
func deleteFromActiveList(sj *batch.ScheduledJob, uid types.UID) {
func deleteFromActiveList(sj *batch.CronJob, uid types.UID) {
if sj == nil {
return
}
......@@ -70,8 +70,8 @@ func getParentUIDFromJob(j batch.Job) (types.UID, bool) {
glog.V(4).Infof("Job with unparsable created-by annotation, name %s namespace %s: %v", j.Name, j.Namespace, err)
return types.UID(""), false
}
if sr.Reference.Kind != "ScheduledJob" {
glog.V(4).Infof("Job with non-ScheduledJob parent, name %s namespace %s", j.Name, j.Namespace)
if sr.Reference.Kind != "CronJob" {
glog.V(4).Infof("Job with non-CronJob parent, name %s namespace %s", j.Name, j.Namespace)
return types.UID(""), false
}
// Don't believe a job that claims to have a parent in a different namespace.
......@@ -85,7 +85,7 @@ func getParentUIDFromJob(j batch.Job) (types.UID, bool) {
// groupJobsByParent groups jobs into a map keyed by the job parent UID (e.g. scheduledJob).
// It has no receiver, to facilitate testing.
func groupJobsByParent(sjs []batch.ScheduledJob, js []batch.Job) map[types.UID][]batch.Job {
func groupJobsByParent(sjs []batch.CronJob, js []batch.Job) map[types.UID][]batch.Job {
jobsBySj := make(map[types.UID][]batch.Job)
for _, job := range js {
parentUID, found := getParentUIDFromJob(job)
......@@ -120,7 +120,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 batch.ScheduledJob, now time.Time) ([]time.Time, error) {
func getRecentUnmetScheduleTimes(sj batch.CronJob, now time.Time) ([]time.Time, error) {
starts := []time.Time{}
sched, err := cron.ParseStandard(sj.Spec.Schedule)
if err != nil {
......@@ -135,7 +135,7 @@ func getRecentUnmetScheduleTimes(sj batch.ScheduledJob, now time.Time) ([]time.T
// in kubernetes says it may need to be recreated), or that we have
// started a job, but have not noticed it yet (distributed systems can
// have arbitrary delays). In any case, use the creation time of the
// ScheduledJob as last known start time.
// CronJob as last known start time.
earliestTime = sj.ObjectMeta.CreationTimestamp.Time
}
......@@ -172,8 +172,8 @@ func getRecentUnmetScheduleTimes(sj batch.ScheduledJob, now time.Time) ([]time.T
// XXX unit test this
// getJobFromTemplate makes a Job from a ScheduledJob
func getJobFromTemplate(sj *batch.ScheduledJob, scheduledTime time.Time) (*batch.Job, error) {
// getJobFromTemplate makes a Job from a CronJob
func getJobFromTemplate(sj *batch.CronJob, scheduledTime time.Time) (*batch.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
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scheduledjob
package cronjob
import (
//"fmt"
......@@ -37,14 +37,14 @@ func TestGetJobFromTemplate(t *testing.T) {
var one int64 = 1
var no bool = false
sj := batch.ScheduledJob{
sj := batch.CronJob{
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: "snazzycats",
UID: types.UID("1a2b3c"),
SelfLink: "/apis/extensions/v1beta1/namespaces/snazzycats/jobs/myscheduledjob",
SelfLink: "/apis/extensions/v1beta1/namespaces/snazzycats/jobs/mycronjob",
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -77,7 +77,7 @@ func TestGetJobFromTemplate(t *testing.T) {
if err != nil {
t.Errorf("Did not expect error: %s", err)
}
if !strings.HasPrefix(job.ObjectMeta.Name, "myscheduledjob-") {
if !strings.HasPrefix(job.ObjectMeta.Name, "mycronjob-") {
t.Errorf("Wrong Name")
}
if len(job.ObjectMeta.Labels) != 1 {
......@@ -90,7 +90,7 @@ func TestGetJobFromTemplate(t *testing.T) {
if !ok {
t.Errorf("Missing created-by annotation")
}
expectedCreatedBy := `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ScheduledJob","namespace":"snazzycats","name":"myscheduledjob","uid":"1a2b3c","apiVersion":"extensions"}}
expectedCreatedBy := `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"snazzycats","name":"mycronjob","uid":"1a2b3c","apiVersion":"extensions"}}
`
if len(v) != len(expectedCreatedBy) {
t.Errorf("Wrong length for created-by annotation, expected %v got %v", len(expectedCreatedBy), len(v))
......@@ -140,7 +140,7 @@ func TestGetParentUIDFromJob(t *testing.T) {
}
{
// Case 2: Has UID annotation
j.ObjectMeta.Annotations = map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ScheduledJob","namespace":"default","name":"pi","uid":"5ef034e0-1890-11e6-8935-42010af0003e","apiVersion":"extensions","resourceVersion":"427339"}}`}
j.ObjectMeta.Annotations = map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"default","name":"pi","uid":"5ef034e0-1890-11e6-8935-42010af0003e","apiVersion":"extensions","resourceVersion":"427339"}}`}
expectedUID := types.UID("5ef034e0-1890-11e6-8935-42010af0003e")
......@@ -158,14 +158,14 @@ func TestGroupJobsByParent(t *testing.T) {
uid1 := types.UID("11111111-1111-1111-1111-111111111111")
uid2 := types.UID("22222222-2222-2222-2222-222222222222")
uid3 := types.UID("33333333-3333-3333-3333-333333333333")
createdBy1 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ScheduledJob","namespace":"x","name":"pi","uid":"11111111-1111-1111-1111-111111111111","apiVersion":"extensions","resourceVersion":"111111"}}`}
createdBy2 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ScheduledJob","namespace":"x","name":"pi","uid":"22222222-2222-2222-2222-222222222222","apiVersion":"extensions","resourceVersion":"222222"}}`}
createdBy3 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ScheduledJob","namespace":"y","name":"pi","uid":"33333333-3333-3333-3333-333333333333","apiVersion":"extensions","resourceVersion":"333333"}}`}
createdBy1 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"x","name":"pi","uid":"11111111-1111-1111-1111-111111111111","apiVersion":"extensions","resourceVersion":"111111"}}`}
createdBy2 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"x","name":"pi","uid":"22222222-2222-2222-2222-222222222222","apiVersion":"extensions","resourceVersion":"222222"}}`}
createdBy3 := map[string]string{api.CreatedByAnnotation: `{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"y","name":"pi","uid":"33333333-3333-3333-3333-333333333333","apiVersion":"extensions","resourceVersion":"333333"}}`}
noCreatedBy := map[string]string{}
{
// Case 1: There are no jobs and scheduledJobs
sjs := []batch.ScheduledJob{}
sjs := []batch.CronJob{}
js := []batch.Job{}
jobsBySj := groupJobsByParent(sjs, js)
if len(jobsBySj) != 0 {
......@@ -175,7 +175,7 @@ func TestGroupJobsByParent(t *testing.T) {
{
// Case 2: there is one controller with no job.
sjs := []batch.ScheduledJob{
sjs := []batch.CronJob{
{ObjectMeta: api.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}},
}
js := []batch.Job{}
......@@ -187,7 +187,7 @@ func TestGroupJobsByParent(t *testing.T) {
{
// Case 3: there is one controller with one job it created.
sjs := []batch.ScheduledJob{
sjs := []batch.CronJob{
{ObjectMeta: api.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}},
}
js := []batch.Job{
......@@ -219,7 +219,7 @@ func TestGroupJobsByParent(t *testing.T) {
{ObjectMeta: api.ObjectMeta{Name: "b", Namespace: "y", Annotations: createdBy3}},
{ObjectMeta: api.ObjectMeta{Name: "d", Namespace: "y", Annotations: noCreatedBy}},
}
sjs := []batch.ScheduledJob{
sjs := []batch.CronJob{
{ObjectMeta: api.ObjectMeta{Name: "e", Namespace: "x", UID: uid1}},
{ObjectMeta: api.ObjectMeta{Name: "f", Namespace: "x", UID: uid2}},
{ObjectMeta: api.ObjectMeta{Name: "g", Namespace: "y", UID: uid3}},
......@@ -269,13 +269,13 @@ func TestGetRecentUnmetScheduleTimes(t *testing.T) {
t.Errorf("test setup error: %v", err)
}
sj := batch.ScheduledJob{
sj := batch.CronJob{
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
UID: types.UID("1a2b3c"),
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: schedule,
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{},
......
......@@ -81,7 +81,7 @@ var (
# Start the perl container to compute π to 2000 places and print it out.
kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
# Start the scheduled job to compute π to 2000 places and print it out every 5 minutes.
# Start the cron job to compute π to 2000 places and print it out every 5 minutes.
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'`)
)
......@@ -197,7 +197,7 @@ func Run(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobr
generatorName := cmdutil.GetFlagString(cmd, "generator")
schedule := cmdutil.GetFlagString(cmd, "schedule")
if len(schedule) != 0 && len(generatorName) == 0 {
generatorName = "scheduledjob/v2alpha1"
generatorName = "cronjob/v2alpha1"
}
if len(generatorName) == 0 {
clientset, err := f.ClientSet()
......
......@@ -198,7 +198,7 @@ const (
DeploymentBasicV1Beta1GeneratorName = "deployment-basic/v1beta1"
JobV1Beta1GeneratorName = "job/v1beta1"
JobV1GeneratorName = "job/v1"
ScheduledJobV2Alpha1GeneratorName = "scheduledjob/v2alpha1"
CronJobV2Alpha1GeneratorName = "cronjob/v2alpha1"
NamespaceV1GeneratorName = "namespace/v1"
ResourceQuotaV1GeneratorName = "resourcequotas/v1"
SecretV1GeneratorName = "secret/v1"
......@@ -235,12 +235,12 @@ func DefaultGenerators(cmdName string) map[string]kubectl.Generator {
}
case "run":
generator = map[string]kubectl.Generator{
RunV1GeneratorName: kubectl.BasicReplicationController{},
RunPodV1GeneratorName: kubectl.BasicPod{},
DeploymentV1Beta1GeneratorName: kubectl.DeploymentV1Beta1{},
JobV1Beta1GeneratorName: kubectl.JobV1Beta1{},
JobV1GeneratorName: kubectl.JobV1{},
ScheduledJobV2Alpha1GeneratorName: kubectl.ScheduledJobV2Alpha1{},
RunV1GeneratorName: kubectl.BasicReplicationController{},
RunPodV1GeneratorName: kubectl.BasicPod{},
DeploymentV1Beta1GeneratorName: kubectl.DeploymentV1Beta1{},
JobV1Beta1GeneratorName: kubectl.JobV1Beta1{},
JobV1GeneratorName: kubectl.JobV1{},
CronJobV2Alpha1GeneratorName: kubectl.CronJobV2Alpha1{},
}
case "autoscale":
generator = map[string]kubectl.Generator{
......
......@@ -116,7 +116,7 @@ func describerMap(c clientset.Interface) map[unversioned.GroupKind]Describer {
extensions.Kind("Job"): &JobDescriber{c},
extensions.Kind("Ingress"): &IngressDescriber{c},
batch.Kind("Job"): &JobDescriber{c},
batch.Kind("ScheduledJob"): &ScheduledJobDescriber{c},
batch.Kind("CronJob"): &CronJobDescriber{c},
apps.Kind("StatefulSet"): &StatefulSetDescriber{c},
certificates.Kind("CertificateSigningRequest"): &CertificateSigningRequestDescriber{c},
storage.Kind("StorageClass"): &StorageClassDescriber{c},
......@@ -1222,13 +1222,13 @@ func describeJob(job *batch.Job, events *api.EventList) (string, error) {
})
}
// ScheduledJobDescriber generates information about a scheduled job and the jobs it has created.
type ScheduledJobDescriber struct {
// CronJobDescriber generates information about a scheduled job and the jobs it has created.
type CronJobDescriber struct {
clientset.Interface
}
func (d *ScheduledJobDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (string, error) {
scheduledJob, err := d.Batch().ScheduledJobs(namespace).Get(name)
func (d *CronJobDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (string, error) {
scheduledJob, err := d.Batch().CronJobs(namespace).Get(name)
if err != nil {
return "", err
}
......@@ -1238,10 +1238,10 @@ func (d *ScheduledJobDescriber) Describe(namespace, name string, describerSettin
events, _ = d.Core().Events(namespace).Search(scheduledJob)
}
return describeScheduledJob(scheduledJob, events)
return describeCronJob(scheduledJob, events)
}
func describeScheduledJob(scheduledJob *batch.ScheduledJob, events *api.EventList) (string, error) {
func describeCronJob(scheduledJob *batch.CronJob, events *api.EventList) (string, error) {
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", scheduledJob.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", scheduledJob.Namespace)
......
......@@ -477,7 +477,7 @@ var (
replicationControllerColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "AGE"}
replicaSetColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "AGE"}
jobColumns = []string{"NAME", "DESIRED", "SUCCESSFUL", "AGE"}
scheduledJobColumns = []string{"NAME", "SCHEDULE", "SUSPEND", "ACTIVE", "LAST-SCHEDULE"}
cronJobColumns = []string{"NAME", "SCHEDULE", "SUSPEND", "ACTIVE", "LAST-SCHEDULE"}
serviceColumns = []string{"NAME", "CLUSTER-IP", "EXTERNAL-IP", "PORT(S)", "AGE"}
ingressColumns = []string{"NAME", "HOSTS", "ADDRESS", "PORTS", "AGE"}
statefulSetColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"}
......@@ -544,8 +544,8 @@ func (h *HumanReadablePrinter) addDefaultHandlers() {
h.Handler(daemonSetColumns, printDaemonSetList)
h.Handler(jobColumns, printJob)
h.Handler(jobColumns, printJobList)
h.Handler(scheduledJobColumns, printScheduledJob)
h.Handler(scheduledJobColumns, printScheduledJobList)
h.Handler(cronJobColumns, printCronJob)
h.Handler(cronJobColumns, printCronJobList)
h.Handler(serviceColumns, printService)
h.Handler(serviceColumns, printServiceList)
h.Handler(ingressColumns, printIngress)
......@@ -1028,9 +1028,9 @@ func printJobList(list *batch.JobList, w io.Writer, options PrintOptions) error
return nil
}
func printScheduledJob(scheduledJob *batch.ScheduledJob, w io.Writer, options PrintOptions) error {
name := scheduledJob.Name
namespace := scheduledJob.Namespace
func printCronJob(cronJob *batch.CronJob, w io.Writer, options PrintOptions) error {
name := cronJob.Name
namespace := cronJob.Namespace
if options.WithNamespace {
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
......@@ -1039,14 +1039,14 @@ func printScheduledJob(scheduledJob *batch.ScheduledJob, w io.Writer, options Pr
}
lastScheduleTime := "<none>"
if scheduledJob.Status.LastScheduleTime != nil {
lastScheduleTime = scheduledJob.Status.LastScheduleTime.Time.Format(time.RFC1123Z)
if cronJob.Status.LastScheduleTime != nil {
lastScheduleTime = cronJob.Status.LastScheduleTime.Time.Format(time.RFC1123Z)
}
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%d\t%s\n",
name,
scheduledJob.Spec.Schedule,
printBoolPtr(scheduledJob.Spec.Suspend),
len(scheduledJob.Status.Active),
cronJob.Spec.Schedule,
printBoolPtr(cronJob.Spec.Suspend),
len(cronJob.Status.Active),
lastScheduleTime,
); err != nil {
return err
......@@ -1055,9 +1055,9 @@ func printScheduledJob(scheduledJob *batch.ScheduledJob, w io.Writer, options Pr
return nil
}
func printScheduledJobList(list *batch.ScheduledJobList, w io.Writer, options PrintOptions) error {
for _, scheduledJob := range list.Items {
if err := printScheduledJob(&scheduledJob, w, options); err != nil {
func printCronJobList(list *batch.CronJobList, w io.Writer, options PrintOptions) error {
for _, cronJob := range list.Items {
if err := printCronJob(&cronJob, w, options); err != nil {
return err
}
}
......
......@@ -401,9 +401,9 @@ func (JobV1) Generate(genericParams map[string]interface{}) (runtime.Object, err
return &job, nil
}
type ScheduledJobV2Alpha1 struct{}
type CronJobV2Alpha1 struct{}
func (ScheduledJobV2Alpha1) ParamNames() []GeneratorParam {
func (CronJobV2Alpha1) ParamNames() []GeneratorParam {
return []GeneratorParam{
{"labels", false},
{"default-name", false},
......@@ -425,7 +425,7 @@ func (ScheduledJobV2Alpha1) ParamNames() []GeneratorParam {
}
}
func (ScheduledJobV2Alpha1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
func (CronJobV2Alpha1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
......@@ -477,12 +477,12 @@ func (ScheduledJobV2Alpha1) Generate(genericParams map[string]interface{}) (runt
}
podSpec.RestartPolicy = restartPolicy
scheduledJob := batchv2alpha1.ScheduledJob{
cronJob := batchv2alpha1.CronJob{
ObjectMeta: v1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: batchv2alpha1.ScheduledJobSpec{
Spec: batchv2alpha1.CronJobSpec{
Schedule: params["schedule"],
ConcurrencyPolicy: batchv2alpha1.AllowConcurrent,
JobTemplate: batchv2alpha1.JobTemplateSpec{
......@@ -498,7 +498,7 @@ func (ScheduledJobV2Alpha1) Generate(genericParams map[string]interface{}) (runt
},
}
return &scheduledJob, nil
return &cronJob, nil
}
type BasicReplicationController struct{}
......
......@@ -14,6 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package scheduledjob provides Registry interface and it's RESTStorage
// Package cronjob provides Registry interface and it's RESTStorage
// implementation for storing ScheduledJob api objects.
package scheduledjob // import "k8s.io/kubernetes/pkg/registry/batch/scheduledjob"
package cronjob // import "k8s.io/kubernetes/pkg/registry/batch/cronjob"
......@@ -18,7 +18,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/api/rest:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/registry/batch/scheduledjob:go_default_library",
"//pkg/registry/batch/cronjob:go_default_library",
"//pkg/registry/cachesize:go_default_library",
"//pkg/registry/generic:go_default_library",
"//pkg/registry/generic/registry:go_default_library",
......
......@@ -20,7 +20,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/registry/batch/scheduledjob"
"k8s.io/kubernetes/pkg/registry/batch/cronjob"
"k8s.io/kubernetes/pkg/registry/cachesize"
"k8s.io/kubernetes/pkg/registry/generic"
"k8s.io/kubernetes/pkg/registry/generic/registry"
......@@ -33,23 +33,23 @@ type REST struct {
*registry.Store
}
// NewREST returns a RESTStorage object that will work against ScheduledJobs.
// NewREST returns a RESTStorage object that will work against CronJobs.
func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
prefix := "/" + opts.ResourcePrefix
newListFunc := func() runtime.Object { return &batch.ScheduledJobList{} }
newListFunc := func() runtime.Object { return &batch.CronJobList{} }
storageInterface, dFunc := opts.Decorator(
opts.StorageConfig,
cachesize.GetWatchCacheSizeByResource(cachesize.ScheduledJobs),
&batch.ScheduledJob{},
cachesize.GetWatchCacheSizeByResource(cachesize.CronJobs),
&batch.CronJob{},
prefix,
scheduledjob.Strategy,
cronjob.Strategy,
newListFunc,
storage.NoTriggerPublisher,
)
store := &registry.Store{
NewFunc: func() runtime.Object { return &batch.ScheduledJob{} },
NewFunc: func() runtime.Object { return &batch.CronJob{} },
// NewListFunc returns an object capable of storing results of an etcd list.
NewListFunc: newListFunc,
......@@ -65,27 +65,27 @@ func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
},
// Retrieve the name field of a scheduled job
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*batch.ScheduledJob).Name, nil
return obj.(*batch.CronJob).Name, nil
},
// Used to match objects based on labels/fields for list and watch
PredicateFunc: scheduledjob.MatchScheduledJob,
QualifiedResource: batch.Resource("scheduledjobs"),
PredicateFunc: cronjob.MatchCronJob,
QualifiedResource: batch.Resource("cronjobs"),
EnableGarbageCollection: opts.EnableGarbageCollection,
DeleteCollectionWorkers: opts.DeleteCollectionWorkers,
// Used to validate scheduled job creation
CreateStrategy: scheduledjob.Strategy,
CreateStrategy: cronjob.Strategy,
// Used to validate scheduled job updates
UpdateStrategy: scheduledjob.Strategy,
DeleteStrategy: scheduledjob.Strategy,
UpdateStrategy: cronjob.Strategy,
DeleteStrategy: cronjob.Strategy,
Storage: storageInterface,
DestroyFunc: dFunc,
}
statusStore := *store
statusStore.UpdateStrategy = scheduledjob.StatusStrategy
statusStore.UpdateStrategy = cronjob.StatusStrategy
return &REST{store}, &StatusREST{store: &statusStore}
}
......@@ -96,7 +96,7 @@ type StatusREST struct {
}
func (r *StatusREST) New() runtime.Object {
return &batch.ScheduledJob{}
return &batch.CronJob{}
}
// Get retrieves the object from the storage. It is required to support Patch.
......
......@@ -38,13 +38,13 @@ func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer)
return storage, statusStorage, server
}
func validNewScheduledJob() *batch.ScheduledJob {
return &batch.ScheduledJob{
func validNewCronJob() *batch.CronJob {
return &batch.CronJob{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: api.NamespaceDefault,
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -72,14 +72,14 @@ func TestCreate(t *testing.T) {
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
validScheduledJob := validNewScheduledJob()
validScheduledJob.ObjectMeta = api.ObjectMeta{}
validCronJob := validNewCronJob()
validCronJob.ObjectMeta = api.ObjectMeta{}
test.TestCreate(
// valid
validScheduledJob,
validCronJob,
// invalid (empty spec)
&batch.ScheduledJob{
Spec: batch.ScheduledJobSpec{},
&batch.CronJob{
Spec: batch.CronJobSpec{},
},
)
}
......@@ -97,16 +97,16 @@ func TestUpdate(t *testing.T) {
schedule := "1 1 1 1 ?"
test.TestUpdate(
// valid
validNewScheduledJob(),
validNewCronJob(),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*batch.ScheduledJob)
object := obj.(*batch.CronJob)
object.Spec.Schedule = schedule
return object
},
// invalid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*batch.ScheduledJob)
object := obj.(*batch.CronJob)
object.Spec.Schedule = "* * *"
return object
},
......@@ -123,7 +123,7 @@ func TestDelete(t *testing.T) {
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestDelete(validNewScheduledJob())
test.TestDelete(validNewCronJob())
}
func TestGet(t *testing.T) {
......@@ -136,7 +136,7 @@ func TestGet(t *testing.T) {
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestGet(validNewScheduledJob())
test.TestGet(validNewCronJob())
}
func TestList(t *testing.T) {
......@@ -149,7 +149,7 @@ func TestList(t *testing.T) {
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestList(validNewScheduledJob())
test.TestList(validNewCronJob())
}
func TestWatch(t *testing.T) {
......@@ -163,7 +163,7 @@ func TestWatch(t *testing.T) {
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestWatch(
validNewScheduledJob(),
validNewCronJob(),
// matching labels
[]labels.Set{},
// not matching labels
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scheduledjob
package cronjob
import (
"fmt"
......@@ -36,7 +36,7 @@ type scheduledJobStrategy struct {
api.NameGenerator
}
// Strategy is the default logic that applies when creating and updating ScheduledJob objects.
// Strategy is the default logic that applies when creating and updating CronJob objects.
var Strategy = scheduledJobStrategy{api.Scheme, api.SimpleNameGenerator}
// NamespaceScoped returns true because all scheduled jobs need to be within a namespace.
......@@ -46,21 +46,21 @@ func (scheduledJobStrategy) NamespaceScoped() bool {
// PrepareForCreate clears the status of a scheduled job before creation.
func (scheduledJobStrategy) PrepareForCreate(ctx api.Context, obj runtime.Object) {
scheduledJob := obj.(*batch.ScheduledJob)
scheduledJob.Status = batch.ScheduledJobStatus{}
scheduledJob := obj.(*batch.CronJob)
scheduledJob.Status = batch.CronJobStatus{}
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (scheduledJobStrategy) PrepareForUpdate(ctx api.Context, obj, old runtime.Object) {
newScheduledJob := obj.(*batch.ScheduledJob)
oldScheduledJob := old.(*batch.ScheduledJob)
newScheduledJob.Status = oldScheduledJob.Status
newCronJob := obj.(*batch.CronJob)
oldCronJob := old.(*batch.CronJob)
newCronJob.Status = oldCronJob.Status
}
// Validate validates a new scheduled job.
func (scheduledJobStrategy) Validate(ctx api.Context, obj runtime.Object) field.ErrorList {
scheduledJob := obj.(*batch.ScheduledJob)
return validation.ValidateScheduledJob(scheduledJob)
scheduledJob := obj.(*batch.CronJob)
return validation.ValidateCronJob(scheduledJob)
}
// Canonicalize normalizes the object after validation.
......@@ -78,7 +78,7 @@ func (scheduledJobStrategy) AllowCreateOnUpdate() bool {
// ValidateUpdate is the default update validation for an end user.
func (scheduledJobStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateScheduledJob(obj.(*batch.ScheduledJob))
return validation.ValidateCronJob(obj.(*batch.CronJob))
}
type scheduledJobStatusStrategy struct {
......@@ -88,8 +88,8 @@ type scheduledJobStatusStrategy struct {
var StatusStrategy = scheduledJobStatusStrategy{Strategy}
func (scheduledJobStatusStrategy) PrepareForUpdate(ctx api.Context, obj, old runtime.Object) {
newJob := obj.(*batch.ScheduledJob)
oldJob := old.(*batch.ScheduledJob)
newJob := obj.(*batch.CronJob)
oldJob := old.(*batch.CronJob)
newJob.Spec = oldJob.Spec
}
......@@ -97,24 +97,24 @@ func (scheduledJobStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runti
return field.ErrorList{}
}
// ScheduledJobToSelectableFields returns a field set that represents the object for matching purposes.
func ScheduledJobToSelectableFields(scheduledJob *batch.ScheduledJob) fields.Set {
// CronJobToSelectableFields returns a field set that represents the object for matching purposes.
func CronJobToSelectableFields(scheduledJob *batch.CronJob) fields.Set {
return generic.ObjectMetaFieldsSet(&scheduledJob.ObjectMeta, true)
}
// MatchScheduledJob is the filter used by the generic etcd backend to route
// MatchCronJob is the filter used by the generic etcd backend to route
// watch events from etcd to clients of the apiserver only interested in specific
// labels/fields.
func MatchScheduledJob(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
func MatchCronJob(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
return storage.SelectionPredicate{
Label: label,
Field: field,
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
scheduledJob, ok := obj.(*batch.ScheduledJob)
scheduledJob, ok := obj.(*batch.CronJob)
if !ok {
return nil, nil, fmt.Errorf("Given object is not a scheduled job.")
}
return labels.Set(scheduledJob.ObjectMeta.Labels), ScheduledJobToSelectableFields(scheduledJob), nil
return labels.Set(scheduledJob.ObjectMeta.Labels), CronJobToSelectableFields(scheduledJob), nil
},
}
}
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package scheduledjob
package cronjob
import (
"testing"
......@@ -31,13 +31,13 @@ func newBool(a bool) *bool {
return r
}
func TestScheduledJobStrategy(t *testing.T) {
func TestCronJobStrategy(t *testing.T) {
ctx := api.NewDefaultContext()
if !Strategy.NamespaceScoped() {
t.Errorf("ScheduledJob must be namespace scoped")
t.Errorf("CronJob must be namespace scoped")
}
if Strategy.AllowCreateOnUpdate() {
t.Errorf("ScheduledJob should not allow create on update")
t.Errorf("CronJob should not allow create on update")
}
validPodTemplateSpec := api.PodTemplateSpec{
......@@ -47,12 +47,12 @@ func TestScheduledJobStrategy(t *testing.T) {
Containers: []api.Container{{Name: "abc", Image: "image", ImagePullPolicy: "IfNotPresent"}},
},
}
scheduledJob := &batch.ScheduledJob{
scheduledJob := &batch.CronJob{
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "* * * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -65,41 +65,41 @@ func TestScheduledJobStrategy(t *testing.T) {
Strategy.PrepareForCreate(ctx, scheduledJob)
if len(scheduledJob.Status.Active) != 0 {
t.Errorf("ScheduledJob does not allow setting status on create")
t.Errorf("CronJob does not allow setting status on create")
}
errs := Strategy.Validate(ctx, scheduledJob)
if len(errs) != 0 {
t.Errorf("Unexpected error validating %v", errs)
}
now := unversioned.Now()
updatedScheduledJob := &batch.ScheduledJob{
updatedCronJob := &batch.CronJob{
ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "4"},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "5 5 5 * ?",
},
Status: batch.ScheduledJobStatus{
Status: batch.CronJobStatus{
LastScheduleTime: &now,
},
}
// ensure we do not change status
Strategy.PrepareForUpdate(ctx, updatedScheduledJob, scheduledJob)
if updatedScheduledJob.Status.Active != nil {
Strategy.PrepareForUpdate(ctx, updatedCronJob, scheduledJob)
if updatedCronJob.Status.Active != nil {
t.Errorf("PrepareForUpdate should have preserved prior version status")
}
errs = Strategy.ValidateUpdate(ctx, updatedScheduledJob, scheduledJob)
errs = Strategy.ValidateUpdate(ctx, updatedCronJob, scheduledJob)
if len(errs) == 0 {
t.Errorf("Expected a validation error")
}
}
func TestScheduledJobStatusStrategy(t *testing.T) {
func TestCronJobStatusStrategy(t *testing.T) {
ctx := api.NewDefaultContext()
if !StatusStrategy.NamespaceScoped() {
t.Errorf("ScheduledJob must be namespace scoped")
t.Errorf("CronJob must be namespace scoped")
}
if StatusStrategy.AllowCreateOnUpdate() {
t.Errorf("ScheduledJob should not allow create on update")
t.Errorf("CronJob should not allow create on update")
}
validPodTemplateSpec := api.PodTemplateSpec{
Spec: api.PodSpec{
......@@ -109,13 +109,13 @@ func TestScheduledJobStatusStrategy(t *testing.T) {
},
}
oldSchedule := "* * * * ?"
oldScheduledJob := &batch.ScheduledJob{
oldCronJob := &batch.CronJob{
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
ResourceVersion: "10",
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: oldSchedule,
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -126,13 +126,13 @@ func TestScheduledJobStatusStrategy(t *testing.T) {
},
}
now := unversioned.Now()
newScheduledJob := &batch.ScheduledJob{
newCronJob := &batch.CronJob{
ObjectMeta: api.ObjectMeta{
Name: "myscheduledjob",
Name: "mycronjob",
Namespace: api.NamespaceDefault,
ResourceVersion: "9",
},
Spec: batch.ScheduledJobSpec{
Spec: batch.CronJobSpec{
Schedule: "5 5 * * ?",
ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{
......@@ -141,23 +141,23 @@ func TestScheduledJobStatusStrategy(t *testing.T) {
},
},
},
Status: batch.ScheduledJobStatus{
Status: batch.CronJobStatus{
LastScheduleTime: &now,
},
}
StatusStrategy.PrepareForUpdate(ctx, newScheduledJob, oldScheduledJob)
if newScheduledJob.Status.LastScheduleTime == nil {
t.Errorf("ScheduledJob status updates must allow changes to scheduledJob status")
StatusStrategy.PrepareForUpdate(ctx, newCronJob, oldCronJob)
if newCronJob.Status.LastScheduleTime == nil {
t.Errorf("CronJob status updates must allow changes to scheduledJob status")
}
if newScheduledJob.Spec.Schedule != oldSchedule {
t.Errorf("ScheduledJob status updates must now allow changes to scheduledJob spec")
if newCronJob.Spec.Schedule != oldSchedule {
t.Errorf("CronJob status updates must now allow changes to scheduledJob spec")
}
errs := StatusStrategy.ValidateUpdate(ctx, newScheduledJob, oldScheduledJob)
errs := StatusStrategy.ValidateUpdate(ctx, newCronJob, oldCronJob)
if len(errs) != 0 {
t.Errorf("Unexpected error %v", errs)
}
if newScheduledJob.ResourceVersion != "9" {
if newCronJob.ResourceVersion != "9" {
t.Errorf("Incoming resource version on update should not be mutated")
}
}
......@@ -166,8 +166,8 @@ func TestScheduledJobStatusStrategy(t *testing.T) {
func TestSelectableFieldLabelConversions(t *testing.T) {
apitesting.TestSelectableFieldLabelConversionsOfKind(t,
"batch/v2alpha1",
"ScheduledJob",
ScheduledJobToSelectableFields(&batch.ScheduledJob{}),
"CronJob",
CronJobToSelectableFields(&batch.CronJob{}),
nil,
)
}
......@@ -16,11 +16,12 @@ go_library(
tags = ["automanaged"],
deps = [
"//pkg/api/rest:go_default_library",
"//pkg/api/unversioned:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/batch/v1:go_default_library",
"//pkg/apis/batch/v2alpha1:go_default_library",
"//pkg/genericapiserver:go_default_library",
"//pkg/registry/batch/cronjob/etcd:go_default_library",
"//pkg/registry/batch/job/etcd:go_default_library",
"//pkg/registry/batch/scheduledjob/etcd:go_default_library",
],
)
......@@ -22,8 +22,8 @@ import (
batchapiv1 "k8s.io/kubernetes/pkg/apis/batch/v1"
batchapiv2alpha1 "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
"k8s.io/kubernetes/pkg/genericapiserver"
cronjobetcd "k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd"
jobetcd "k8s.io/kubernetes/pkg/registry/batch/job/etcd"
scheduledjobetcd "k8s.io/kubernetes/pkg/registry/batch/scheduledjob/etcd"
)
type RESTStorageProvider struct{}
......@@ -66,10 +66,10 @@ func (p RESTStorageProvider) v2alpha1Storage(apiResourceConfigSource genericapis
storage["jobs"] = jobsStorage
storage["jobs/status"] = jobsStatusStorage
}
if apiResourceConfigSource.ResourceEnabled(version.WithResource("scheduledjobs")) {
scheduledJobsStorage, scheduledJobsStatusStorage := scheduledjobetcd.NewREST(restOptionsGetter(batch.Resource("scheduledjobs")))
storage["scheduledjobs"] = scheduledJobsStorage
storage["scheduledjobs/status"] = scheduledJobsStatusStorage
if apiResourceConfigSource.ResourceEnabled(version.WithResource("cronjobs")) {
cronJobsStorage, cronJobsStatusStorage := cronjobetcd.NewREST(restOptionsGetter(batch.Resource("cronjobs")))
storage["cronjobs"] = cronJobsStorage
storage["cronjobs/status"] = cronJobsStatusStorage
}
return storage
}
......
......@@ -52,7 +52,7 @@ const (
PodTemplates Resource = "podtemplates"
Replicasets Resource = "replicasets"
ResourceQuotas Resource = "resourcequotas"
ScheduledJobs Resource = "scheduledjobs"
CronJobs Resource = "cronjobs"
Roles Resource = "roles"
RoleBindings Resource = "rolebindings"
Secrets Resource = "secrets"
......
......@@ -86,7 +86,7 @@ func ClusterRoles() []rbac.ClusterRole {
rbac.NewRule(ReadWrite...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "scheduledjobs").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "cronjobs").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(extensionsGroup).Resources("jobs", "daemonsets", "horizontalpodautoscalers",
"replicationcontrollers/scale", "replicasets", "replicasets/scale", "deployments", "deployments/scale").RuleOrDie(),
......@@ -116,7 +116,7 @@ func ClusterRoles() []rbac.ClusterRole {
rbac.NewRule(ReadWrite...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "scheduledjobs").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(batchGroup).Resources("jobs", "cronjobs").RuleOrDie(),
rbac.NewRule(ReadWrite...).Groups(extensionsGroup).Resources("jobs", "daemonsets", "horizontalpodautoscalers",
"replicationcontrollers/scale", "replicasets", "replicasets/scale", "deployments", "deployments/scale").RuleOrDie(),
......@@ -139,7 +139,7 @@ func ClusterRoles() []rbac.ClusterRole {
rbac.NewRule(Read...).Groups(autoscalingGroup).Resources("horizontalpodautoscalers").RuleOrDie(),
rbac.NewRule(Read...).Groups(batchGroup).Resources("jobs", "scheduledjobs").RuleOrDie(),
rbac.NewRule(Read...).Groups(batchGroup).Resources("jobs", "cronjobs").RuleOrDie(),
rbac.NewRule(Read...).Groups(extensionsGroup).Resources("jobs", "daemonsets", "horizontalpodautoscalers",
"replicationcontrollers/scale", "replicasets", "replicasets/scale", "deployments", "deployments/scale").RuleOrDie(),
......
......@@ -22,6 +22,7 @@ go_library(
"cluster_logging_utils.go",
"cluster_size_autoscaling.go",
"cluster_upgrade.go",
"cronjob.go",
"daemon_restart.go",
"daemon_set.go",
"dashboard.go",
......@@ -91,7 +92,6 @@ go_library(
"resize_nodes.go",
"resource_quota.go",
"restart.go",
"scheduledjob.go",
"scheduler_predicates.go",
"security_context.go",
"service.go",
......
......@@ -188,17 +188,17 @@ var _ = framework.KubeDescribe("Generated release_1_5 clientset", func() {
})
})
func newTestingScheduledJob(name string, value string) *v2alpha1.ScheduledJob {
func newTestingCronJob(name string, value string) *v2alpha1.CronJob {
parallelism := int32(1)
completions := int32(1)
return &v2alpha1.ScheduledJob{
return &v2alpha1.CronJob{
ObjectMeta: v1.ObjectMeta{
Name: name,
Labels: map[string]string{
"time": value,
},
},
Spec: v2alpha1.ScheduledJobSpec{
Spec: v2alpha1.CronJobSpec{
Schedule: "*/1 * * * ?",
ConcurrencyPolicy: v2alpha1.AllowConcurrent,
JobTemplate: v2alpha1.JobTemplateSpec{
......@@ -238,7 +238,7 @@ func newTestingScheduledJob(name string, value string) *v2alpha1.ScheduledJob {
var _ = framework.KubeDescribe("Generated release_1_5 clientset", func() {
f := framework.NewDefaultFramework("clientset")
It("should create v2alpha1 scheduleJobs, delete scheduleJobs, watch scheduleJobs", func() {
It("should create v2alpha1 cronJobs, delete cronJobs, watch cronJobs", func() {
var enabled bool
groupList, err := f.ClientSet_1_5.Discovery().ServerGroups()
ExpectNoError(err)
......@@ -256,59 +256,59 @@ var _ = framework.KubeDescribe("Generated release_1_5 clientset", func() {
framework.Logf("%s is not enabled, test skipped", v2alpha1.SchemeGroupVersion)
return
}
scheduleJobClient := f.ClientSet_1_5.BatchV2alpha1().ScheduledJobs(f.Namespace.Name)
By("constructing the scheduledJob")
name := "scheduledjob" + string(uuid.NewUUID())
cronJobClient := f.ClientSet_1_5.BatchV2alpha1().CronJobs(f.Namespace.Name)
By("constructing the cronJob")
name := "cronjob" + string(uuid.NewUUID())
value := strconv.Itoa(time.Now().Nanosecond())
scheduledJob := newTestingScheduledJob(name, value)
cronJob := newTestingCronJob(name, value)
By("setting up watch")
selector := labels.SelectorFromSet(labels.Set(map[string]string{"time": value})).String()
options := v1.ListOptions{LabelSelector: selector}
scheduleJobs, err := scheduleJobClient.List(options)
cronJobs, err := cronJobClient.List(options)
if err != nil {
framework.Failf("Failed to query for scheduleJobs: %v", err)
framework.Failf("Failed to query for cronJobs: %v", err)
}
Expect(len(scheduleJobs.Items)).To(Equal(0))
Expect(len(cronJobs.Items)).To(Equal(0))
options = v1.ListOptions{
LabelSelector: selector,
ResourceVersion: scheduleJobs.ListMeta.ResourceVersion,
ResourceVersion: cronJobs.ListMeta.ResourceVersion,
}
w, err := scheduleJobClient.Watch(options)
w, err := cronJobClient.Watch(options)
if err != nil {
framework.Failf("Failed to set up watch: %v", err)
}
By("creating the scheduledJob")
scheduledJob, err = scheduleJobClient.Create(scheduledJob)
By("creating the cronJob")
cronJob, err = cronJobClient.Create(cronJob)
if err != nil {
framework.Failf("Failed to create scheduledJob: %v", err)
framework.Failf("Failed to create cronJob: %v", err)
}
By("verifying the scheduledJob is in kubernetes")
By("verifying the cronJob is in kubernetes")
options = v1.ListOptions{
LabelSelector: selector,
ResourceVersion: scheduledJob.ResourceVersion,
ResourceVersion: cronJob.ResourceVersion,
}
scheduleJobs, err = scheduleJobClient.List(options)
cronJobs, err = cronJobClient.List(options)
if err != nil {
framework.Failf("Failed to query for scheduleJobs: %v", err)
framework.Failf("Failed to query for cronJobs: %v", err)
}
Expect(len(scheduleJobs.Items)).To(Equal(1))
Expect(len(cronJobs.Items)).To(Equal(1))
By("verifying scheduledJob creation was observed")
By("verifying cronJob creation was observed")
observeCreation(w)
By("deleting the scheduledJob")
if err := scheduleJobClient.Delete(scheduledJob.Name, nil); err != nil {
framework.Failf("Failed to delete scheduledJob: %v", err)
By("deleting the cronJob")
if err := cronJobClient.Delete(cronJob.Name, nil); err != nil {
framework.Failf("Failed to delete cronJob: %v", err)
}
options = v1.ListOptions{LabelSelector: selector}
scheduleJobs, err = scheduleJobClient.List(options)
cronJobs, err = cronJobClient.List(options)
if err != nil {
framework.Failf("Failed to list scheduleJobs to verify deletion: %v", err)
framework.Failf("Failed to list cronJobs to verify deletion: %v", err)
}
Expect(len(scheduleJobs.Items)).To(Equal(0))
Expect(len(cronJobs.Items)).To(Equal(0))
})
})
......
......@@ -183,39 +183,39 @@ var _ = framework.KubeDescribe("Kubectl alpha client", func() {
// Customized Wait / ForEach wrapper for this test. These demonstrate the
framework.KubeDescribe("Kubectl run ScheduledJob", func() {
framework.KubeDescribe("Kubectl run CronJob", func() {
var nsFlag string
var sjName string
var cjName string
BeforeEach(func() {
nsFlag = fmt.Sprintf("--namespace=%v", ns)
sjName = "e2e-test-echo-scheduledjob"
cjName = "e2e-test-echo-cronjob"
})
AfterEach(func() {
framework.RunKubectlOrDie("delete", "scheduledjobs", sjName, nsFlag)
framework.RunKubectlOrDie("delete", "cronjobs", cjName, nsFlag)
})
It("should create a ScheduledJob", func() {
framework.SkipIfMissingResource(f.ClientPool, ScheduledJobGroupVersionResource, f.Namespace.Name)
It("should create a CronJob", func() {
framework.SkipIfMissingResource(f.ClientPool, CronJobGroupVersionResource, f.Namespace.Name)
schedule := "*/5 * * * ?"
framework.RunKubectlOrDie("run", sjName, "--restart=OnFailure", "--generator=scheduledjob/v2alpha1",
framework.RunKubectlOrDie("run", cjName, "--restart=OnFailure", "--generator=cronjob/v2alpha1",
"--schedule="+schedule, "--image="+busyboxImage, nsFlag)
By("verifying the ScheduledJob " + sjName + " was created")
sj, err := c.Batch().ScheduledJobs(ns).Get(sjName)
By("verifying the CronJob " + cjName + " was created")
sj, err := c.Batch().CronJobs(ns).Get(cjName)
if err != nil {
framework.Failf("Failed getting ScheduledJob %s: %v", sjName, err)
framework.Failf("Failed getting CronJob %s: %v", cjName, err)
}
if sj.Spec.Schedule != schedule {
framework.Failf("Failed creating a ScheduledJob with correct schedule %s", schedule)
framework.Failf("Failed creating a CronJob with correct schedule %s", schedule)
}
containers := sj.Spec.JobTemplate.Spec.Template.Spec.Containers
if containers == nil || len(containers) != 1 || containers[0].Image != busyboxImage {
framework.Failf("Failed creating ScheduledJob %s for 1 pod with expected image %s: %#v", sjName, busyboxImage, containers)
framework.Failf("Failed creating CronJob %s for 1 pod with expected image %s: %#v", cjName, busyboxImage, containers)
}
if sj.Spec.JobTemplate.Spec.Template.Spec.RestartPolicy != api.RestartPolicyOnFailure {
framework.Failf("Failed creating a ScheduledJob with correct restart policy for --restart=OnFailure")
framework.Failf("Failed creating a CronJob with correct restart policy for --restart=OnFailure")
}
})
})
......
......@@ -586,7 +586,7 @@ k8s.io/kubernetes/pkg/controller/replicaset,fgrzadkowski,0
k8s.io/kubernetes/pkg/controller/replication,fgrzadkowski,0
k8s.io/kubernetes/pkg/controller/resourcequota,ghodss,1
k8s.io/kubernetes/pkg/controller/route,gmarek,0
k8s.io/kubernetes/pkg/controller/scheduledjob,soltysh,1
k8s.io/kubernetes/pkg/controller/cronjob,soltysh,1
k8s.io/kubernetes/pkg/controller/service,asalkeld,0
k8s.io/kubernetes/pkg/controller/serviceaccount,liggitt,0
k8s.io/kubernetes/pkg/controller/volume/attachdetach,luxas,1
......@@ -674,8 +674,8 @@ k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler,bgrant0607,1
k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler/etcd,justinsb,1
k8s.io/kubernetes/pkg/registry/batch/job,kargakis,1
k8s.io/kubernetes/pkg/registry/batch/job/etcd,Q-Lee,1
k8s.io/kubernetes/pkg/registry/batch/scheduledjob,nikhiljindal,1
k8s.io/kubernetes/pkg/registry/batch/scheduledjob/etcd,mtaufen,1
k8s.io/kubernetes/pkg/registry/batch/cronjob,nikhiljindal,1
k8s.io/kubernetes/pkg/registry/batch/cronjob/etcd,mtaufen,1
k8s.io/kubernetes/pkg/registry/certificates/certificates,smarterclayton,1
k8s.io/kubernetes/pkg/registry/core/componentstatus,krousey,1
k8s.io/kubernetes/pkg/registry/core/configmap,janetkuo,1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment