Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename JobStatus.Unsuccessful => JobStatus.Failed #15240

Merged
merged 1 commit into from
Oct 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/apis/experimental/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,8 @@ func deepCopy_experimental_JobStatus(in JobStatus, out *JobStatus, c *conversion
out.CompletionTime = nil
}
out.Active = in.Active
out.Successful = in.Successful
out.Unsuccessful = in.Unsuccessful
out.Succeeded = in.Succeeded
out.Failed = in.Failed
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/experimental/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ type JobStatus struct {
// 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"`
// Succeeded is the number of pods which reached Phase Succeeded.
Succeeded int `json:"succeeded,omitempty"`

// Unsuccessful is the number of pods which reached Phase Failed.
Unsuccessful int `json:"unsuccessful,omitempty"`
// Failed is the number of pods which reached Phase Failed.
Failed int `json:"failed,omitempty"`
}

type JobConditionType string
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/experimental/v1alpha1/conversion_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -2836,8 +2836,8 @@ func autoconvert_experimental_JobStatus_To_v1alpha1_JobStatus(in *experimental.J
out.CompletionTime = nil
}
out.Active = in.Active
out.Successful = in.Successful
out.Unsuccessful = in.Unsuccessful
out.Succeeded = in.Succeeded
out.Failed = in.Failed
return nil
}

Expand Down Expand Up @@ -3758,8 +3758,8 @@ func autoconvert_v1alpha1_JobStatus_To_experimental_JobStatus(in *JobStatus, out
out.CompletionTime = nil
}
out.Active = in.Active
out.Successful = in.Successful
out.Unsuccessful = in.Unsuccessful
out.Succeeded = in.Succeeded
out.Failed = in.Failed
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/experimental/v1alpha1/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,8 @@ func deepCopy_v1alpha1_JobStatus(in JobStatus, out *JobStatus, c *conversion.Clo
out.CompletionTime = nil
}
out.Active = in.Active
out.Successful = in.Successful
out.Unsuccessful = in.Unsuccessful
out.Succeeded = in.Succeeded
out.Failed = in.Failed
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/experimental/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,11 @@ type JobStatus struct {
// 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"`
// Succeeded is the number of pods which reached Phase Succeeded.
Succeeded int `json:"succeeded,omitempty"`

// Unsuccessful is the number of pods which reached Phase Failed.
Unsuccessful int `json:"unsuccessful,omitempty"`
// Failed is the number of pods which reached Phase Failed.
Failed int `json:"failed,omitempty"`
}

type JobConditionType string
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/experimental/v1alpha1/types_swagger_doc_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
"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.",
"successful": "Successful is the number of pods which reached Phase Succeeded.",
"unsuccessful": "Unsuccessful is the number of pods which reached Phase Failed.",
"succeeded": "Succeeded is the number of pods which reached Phase Succeeded.",
"failed": "Failed is the number of pods which reached Phase Failed.",
}

