Skip to content

Commit

Permalink
New Job resource
Browse files Browse the repository at this point in the history
  • Loading branch information
soltysh committed Sep 11, 2015
1 parent 90ba96d commit e55c59e
Show file tree
Hide file tree
Showing 15 changed files with 1,338 additions and 0 deletions.
120 changes: 120 additions & 0 deletions pkg/expapi/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,121 @@ func deepCopy_expapi_HorizontalPodAutoscalerStatus(in HorizontalPodAutoscalerSta
return nil
}

func deepCopy_expapi_Job(in Job, out *Job, c *conversion.Cloner) error {
if err := deepCopy_api_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := deepCopy_api_ObjectMeta(in.ObjectMeta, &out.ObjectMeta, c); err != nil {
return err
}
if err := deepCopy_expapi_JobSpec(in.Spec, &out.Spec, c); err != nil {
return err
}
if err := deepCopy_expapi_JobStatus(in.Status, &out.Status, c); err != nil {
return err
}
return nil
}

func deepCopy_expapi_JobCondition(in JobCondition, out *JobCondition, c *conversion.Cloner) error {
out.Type = in.Type
out.Status = in.Status
if err := deepCopy_util_Time(in.LastProbeTime, &out.LastProbeTime, c); err != nil {
return err
}
if err := deepCopy_util_Time(in.LastTransitionTime, &out.LastTransitionTime, c); err != nil {
return err
}
out.Reason = in.Reason
out.Message = in.Message
return nil
}

