-
Notifications
You must be signed in to change notification settings - Fork 53
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
KEP-672: Implement the DependsOn API #740
base: main
Are you sure you want to change the base?
Changes from 2 commits
370b4fe
39f712a
34c0593
22a408b
600f0a6
d751c13
725e7d9
bf743bb
c8e052c
d76b286
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -79,6 +79,8 @@ const ( | |||||
) | ||||||
|
||||||
// JobSetSpec defines the desired state of JobSet | ||||||
// +kubebuilder:validation:XValidation:rule="!(has(self.startupPolicy) && self.startupPolicy.startupPolicyOrder == 'InOrder' && self.replicatedJobs.all(x, has(x.dependsOn)))",message="StartupPolicy and DependsOn APIs are mutually exclusive" | ||||||
// +kubebuilder:validation:XValidation:rule="!(has(self.replicatedJobs[0].dependsOn))",message="DependsOn can't be set for the first ReplicatedJob" | ||||||
type JobSetSpec struct { | ||||||
// ReplicatedJobs is the group of jobs that will form the set. | ||||||
// +listType=map | ||||||
|
@@ -105,6 +107,7 @@ type JobSetSpec struct { | |||||
FailurePolicy *FailurePolicy `json:"failurePolicy,omitempty"` | ||||||
|
||||||
// StartupPolicy, if set, configures in what order jobs must be started | ||||||
// Deprecated: StartupPolicy is deprecated, please use the DependsOn API. | ||||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" | ||||||
StartupPolicy *StartupPolicy `json:"startupPolicy,omitempty"` | ||||||
|
||||||
|
@@ -230,8 +233,44 @@ type ReplicatedJob struct { | |||||
// Jobs names will be in the format: <jobSet.name>-<spec.replicatedJob.name>-<job-index> | ||||||
// +kubebuilder:default=1 | ||||||
Replicas int32 `json:"replicas,omitempty"` | ||||||
|
||||||
// DependsOn is an optional list that specifies the preceding ReplicatedJobs upon which | ||||||
// the current ReplicatedJob depends. If specified, the ReplicatedJob will be created | ||||||
// only after the referenced ReplicatedJobs reach their desired state. | ||||||
// The Order of ReplicatedJobs is defined by their enumeration in the slice. | ||||||
// Note, that the first ReplicatedJob in the slice cannot use the DependsOn API. | ||||||
// TODO (andreyvelich): Currently, only a single item is supported in the DependsOn list. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// This API is mutually exclusive with the StartupPolicy API. | ||||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable" | ||||||
// +kubebuilder:validation:MaxItems=1 | ||||||
// +optional | ||||||
// +listType=map | ||||||
// +listMapKey=name | ||||||
DependsOn []DependsOn `json:"dependsOn,omitempty"` | ||||||
} | ||||||
|
||||||
// DependsOn defines the dependency on the previous ReplicatedJob status. | ||||||
type DependsOn struct { | ||||||
// Name of the previous ReplicatedJob. | ||||||
Name string `json:"name"` | ||||||
|
||||||
// Status defines the condition for the ReplicatedJob. Only Ready or Complete status can be set. | ||||||
// +kubebuilder:validation:Enum=Ready;Complete | ||||||
Status DependsOnStatus `json:"status"` | ||||||
} | ||||||
|
||||||
type DependsOnStatus string | ||||||
|
||||||
const ( | ||||||
// Ready status means the Ready counter equals the number of child Jobs. | ||||||
// .spec.replicatedJobs["name==<JOB_NAME>"].replicas == .status.replicatedJobsStatus.name["name==<JOB_NAME>"].ready | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the boolean expression is necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why ? Should we modify this as follows:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||||||
ReadyStatus DependsOnStatus = "Ready" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should rename these status variables something like With the current naming, in the other places we're importing the api as |
||||||
|
||||||
// Complete status means the Succeeded counter equals the number of child Jobs. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is actually true. A ReplicatedJob can be mark as succeeded if the success policy passes which doesn't necessarly mean that all the replicated jobs finished. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can you give me an example of this use-case? From my understanding, ReplicatedJob completion is based on ReplicatedJob's SuccessPolicy: https://kubernetes.io/docs/concepts/workloads/controllers/job/#success-policy. SuccessPolicy on the JobSet level just sets whether we should mark JobSet as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see. You are correct. |
||||||
// .spec.replicatedJobs["name==<JOB_NAME>"].replicas == .status.replicatedJobsStatus.name["name==<JOB_NAME>"].succeeded | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the boolean expression is necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, you mean for user-facing docs. Sure, I think we can remove it. |
||||||
CompleteStatus DependsOnStatus = "Complete" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do we think about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want to match the Kubernetes Job and use Complete, so keep as is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea I think that is fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for consistency w/ Job API |
||||||
) | ||||||
|
||||||
type Network struct { | ||||||
// EnableDNSHostnames allows pods to be reached via their hostnames. | ||||||
// Pods will be reachable using the fully qualified pod hostname: | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have TODO in user facing APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will remove it.