Skip to content

Commit

Permalink
Merge pull request kubernetes#25475 from soltysh/scheduledjob_client
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

ScheduledJob client 

@erictune SheduledJob part 2, based on kubernetes#24970 so first two commits doesn't count. 
This is still WIP, but it's here so you know :)

```release-note
Introducing ScheduledJobs as described in [the proposal](https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/scheduledjob.md) as part of `batch/v2alpha1` version (experimental feature).
```
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
  • Loading branch information
k8s-merge-robot committed May 21, 2016
2 parents 5c08302 + 6510eb5 commit 4d69e2c
Show file tree
Hide file tree
Showing 32 changed files with 1,885 additions and 84 deletions.
4 changes: 4 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Godeps/LICENSES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions pkg/apis/batch/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ func addKnownTypes(scheme *runtime.Scheme) {
&Job{},
&JobList{},
&JobTemplate{},
&ScheduledJob{},
&ScheduledJobList{},
&api.ListOptions{},
)
}

func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *JobTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *JobTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *ScheduledJob) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *ScheduledJobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
2 changes: 2 additions & 0 deletions pkg/apis/batch/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ type JobCondition struct {
Message string `json:"message,omitempty"`
}

// +genclient=true

// ScheduledJob represents the configuration of a single scheduled job.
type ScheduledJob struct {
unversioned.TypeMeta `json:",inline"`
Expand Down
141 changes: 141 additions & 0 deletions pkg/apis/batch/v2alpha1/conversion_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ func init() {
Convert_unversioned_LabelSelector_To_v2alpha1_LabelSelector,
Convert_v2alpha1_LabelSelectorRequirement_To_unversioned_LabelSelectorRequirement,
Convert_unversioned_LabelSelectorRequirement_To_v2alpha1_LabelSelectorRequirement,
Convert_v2alpha1_ScheduledJob_To_batch_ScheduledJob,
Convert_batch_ScheduledJob_To_v2alpha1_ScheduledJob,
Convert_v2alpha1_ScheduledJobList_To_batch_ScheduledJobList,
Convert_batch_ScheduledJobList_To_v2alpha1_ScheduledJobList,
Convert_v2alpha1_ScheduledJobSpec_To_batch_ScheduledJobSpec,
Convert_batch_ScheduledJobSpec_To_v2alpha1_ScheduledJobSpec,
Convert_v2alpha1_ScheduledJobStatus_To_batch_ScheduledJobStatus,
Convert_batch_ScheduledJobStatus_To_v2alpha1_ScheduledJobStatus,
); err != nil {
Expand Down Expand Up @@ -509,6 +515,141 @@ func Convert_unversioned_LabelSelectorRequirement_To_v2alpha1_LabelSelectorRequi
return autoConvert_unversioned_LabelSelectorRequirement_To_v2alpha1_LabelSelectorRequirement(in, out, s)
}

func autoConvert_v2alpha1_ScheduledJob_To_batch_ScheduledJob(in *ScheduledJob, out *batch.ScheduledJob, s conversion.Scope) error {
SetDefaults_ScheduledJob(in)
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil {
return err
}
if err := Convert_v2alpha1_ScheduledJobSpec_To_batch_ScheduledJobSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := Convert_v2alpha1_ScheduledJobStatus_To_batch_ScheduledJobStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}

func Convert_v2alpha1_ScheduledJob_To_batch_ScheduledJob(in *ScheduledJob, out *batch.ScheduledJob, s conversion.Scope) error {
return autoConvert_v2alpha1_ScheduledJob_To_batch_ScheduledJob(in, out, s)
}

func autoConvert_batch_ScheduledJob_To_v2alpha1_ScheduledJob(in *batch.ScheduledJob, out *ScheduledJob, s conversion.Scope) error {
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil {
return err
}
if err := Convert_batch_ScheduledJobSpec_To_v2alpha1_ScheduledJobSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := Convert_batch_ScheduledJobStatus_To_v2alpha1_ScheduledJobStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}

func Convert_batch_ScheduledJob_To_v2alpha1_ScheduledJob(in *batch.ScheduledJob, out *ScheduledJob, s conversion.Scope) error {
return autoConvert_batch_ScheduledJob_To_v2alpha1_ScheduledJob(in, out, s)
}

func autoConvert_v2alpha1_ScheduledJobList_To_batch_ScheduledJobList(in *ScheduledJobList, out *batch.ScheduledJobList, s conversion.Scope) error {
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
if err := api.Convert_unversioned_ListMeta_To_unversioned_ListMeta(&in.ListMeta, &out.ListMeta, s); err != nil {
return err
}
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]batch.ScheduledJob, len(*in))
for i := range *in {
if err := Convert_v2alpha1_ScheduledJob_To_batch_ScheduledJob(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}

func Convert_v2alpha1_ScheduledJobList_To_batch_ScheduledJobList(in *ScheduledJobList, out *batch.ScheduledJobList, s conversion.Scope) error {
return autoConvert_v2alpha1_ScheduledJobList_To_batch_ScheduledJobList(in, out, s)
}

func autoConvert_batch_ScheduledJobList_To_v2alpha1_ScheduledJobList(in *batch.ScheduledJobList, out *ScheduledJobList, s conversion.Scope) error {
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
if err := api.Convert_unversioned_ListMeta_To_unversioned_ListMeta(&in.ListMeta, &out.ListMeta, s); err != nil {
return err
}
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ScheduledJob, len(*in))
for i := range *in {
if err := Convert_batch_ScheduledJob_To_v2alpha1_ScheduledJob(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}

func Convert_batch_ScheduledJobList_To_v2alpha1_ScheduledJobList(in *batch.ScheduledJobList, out *ScheduledJobList, s conversion.Scope) error {
return autoConvert_batch_ScheduledJobList_To_v2alpha1_ScheduledJobList(in, out, s)
}

func autoConvert_v2alpha1_ScheduledJobSpec_To_batch_ScheduledJobSpec(in *ScheduledJobSpec, out *batch.ScheduledJobSpec, s conversion.Scope) error {
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 = batch.ConcurrencyPolicy(in.ConcurrencyPolicy)
out.Suspend = in.Suspend
if err := Convert_v2alpha1_JobTemplateSpec_To_batch_JobTemplateSpec(&in.JobTemplate, &out.JobTemplate, s); err != nil {
return err
}
return nil
}

func Convert_v2alpha1_ScheduledJobSpec_To_batch_ScheduledJobSpec(in *ScheduledJobSpec, out *batch.ScheduledJobSpec, s conversion.Scope) error {
return autoConvert_v2alpha1_ScheduledJobSpec_To_batch_ScheduledJobSpec(in, out, s)
}

func autoConvert_batch_ScheduledJobSpec_To_v2alpha1_ScheduledJobSpec(in *batch.ScheduledJobSpec, out *ScheduledJobSpec, s conversion.Scope) error {
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 = ConcurrencyPolicy(in.ConcurrencyPolicy)
out.Suspend = in.Suspend
if err := Convert_batch_JobTemplateSpec_To_v2alpha1_JobTemplateSpec(&in.JobTemplate, &out.JobTemplate, s); err != nil {
return err
}
return nil
}

func Convert_batch_ScheduledJobSpec_To_v2alpha1_ScheduledJobSpec(in *batch.ScheduledJobSpec, out *ScheduledJobSpec, s conversion.Scope) error {
return autoConvert_batch_ScheduledJobSpec_To_v2alpha1_ScheduledJobSpec(in, out, s)
}

func autoConvert_v2alpha1_ScheduledJobStatus_To_batch_ScheduledJobStatus(in *ScheduledJobStatus, out *batch.ScheduledJobStatus, s conversion.Scope) error {
if in.Active != nil {
in, out := &in.Active, &out.Active
Expand Down
10 changes: 2 additions & 8 deletions pkg/apis/batch/v2alpha1/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,8 @@ func DeepCopy_v2alpha1_ScheduledJobSpec(in ScheduledJobSpec, out *ScheduledJobSp
}
out.ConcurrencyPolicy = in.ConcurrencyPolicy
out.Suspend = in.Suspend
if in.JobTemplate != nil {
in, out := in.JobTemplate, &out.JobTemplate
*out = new(JobTemplateSpec)
if err := DeepCopy_v2alpha1_JobTemplateSpec(*in, *out, c); err != nil {
return err
}
} else {
out.JobTemplate = nil
if err := DeepCopy_v2alpha1_JobTemplateSpec(in.JobTemplate, &out.JobTemplate, c); err != nil {
return err
}
return nil
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/batch/v2alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
func addDefaultingFuncs(scheme *runtime.Scheme) {
scheme.AddDefaultingFuncs(
SetDefaults_Job,
SetDefaults_ScheduledJob,
)
}

Expand All @@ -40,3 +41,9 @@ func SetDefaults_Job(obj *Job) {
*obj.Spec.Parallelism = 1
}
}

func SetDefaults_ScheduledJob(obj *ScheduledJob) {
if obj.Spec.ConcurrencyPolicy == "" {
obj.Spec.ConcurrencyPolicy = AllowConcurrent
}
}
25 changes: 9 additions & 16 deletions pkg/apis/batch/v2alpha1/generated.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions pkg/apis/batch/v2alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ func addKnownTypes(scheme *runtime.Scheme) {
&Job{},
&JobList{},
&JobTemplate{},
&ScheduledJob{},
&ScheduledJobList{},
&v1.ListOptions{},
)
versionedwatch.AddToGroupVersion(scheme, SchemeGroupVersion)
}

func (obj *JobTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *JobTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *ScheduledJob) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *ScheduledJobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
36 changes: 11 additions & 25 deletions pkg/apis/batch/v2alpha1/types.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -3597,20 +3597,14 @@ func (x *ScheduledJobSpec) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if x.JobTemplate == nil {
r.EncodeNil()
} else {
x.JobTemplate.CodecEncodeSelf(e)
}
yy18 := &x.JobTemplate
yy18.CodecEncodeSelf(e)
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("jobTemplate"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.JobTemplate == nil {
r.EncodeNil()
} else {
x.JobTemplate.CodecEncodeSelf(e)
}
yy20 := &x.JobTemplate
yy20.CodecEncodeSelf(e)
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
Expand Down Expand Up @@ -3709,14 +3703,10 @@ func (x *ScheduledJobSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
}
case "jobTemplate":
if r.TryDecodeAsNil() {
if x.JobTemplate != nil {
x.JobTemplate = nil
}
x.JobTemplate = JobTemplateSpec{}
} else {
if x.JobTemplate == nil {
x.JobTemplate = new(JobTemplateSpec)
}
x.JobTemplate.CodecDecodeSelf(d)
yyv9 := &x.JobTemplate
yyv9.CodecDecodeSelf(d)
}
default:
z.DecStructFieldNotFound(-1, yys3)
Expand Down Expand Up @@ -3818,14 +3808,10 @@ func (x *ScheduledJobSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.JobTemplate != nil {
x.JobTemplate = nil
}
x.JobTemplate = JobTemplateSpec{}
} else {
if x.JobTemplate == nil {
x.JobTemplate = new(JobTemplateSpec)
}
x.JobTemplate.CodecDecodeSelf(d)
yyv16 := &x.JobTemplate
yyv16.CodecDecodeSelf(d)
}
for {
yyj10++
Expand Down Expand Up @@ -4975,7 +4961,7 @@ func (x codecSelfer1234) decSliceScheduledJob(v *[]ScheduledJob, d *codec1978.De

yyrg1 := len(yyv1) > 0
yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 328)
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1024)
if yyrt1 {
if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1]
Expand Down
Loading

0 comments on commit 4d69e2c

Please sign in to comment.