rename JobStatus.Unsuccessful => JobStatus.Failed, JobStatus.Successful => JobStatus.Succeeded
This commit is contained in:
@@ -1340,8 +1340,8 @@ func deepCopy_experimental_JobStatus(in JobStatus, out *JobStatus, c *conversion
|
|||||||
out.CompletionTime = nil
|
out.CompletionTime = nil
|
||||||
}
|
}
|
||||||
out.Active = in.Active
|
out.Active = in.Active
|
||||||
out.Successful = in.Successful
|
out.Succeeded = in.Succeeded
|
||||||
out.Unsuccessful = in.Unsuccessful
|
out.Failed = in.Failed
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -432,11 +432,11 @@ type JobStatus struct {
|
|||||||
// Active is the number of actively running pods.
|
// Active is the number of actively running pods.
|
||||||
Active int `json:"active,omitempty"`
|
Active int `json:"active,omitempty"`
|
||||||
|
|
||||||
// Successful is the number of pods which reached Phase Succeeded.
|
// Succeeded is the number of pods which reached Phase Succeeded.
|
||||||
Successful int `json:"successful,omitempty"`
|
Succeeded int `json:"succeeded,omitempty"`
|
||||||
|
|
||||||
// Unsuccessful is the number of pods which reached Phase Failed.
|
// Failed is the number of pods which reached Phase Failed.
|
||||||
Unsuccessful int `json:"unsuccessful,omitempty"`
|
Failed int `json:"failed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobConditionType string
|
type JobConditionType string
|
||||||
|
@@ -2836,8 +2836,8 @@ func autoconvert_experimental_JobStatus_To_v1alpha1_JobStatus(in *experimental.J
|
|||||||
out.CompletionTime = nil
|
out.CompletionTime = nil
|
||||||
}
|
}
|
||||||
out.Active = in.Active
|
out.Active = in.Active
|
||||||
out.Successful = in.Successful
|
out.Succeeded = in.Succeeded
|
||||||
out.Unsuccessful = in.Unsuccessful
|
out.Failed = in.Failed
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3758,8 +3758,8 @@ func autoconvert_v1alpha1_JobStatus_To_experimental_JobStatus(in *JobStatus, out
|
|||||||
out.CompletionTime = nil
|
out.CompletionTime = nil
|
||||||
}
|
}
|
||||||
out.Active = in.Active
|
out.Active = in.Active
|
||||||
out.Successful = in.Successful
|
out.Succeeded = in.Succeeded
|
||||||
out.Unsuccessful = in.Unsuccessful
|
out.Failed = in.Failed
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1352,8 +1352,8 @@ func deepCopy_v1alpha1_JobStatus(in JobStatus, out *JobStatus, c *conversion.Clo
|
|||||||
out.CompletionTime = nil
|
out.CompletionTime = nil
|
||||||
}
|
}
|
||||||
out.Active = in.Active
|
out.Active = in.Active
|
||||||
out.Successful = in.Successful
|
out.Succeeded = in.Succeeded
|
||||||
out.Unsuccessful = in.Unsuccessful
|
out.Failed = in.Failed
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -441,11 +441,11 @@ type JobStatus struct {
|
|||||||
// Active is the number of actively running pods.
|
// Active is the number of actively running pods.
|
||||||
Active int `json:"active,omitempty"`
|
Active int `json:"active,omitempty"`
|
||||||
|
|
||||||
// Successful is the number of pods which reached Phase Succeeded.
|
// Succeeded is the number of pods which reached Phase Succeeded.
|
||||||
Successful int `json:"successful,omitempty"`
|
Succeeded int `json:"succeeded,omitempty"`
|
||||||
|
|
||||||
// Unsuccessful is the number of pods which reached Phase Failed.
|
// Failed is the number of pods which reached Phase Failed.
|
||||||
Unsuccessful int `json:"unsuccessful,omitempty"`
|
Failed int `json:"failed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobConditionType string
|
type JobConditionType string
|
||||||
|
@@ -347,8 +347,8 @@ var map_JobStatus = map[string]string{
|
|||||||
"startTime": "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": "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.",
|
||||||
"completionTime": "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": "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.",
|
||||||
"active": "Active is the number of actively running pods.",
|
"active": "Active is the number of actively running pods.",
|
||||||
"successful": "Successful is the number of pods which reached Phase Succeeded.",
|
"succeeded": "Succeeded is the number of pods which reached Phase Succeeded.",
|
||||||
"unsuccessful": "Unsuccessful is the number of pods which reached Phase Failed.",
|
"failed": "Failed is the number of pods which reached Phase Failed.",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (JobStatus) SwaggerDoc() map[string]string {
|
func (JobStatus) SwaggerDoc() map[string]string {
|
||||||
|
@@ -345,8 +345,8 @@ func ValidateJobSpec(spec *experimental.JobSpec) errs.ValidationErrorList {
|
|||||||
func ValidateJobStatus(status *experimental.JobStatus) errs.ValidationErrorList {
|
func ValidateJobStatus(status *experimental.JobStatus) errs.ValidationErrorList {
|
||||||
allErrs := errs.ValidationErrorList{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Active), "active")...)
|
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Active), "active")...)
|
||||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Successful), "successful")...)
|
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Succeeded), "succeeded")...)
|
||||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Unsuccessful), "unsuccessful")...)
|
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Failed), "failed")...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,7 +58,7 @@ func JobHasDesiredParallelism(c Interface, job *experimental.Job) wait.Condition
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
// otherwise count successful
|
// otherwise count successful
|
||||||
progress := *job.Spec.Completions - job.Status.Active - job.Status.Successful
|
progress := *job.Spec.Completions - job.Status.Active - job.Status.Succeeded
|
||||||
return progress == 0, nil
|
return progress == 0, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -322,20 +322,20 @@ func (jm *JobController) syncJob(key string) error {
|
|||||||
|
|
||||||
activePods := controller.FilterActivePods(podList.Items)
|
activePods := controller.FilterActivePods(podList.Items)
|
||||||
active := len(activePods)
|
active := len(activePods)
|
||||||
successful, unsuccessful := getStatus(podList.Items)
|
succeeded, failed := getStatus(podList.Items)
|
||||||
if jobNeedsSync {
|
if jobNeedsSync {
|
||||||
active = jm.manageJob(activePods, successful, unsuccessful, &job)
|
active = jm.manageJob(activePods, succeeded, &job)
|
||||||
}
|
}
|
||||||
completions := successful
|
completions := succeeded
|
||||||
if completions == *job.Spec.Completions {
|
if completions == *job.Spec.Completions {
|
||||||
job.Status.Conditions = append(job.Status.Conditions, newCondition())
|
job.Status.Conditions = append(job.Status.Conditions, newCondition())
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to update the job if the status hasn't changed since last time
|
// no need to update the job if the status hasn't changed since last time
|
||||||
if job.Status.Active != active || job.Status.Successful != successful || job.Status.Unsuccessful != unsuccessful {
|
if job.Status.Active != active || job.Status.Succeeded != succeeded || job.Status.Failed != failed {
|
||||||
job.Status.Active = active
|
job.Status.Active = active
|
||||||
job.Status.Successful = successful
|
job.Status.Succeeded = succeeded
|
||||||
job.Status.Unsuccessful = unsuccessful
|
job.Status.Failed = failed
|
||||||
|
|
||||||
if err := jm.updateHandler(&job); err != nil {
|
if err := jm.updateHandler(&job); err != nil {
|
||||||
glog.Errorf("Failed to update job %v, requeuing. Error: %v", job.Name, err)
|
glog.Errorf("Failed to update job %v, requeuing. Error: %v", job.Name, err)
|
||||||
@@ -354,13 +354,13 @@ func newCondition() experimental.JobCondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStatus(pods []api.Pod) (successful, unsuccessful int) {
|
func getStatus(pods []api.Pod) (succeeded, failed int) {
|
||||||
successful = filterPods(pods, api.PodSucceeded)
|
succeeded = filterPods(pods, api.PodSucceeded)
|
||||||
unsuccessful = filterPods(pods, api.PodFailed)
|
failed = filterPods(pods, api.PodFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (jm *JobController) manageJob(activePods []*api.Pod, successful, unsuccessful int, job *experimental.Job) int {
|
func (jm *JobController) manageJob(activePods []*api.Pod, succeeded int, job *experimental.Job) int {
|
||||||
var activeLock sync.Mutex
|
var activeLock sync.Mutex
|
||||||
active := len(activePods)
|
active := len(activePods)
|
||||||
parallelism := *job.Spec.Parallelism
|
parallelism := *job.Spec.Parallelism
|
||||||
@@ -399,7 +399,7 @@ func (jm *JobController) manageJob(activePods []*api.Pod, successful, unsuccessf
|
|||||||
|
|
||||||
} else if active < parallelism {
|
} else if active < parallelism {
|
||||||
// how many executions are left to run
|
// how many executions are left to run
|
||||||
diff := *job.Spec.Completions - successful
|
diff := *job.Spec.Completions - succeeded
|
||||||
// limit to parallelism and count active pods as well
|
// limit to parallelism and count active pods as well
|
||||||
if diff > parallelism {
|
if diff > parallelism {
|
||||||
diff = parallelism
|
diff = parallelism
|
||||||
|
@@ -95,16 +95,16 @@ func TestControllerSyncJob(t *testing.T) {
|
|||||||
// pod setup
|
// pod setup
|
||||||
podControllerError error
|
podControllerError error
|
||||||
activePods int
|
activePods int
|
||||||
successfulPods int
|
succeededPods int
|
||||||
unsuccessfulPods int
|
failedPods int
|
||||||
|
|
||||||
// expectations
|
// expectations
|
||||||
expectedCreations int
|
expectedCreations int
|
||||||
expectedDeletions int
|
expectedDeletions int
|
||||||
expectedActive int
|
expectedActive int
|
||||||
expectedSuccessful int
|
expectedSucceeded int
|
||||||
expectedUnsuccessful int
|
expectedFailed int
|
||||||
expectedComplete bool
|
expectedComplete bool
|
||||||
}{
|
}{
|
||||||
"job start": {
|
"job start": {
|
||||||
2, 5,
|
2, 5,
|
||||||
@@ -177,10 +177,10 @@ func TestControllerSyncJob(t *testing.T) {
|
|||||||
for _, pod := range newPodList(tc.activePods, api.PodRunning, job) {
|
for _, pod := range newPodList(tc.activePods, api.PodRunning, job) {
|
||||||
manager.podStore.Store.Add(&pod)
|
manager.podStore.Store.Add(&pod)
|
||||||
}
|
}
|
||||||
for _, pod := range newPodList(tc.successfulPods, api.PodSucceeded, job) {
|
for _, pod := range newPodList(tc.succeededPods, api.PodSucceeded, job) {
|
||||||
manager.podStore.Store.Add(&pod)
|
manager.podStore.Store.Add(&pod)
|
||||||
}
|
}
|
||||||
for _, pod := range newPodList(tc.unsuccessfulPods, api.PodFailed, job) {
|
for _, pod := range newPodList(tc.failedPods, api.PodFailed, job) {
|
||||||
manager.podStore.Store.Add(&pod)
|
manager.podStore.Store.Add(&pod)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,11 +201,11 @@ func TestControllerSyncJob(t *testing.T) {
|
|||||||
if actual.Status.Active != tc.expectedActive {
|
if actual.Status.Active != tc.expectedActive {
|
||||||
t.Errorf("%s: unexpected number of active pods. Expected %d, saw %d\n", name, tc.expectedActive, actual.Status.Active)
|
t.Errorf("%s: unexpected number of active pods. Expected %d, saw %d\n", name, tc.expectedActive, actual.Status.Active)
|
||||||
}
|
}
|
||||||
if actual.Status.Successful != tc.expectedSuccessful {
|
if actual.Status.Succeeded != tc.expectedSucceeded {
|
||||||
t.Errorf("%s: unexpected number of successful pods. Expected %d, saw %d\n", name, tc.expectedSuccessful, actual.Status.Successful)
|
t.Errorf("%s: unexpected number of succeeded pods. Expected %d, saw %d\n", name, tc.expectedSucceeded, actual.Status.Succeeded)
|
||||||
}
|
}
|
||||||
if actual.Status.Unsuccessful != tc.expectedUnsuccessful {
|
if actual.Status.Failed != tc.expectedFailed {
|
||||||
t.Errorf("%s: unexpected number of unsuccessful pods. Expected %d, saw %d\n", name, tc.expectedUnsuccessful, actual.Status.Unsuccessful)
|
t.Errorf("%s: unexpected number of failed pods. Expected %d, saw %d\n", name, tc.expectedFailed, actual.Status.Failed)
|
||||||
}
|
}
|
||||||
// validate conditions
|
// validate conditions
|
||||||
if tc.expectedComplete {
|
if tc.expectedComplete {
|
||||||
|
@@ -893,7 +893,7 @@ func describeJob(job *experimental.Job, events *api.EventList) (string, error) {
|
|||||||
fmt.Fprintf(out, "Parallelism:\t%d\n", *job.Spec.Parallelism)
|
fmt.Fprintf(out, "Parallelism:\t%d\n", *job.Spec.Parallelism)
|
||||||
fmt.Fprintf(out, "Completions:\t%d\n", *job.Spec.Completions)
|
fmt.Fprintf(out, "Completions:\t%d\n", *job.Spec.Completions)
|
||||||
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(job.Labels))
|
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(job.Labels))
|
||||||
fmt.Fprintf(out, "Pods Statuses:\t%d Running / %d Succeeded / %d Failed\n", job.Status.Active, job.Status.Successful, job.Status.Unsuccessful)
|
fmt.Fprintf(out, "Pods Statuses:\t%d Running / %d Succeeded / %d Failed\n", job.Status.Active, job.Status.Succeeded, job.Status.Failed)
|
||||||
if job.Spec.Template != nil {
|
if job.Spec.Template != nil {
|
||||||
describeVolumes(job.Spec.Template.Spec.Volumes, out)
|
describeVolumes(job.Spec.Template.Spec.Volumes, out)
|
||||||
}
|
}
|
||||||
|
@@ -741,7 +741,7 @@ func printJob(job *experimental.Job, w io.Writer, withNamespace bool, wide bool,
|
|||||||
firstContainer.Name,
|
firstContainer.Name,
|
||||||
firstContainer.Image,
|
firstContainer.Image,
|
||||||
labels.FormatLabels(job.Spec.Selector),
|
labels.FormatLabels(job.Spec.Selector),
|
||||||
job.Status.Successful)
|
job.Status.Succeeded)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -99,7 +99,7 @@ func (jobStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object
|
|||||||
func JobToSelectableFields(job *experimental.Job) fields.Set {
|
func JobToSelectableFields(job *experimental.Job) fields.Set {
|
||||||
return fields.Set{
|
return fields.Set{
|
||||||
"metadata.name": job.Name,
|
"metadata.name": job.Name,
|
||||||
"status.successful": strconv.Itoa(job.Status.Successful),
|
"status.successful": strconv.Itoa(job.Status.Succeeded),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ var _ = Describe("Job", func() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return curr.Status.Unsuccessful > lotsOfFailures, nil
|
return curr.Status.Failed > lotsOfFailures, nil
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -256,6 +256,6 @@ func waitForJobFinish(c *client.Client, ns, jobName string, completions int) err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return curr.Status.Successful == completions, nil
|
return curr.Status.Succeeded == completions, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user