func deepCopy_expapi_JobList(in JobList, out *JobList, c *conversion.Cloner) error {
if err := deepCopy_api_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if err := deepCopy_api_ListMeta(in.ListMeta, &out.ListMeta, c); err != nil {
return err
}
if in.Items != nil {
out.Items = make([]Job, len(in.Items))
for i := range in.Items {
if err := deepCopy_expapi_Job(in.Items[i], &out.Items[i], c); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}

func deepCopy_expapi_JobSpec(in JobSpec, out *JobSpec, c *conversion.Cloner) error {
if in.Parallelism != nil {
out.Parallelism = new(int)
*out.Parallelism = *in.Parallelism
} else {
out.Parallelism = nil
}
if in.Completions != nil {
out.Completions = new(int)
*out.Completions = *in.Completions
} else {
out.Completions = nil
}
if in.Selector != nil {
out.Selector = make(map[string]string)
for key, val := range in.Selector {
out.Selector[key] = val
}
} else {
out.Selector = nil
}
if in.Template != nil {
out.Template = new(api.PodTemplateSpec)
if err := deepCopy_api_PodTemplateSpec(*in.Template, out.Template, c); err != nil {
return err
}
} else {
out.Template = nil
}
return nil
}

func deepCopy_expapi_JobStatus(in JobStatus, out *JobStatus, c *conversion.Cloner) error {
if in.Conditions != nil {
out.Conditions = make([]JobCondition, len(in.Conditions))
for i := range in.Conditions {
if err := deepCopy_expapi_JobCondition(in.Conditions[i], &out.Conditions[i], c); err != nil {
return err
}
}
} else {
out.Conditions = nil
}
if in.StartTime != nil {
out.StartTime = new(util.Time)
if err := deepCopy_util_Time(*in.StartTime, out.StartTime, c); err != nil {
return err
}
} else {
out.StartTime = nil
}
if in.CompletionTime != nil {
out.CompletionTime = new(util.Time)
if err := deepCopy_util_Time(*in.CompletionTime, out.CompletionTime, c); err != nil {
return err
}
} else {
out.CompletionTime = nil
}
out.Active = in.Active
out.Successful = in.Successful
out.Unsuccessful = in.Unsuccessful
return nil
}

func deepCopy_expapi_ReplicationControllerDummy(in ReplicationControllerDummy, out *ReplicationControllerDummy, c *conversion.Cloner) error {
if err := deepCopy_api_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
Expand Down Expand Up @@ -1206,6 +1321,11 @@ func init() {
deepCopy_expapi_HorizontalPodAutoscalerList,
deepCopy_expapi_HorizontalPodAutoscalerSpec,
deepCopy_expapi_HorizontalPodAutoscalerStatus,
deepCopy_expapi_Job,
deepCopy_expapi_JobCondition,
deepCopy_expapi_JobList,
deepCopy_expapi_JobSpec,
deepCopy_expapi_JobStatus,
deepCopy_expapi_ReplicationControllerDummy,
deepCopy_expapi_ResourceConsumption,
deepCopy_expapi_RollingUpdateDeployment,
Expand Down
4 changes: 4 additions & 0 deletions pkg/expapi/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func addKnownTypes() {
&DeploymentList{},
&HorizontalPodAutoscaler{},
&HorizontalPodAutoscalerList{},
&Job{},
&JobList{},
&ReplicationControllerDummy{},
&Scale{},
&ThirdPartyResource{},
Expand All @@ -47,6 +49,8 @@ func (*Deployment) IsAnAPIObject() {}
func (*DeploymentList) IsAnAPIObject() {}
func (*HorizontalPodAutoscaler) IsAnAPIObject() {}
func (*HorizontalPodAutoscalerList) IsAnAPIObject() {}
func (*Job) IsAnAPIObject() {}
func (*JobList) IsAnAPIObject() {}
func (*ReplicationControllerDummy) IsAnAPIObject() {}
func (*Scale) IsAnAPIObject() {}
func (*ThirdPartyResource) IsAnAPIObject() {}
Expand Down
99 changes: 99 additions & 0 deletions pkg/expapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,102 @@ type ThirdPartyResourceDataList struct {
// Items is a list of third party objects
Items []ThirdPartyResourceData `json:"items"`
}

// Job represents the configuration of a single job.
type Job struct {
api.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
api.ObjectMeta `json:"metadata,omitempty"`

// Spec is a structure defining the expected behavior of a job.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
Spec JobSpec `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
Status JobStatus `json:"status,omitempty"`
}

// JobList is a collection of jobs.
type JobList struct {
api.TypeMeta `json:",inline"`
// Standard list metadata
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
api.ListMeta `json:"metadata,omitempty"`

// Items is the list of Job.
Items []Job `json:"items"`
}

// JobSpec describes how the job execution will look like.
type JobSpec struct {

// Parallelism specifies the maximum desired number of pods the job should
// run at any given time. The actual number of pods running in steady state will
// be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism),
// i.e. when the work left to do is less than max parallelism.
Parallelism *int `json:"parallelism,omitempty"`

// Completions specifies the desired number of successfully finished pods the
// job should be run with. Defaults to 1.
Completions *int `json:"completions,omitempty"`

// Selector is a label query over pods that should match the pod count.
Selector map[string]string `json:"selector"`

// Template is the object that describes the pod that will be created when
// executing a job.
Template *api.PodTemplateSpec `json:"template"`
}

// JobStatus represents the current state of a Job.
type JobStatus struct {

// Conditions represent the latest available observations of an object's current state.
Conditions []JobCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`

// StartTime represents time when the job was acknowledged by the Job Manager.
// It is not guaranteed to be set in happens-before order across separate operations.
// It is represented in RFC3339 form and is in UTC.
StartTime *util.Time `json:"startTime,omitempty"`

// CompletionTime represents time when the job was completed. It is not guaranteed to
// be set in happens-before order across separate operations.
// It is represented in RFC3339 form and is in UTC.
CompletionTime *util.Time `json:"completionTime,omitempty"`

// Active is the number of actively running pods.
Active int `json:"active,omitempty"`

// Successful is the number of pods which reached Phase Succeeded.
Successful int `json:"successful,omitempty"`

// Unsuccessful is the number of pods failures, this applies only to jobs
// created with RestartPolicyNever, otherwise this value will always be 0.
Unsuccessful int `json:"unsuccessful,omitempty"`
}

type JobConditionType string

// These are valid conditions of a job.
const (
// JobComplete means the job has completed its execution.
JobComplete JobConditionType = "Complete"
)

// JobCondition describes current state of a job.
type JobCondition struct {
// Type of job condition, currently only Complete.
Type JobConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status api.ConditionStatus `json:"status"`
// Last time the condition was checked.
LastProbeTime util.Time `json:"lastProbeTime,omitempty"`
// Last time the condition transit from one status to another.
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
// (brief) reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
// Human readable message indicating details about last transition.
Message string `json:"message,omitempty"`
}
Loading

0 comments on commit e55c59e

Please sign in to comment.