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

Use local copy of JobStatus by mpi-operator #514

Merged
merged 2 commits into from
Feb 3, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions crd/kubeflow.org_mpijobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7898,7 +7898,7 @@ spec:
format: date-time
type: string
conditions:
description: Conditions is an array of current observed job conditions.
description: conditions is a list of current observed job conditions.
items:
description: JobCondition describes the state of the job at a certain
point.
Expand All @@ -7913,23 +7913,30 @@ spec:
format: date-time
type: string
message:
description: A human readable message indicating details about
description: A human-readable message indicating details about
the transition.
type: string
reason:
description: The reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: Type of job condition.
description: type of job condition.
type: string
required:
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
lastReconcileTime:
description: Represents last time when the job was reconciled. It
is not guaranteed to be set in happens-before order across separate
Expand All @@ -7946,11 +7953,11 @@ spec:
format: int32
type: integer
failed:
description: The number of pods which reached phase Failed.
description: The number of pods which reached phase failed.
format: int32
type: integer
labelSelector:
description: 'Deprecated: Use Selector instead'
description: 'Deprecated: Use selector instead'
properties:
matchExpressions:
description: matchExpressions is a list of label selector
Expand Down Expand Up @@ -7995,17 +8002,17 @@ spec:
type: object
x-kubernetes-map-type: atomic
selector:
description: A Selector is a label query over a set of resources.
description: A selector is a label query over a set of resources.
The result of matchLabels and matchExpressions are ANDed.
An empty Selector matches all objects. A null Selector matches
An empty selector matches all objects. A null selector matches
no objects.
type: string
succeeded:
description: The number of pods which reached phase Succeeded.
description: The number of pods which reached phase succeeded.
format: int32
type: integer
type: object
description: ReplicaStatuses is map of ReplicaType and ReplicaStatus,
description: replicaStatuses is map of ReplicaType and ReplicaStatus,
specifies the status of each replica.
type: object
startTime:
Expand All @@ -8015,9 +8022,6 @@ spec:
and is in UTC.
format: date-time
type: string
required:
- conditions
- replicaStatuses
type: object
type: object
served: true
Expand Down
106 changes: 105 additions & 1 deletion pkg/apis/kubeflow/v2beta1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,81 @@
}
}
},
"v2beta1.JobCondition": {
"description": "JobCondition describes the state of the job at a certain point.",
"type": "object",
"required": [
"type",
"status"
],
"properties": {
"lastTransitionTime": {
"description": "Last time the condition transitioned from one status to another.",
"default": {},
"$ref": "#/definitions/v1.Time"
},
"lastUpdateTime": {
"description": "The last time this condition was updated.",
"default": {},
"$ref": "#/definitions/v1.Time"
},
"message": {
"description": "A human-readable message indicating details about the transition.",
"type": "string"
},
"reason": {
"description": "The reason for the condition's last transition.",
"type": "string"
},
"status": {
"description": "status of the condition, one of True, False, Unknown.",
"type": "string",
"default": ""
},
"type": {
"description": "type of job condition.",
"type": "string",
"default": ""
}
}
},
"v2beta1.JobStatus": {
"description": "JobStatus represents the current observed state of the training Job.",
"type": "object",
"properties": {
"completionTime": {
"description": "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.",
"$ref": "#/definitions/v1.Time"
},
"conditions": {
"description": "conditions is a list of current observed job conditions.",
"type": "array",
"items": {
"default": {},
"$ref": "#/definitions/v2beta1.JobCondition"
},
"x-kubernetes-list-map-keys": [
"type"
],
"x-kubernetes-list-type": "map"
},
"lastReconcileTime": {
"description": "Represents last time when the job was reconciled. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC.",
"$ref": "#/definitions/v1.Time"
},
"replicaStatuses": {
"description": "replicaStatuses is map of ReplicaType and ReplicaStatus, specifies the status of each replica.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/v2beta1.ReplicaStatus"
}
},
"startTime": {
"description": "Represents time when the job was acknowledged by the job controller. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC.",
"$ref": "#/definitions/v1.Time"
}
}
},
"v2beta1.MPIJob": {
"type": "object",
"properties": {
Expand All @@ -208,7 +283,7 @@
},
"status": {
"default": {},
"$ref": "#/definitions/v1.JobStatus"
"$ref": "#/definitions/v2beta1.JobStatus"
}
}
},
Expand Down Expand Up @@ -273,6 +348,35 @@
}
}
},
"v2beta1.ReplicaStatus": {
"description": "ReplicaStatus represents the current observed state of the replica.",
"type": "object",
"properties": {
"active": {
"description": "The number of actively running pods.",
"type": "integer",
"format": "int32"
},
"failed": {
"description": "The number of pods which reached phase failed.",
"type": "integer",
"format": "int32"
},
"labelSelector": {
"description": "Deprecated: Use selector instead",
"$ref": "#/definitions/v1.LabelSelector"
},
"selector": {
"description": "A selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty selector matches all objects. A null selector matches no objects.",
"type": "string"
},
"succeeded": {
"description": "The number of pods which reached phase succeeded.",
"type": "integer",
"format": "int32"
}
}
},
"v2beta1.RunPolicy": {
"description": "RunPolicy encapsulates various runtime policies of the distributed training job, for example how to clean up resources and how long the job can stay active.",
"type": "object",
Expand Down
120 changes: 117 additions & 3 deletions pkg/apis/kubeflow/v2beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
type MPIJob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec MPIJobSpec `json:"spec,omitempty"`
Status common.JobStatus `json:"status,omitempty"`
Spec MPIJobSpec `json:"spec,omitempty"`
Status JobStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -114,7 +114,7 @@ type MPIJobSpec struct {
}

// MPIReplicaType is the type for MPIReplica.
type MPIReplicaType common.ReplicaType
type MPIReplicaType string

const (
// MPIReplicaTypeLauncher is the type for launcher replica.
Expand All @@ -130,3 +130,117 @@ const (
MPIImplementationOpenMPI MPIImplementation = "OpenMPI"
MPIImplementationIntel MPIImplementation = "Intel"
)

// JobStatus represents the current observed state of the training Job.
type JobStatus struct {
// conditions is a list of current observed job conditions.
// +optional
// +listType=map
// +listMapKey=type
Conditions []JobCondition `json:"conditions,omitempty"`

// replicaStatuses is map of ReplicaType and ReplicaStatus,
// specifies the status of each replica.
// +optional
ReplicaStatuses map[MPIReplicaType]*ReplicaStatus `json:"replicaStatuses,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another violation of API conventions T_T
But we can only change it in a new API version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right :(
For v2beta1, we need to keep using this API for compatibility.


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

// 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.
// +optional
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// Represents last time when the job was reconciled. It is not guaranteed to
// be set in happens-before order across separate operations.
// It is represented in RFC3339 form and is in UTC.
// +optional
LastReconcileTime *metav1.Time `json:"lastReconcileTime,omitempty"`
}

// ReplicaStatus represents the current observed state of the replica.
type ReplicaStatus struct {
// The number of actively running pods.
// +optional
Active int32 `json:"active,omitempty"`

// The number of pods which reached phase succeeded.
// +optional
Succeeded int32 `json:"succeeded,omitempty"`

// The number of pods which reached phase failed.
// +optional
Failed int32 `json:"failed,omitempty"`

// Deprecated: Use selector instead
// +optional
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`

// A selector is a label query over a set of resources. The result of matchLabels and
// matchExpressions are ANDed. An empty selector matches all objects. A null
// selector matches no objects.
// +optional
Selector string `json:"selector,omitempty"`
}

// JobCondition describes the state of the job at a certain point.
type JobCondition struct {
// type of job condition.
Type JobConditionType `json:"type"`

// status of the condition, one of True, False, Unknown.
// +kubebuilder:validation:Enum:=True;False;Unknown
Status v1.ConditionStatus `json:"status"`

// The reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty"`

// A human-readable message indicating details about the transition.
// +optional
Message string `json:"message,omitempty"`

// The last time this condition was updated.
// +optional
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`

// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
}

// JobConditionType defines all kinds of types of JobStatus.
type JobConditionType string

const (
// JobCreated means the job has been accepted by the system,
// but one or more of the pods/services has not been started.
// This includes time before pods being scheduled and launched.
JobCreated JobConditionType = "Created"

// JobRunning means all sub-resources (e.g. services/pods) of this job
// have been successfully scheduled and launched.
// The training is running without error.
JobRunning JobConditionType = "Running"

// JobRestarting means one or more sub-resources (e.g. services/pods) of this job
// reached phase failed but maybe restarted according to it's restart policy
// which specified by user in v1.PodTemplateSpec.
// The training is freezing/pending.
JobRestarting JobConditionType = "Restarting"

// JobSucceeded means all sub-resources (e.g. services/pods) of this job
// reached phase have terminated in success.
// The training is complete without error.
JobSucceeded JobConditionType = "Succeeded"

// JobFailed means one or more sub-resources (e.g. services/pods) of this job
// reached phase failed with no restarting.
// The training has failed its execution.
JobFailed JobConditionType = "Failed"
)
Loading