func (JobStatus) SwaggerDoc() map[string]string {
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/experimental/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ func ValidateJobSpec(spec *experimental.JobSpec) errs.ValidationErrorList {
func ValidateJobStatus(status *experimental.JobStatus) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
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.Unsuccessful), "unsuccessful")...)
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Succeeded), "succeeded")...)
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Failed), "failed")...)
return allErrs
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/unversioned/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func JobHasDesiredParallelism(c Interface, job *experimental.Job) wait.Condition
return true, nil
}
// 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
}
}
22 changes: 11 additions & 11 deletions pkg/controller/job/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,20 @@ func (jm *JobController) syncJob(key string) error {

activePods := controller.FilterActivePods(podList.Items)
active := len(activePods)
successful, unsuccessful := getStatus(podList.Items)
succeeded, failed := getStatus(podList.Items)
if jobNeedsSync {
active = jm.manageJob(activePods, successful, unsuccessful, &job)
active = jm.manageJob(activePods, succeeded, &job)
}
completions := successful
completions := succeeded
if completions == *job.Spec.Completions {
job.Status.Conditions = append(job.Status.Conditions, newCondition())
}

// 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.Successful = successful
job.Status.Unsuccessful = unsuccessful
job.Status.Succeeded = succeeded
job.Status.Failed = failed

if err := jm.updateHandler(&job); err != nil {
glog.Errorf("Failed to update job %v, requeuing. Error: %v", job.Name, err)
Expand All @@ -354,13 +354,13 @@ func newCondition() experimental.JobCondition {
}
}

func getStatus(pods []api.Pod) (successful, unsuccessful int) {
successful = filterPods(pods, api.PodSucceeded)
unsuccessful = filterPods(pods, api.PodFailed)
func getStatus(pods []api.Pod) (succeeded, failed int) {
succeeded = filterPods(pods, api.PodSucceeded)
failed = filterPods(pods, api.PodFailed)
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
active := len(activePods)
parallelism := *job.Spec.Parallelism
Expand Down Expand Up @@ -399,7 +399,7 @@ func (jm *JobController) manageJob(activePods []*api.Pod, successful, unsuccessf

} else if active < parallelism {
// 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
if diff > parallelism {
diff = parallelism
Expand Down
28 changes: 14 additions & 14 deletions pkg/controller/job/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ func TestControllerSyncJob(t *testing.T) {
// pod setup
podControllerError error
activePods int
successfulPods int
unsuccessfulPods int
succeededPods int
failedPods int

// expectations
expectedCreations int
expectedDeletions int
expectedActive int
expectedSuccessful int
expectedUnsuccessful int
expectedComplete bool
expectedCreations int
expectedDeletions int
expectedActive int
expectedSucceeded int
expectedFailed int
expectedComplete bool
}{
"job start": {
2, 5,
Expand Down Expand Up @@ -177,10 +177,10 @@ func TestControllerSyncJob(t *testing.T) {
for _, pod := range newPodList(tc.activePods, api.PodRunning, job) {
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)
}
for _, pod := range newPodList(tc.unsuccessfulPods, api.PodFailed, job) {
for _, pod := range newPodList(tc.failedPods, api.PodFailed, job) {
manager.podStore.Store.Add(&pod)
}

Expand All @@ -201,11 +201,11 @@ func TestControllerSyncJob(t *testing.T) {
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)
}
if actual.Status.Successful != tc.expectedSuccessful {
t.Errorf("%s: unexpected number of successful pods. Expected %d, saw %d\n", name, tc.expectedSuccessful, actual.Status.Successful)
if actual.Status.Succeeded != tc.expectedSucceeded {
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 {
t.Errorf("%s: unexpected number of unsuccessful pods. Expected %d, saw %d\n", name, tc.expectedUnsuccessful, actual.Status.Unsuccessful)
if actual.Status.Failed != tc.expectedFailed {
t.Errorf("%s: unexpected number of failed pods. Expected %d, saw %d\n", name, tc.expectedFailed, actual.Status.Failed)
}
// validate conditions
if tc.expectedComplete {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "Completions:\t%d\n", *job.Spec.Completions)
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 {
describeVolumes(job.Spec.Template.Spec.Volumes, out)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/resource_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ func printJob(job *experimental.Job, w io.Writer, withNamespace bool, wide bool,
firstContainer.Name,
firstContainer.Image,
labels.FormatLabels(job.Spec.Selector),
job.Status.Successful)
job.Status.Succeeded)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/job/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (jobStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object
func JobToSelectableFields(job *experimental.Job) fields.Set {
return fields.Set{
"metadata.name": job.Name,
"status.successful": strconv.Itoa(job.Status.Successful),
"status.successful": strconv.Itoa(job.Status.Succeeded),
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var _ = Describe("Job", func() {
if err != nil {
return false, err
}
return curr.Status.Unsuccessful > lotsOfFailures, nil
return curr.Status.Failed > lotsOfFailures, nil
})
})

Expand Down Expand Up @@ -256,6 +256,6 @@ func waitForJobFinish(c *client.Client, ns, jobName string, completions int) err
if err != nil {
return false, err
}
return curr.Status.Successful == completions, nil
return curr.Status.Succeeded == completions, nil
})
}