Skip to content
Open
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
5 changes: 4 additions & 1 deletion api/v1alpha1/databackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ type DataBackupSpec struct {
BackupPath string `json:"backupPath,omitempty"`
// Manage the user to run Alluxio DataBackup
RunAs *User `json:"runAs,omitempty"`
// Specifies that the preceding operation in a workflow
// Specifies that the preceding operation in a workflow.
// The operation waits for the preceding operation only if runAfter is set when the operation is created.
// Removing runAfter while the operation is waiting ends the wait.
// Adding runAfter later does not make the operation wait.
// +optional
RunAfter *OperationRef `json:"runAfter,omitempty"`
// TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed
Expand Down
5 changes: 4 additions & 1 deletion api/v1alpha1/dataload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ type DataLoadSpec struct {
// +optional
Schedule string `json:"schedule,omitempty"`

// Specifies that the preceding operation in a workflow
// Specifies that the preceding operation in a workflow.
// The operation waits for the preceding operation only if runAfter is set when the operation is created.
// Removing runAfter while the operation is waiting ends the wait.
// Adding runAfter later does not make the operation wait.
// +optional
RunAfter *OperationRef `json:"runAfter,omitempty"`

Expand Down
5 changes: 4 additions & 1 deletion api/v1alpha1/datamigrate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ type DataMigrateSpec struct {
// SchedulerName sets the scheduler to be used for DataMigrate pod
SchedulerName string `json:"schedulerName,omitempty"`

// Specifies that the preceding operation in a workflow
// Specifies that the preceding operation in a workflow.
// The operation waits for the preceding operation only if runAfter is set when the operation is created.
// Removing runAfter while the operation is waiting ends the wait.
// Adding runAfter later does not make the operation wait.
// +optional
RunAfter *OperationRef `json:"runAfter,omitempty"`

Expand Down
5 changes: 4 additions & 1 deletion api/v1alpha1/dataprocess_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ type DataProcessSpec struct {
// +required
Processor Processor `json:"processor"`

// Specifies that the preceding operation in a workflow
// Specifies that the preceding operation in a workflow.
// The operation waits for the preceding operation only if runAfter is set when the operation is created.
// Removing runAfter while the operation is waiting ends the wait.
// Adding runAfter later does not make the operation wait.
// +optional
RunAfter *OperationRef `json:"runAfter,omitempty"`

Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/en/dev/api_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ _Appears in:_
| `dataset` _string_ | Dataset defines the target dataset of the DataBackup | | |
| `backupPath` _string_ | BackupPath defines the target path to save data of the DataBackup | | |
| `runAs` _[User](#user)_ | Manage the user to run Alluxio DataBackup | | |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |


Expand Down Expand Up @@ -564,7 +564,7 @@ _Appears in:_
| `schedulerName` _string_ | SchedulerName sets the scheduler to be used for DataLoad pod | | Optional: \{\} <br /> |
| `policy` _[Policy](#policy)_ | including Once, Cron, OnEvent | Once | Enum: [Once Cron OnEvent] <br />Optional: \{\} <br /> |
| `schedule` _string_ | The schedule in Cron format, only set when policy is cron, see https://en.wikipedia.org/wiki/Cron. | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |
| `resources` _[ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#resourcerequirements-v1-core)_ | Resources that will be requested by the DataLoad job. <br> | | Optional: \{\} <br /> |

Expand Down Expand Up @@ -615,7 +615,7 @@ _Appears in:_
| `tolerations` _[Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#toleration-v1-core) array_ | Tolerations defines tolerations for DataMigrate pod | | Optional: \{\} <br /> |
| `nodeSelector` _object (keys:string, values:string)_ | NodeSelector defiens node selector for DataMigrate pod | | Optional: \{\} <br /> |
| `schedulerName` _string_ | SchedulerName sets the scheduler to be used for DataMigrate pod | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |
| `resources` _[ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#resourcerequirements-v1-core)_ | Resources that will be requested by the DataMigrate job. <br> | | Optional: \{\} <br /> |
| `parallelism` _integer_ | Parallelism defines the parallelism tasks numbers for DataMigrate. If the value is greater than 1, the job acts<br />as a launcher, and users should define the WorkerSpec. | 1 | Minimum: 1 <br />Optional: \{\} <br /> |
Expand Down Expand Up @@ -674,7 +674,7 @@ _Appears in:_
| --- | --- | --- | --- |
| `dataset` _[TargetDatasetWithMountPath](#targetdatasetwithmountpath)_ | Dataset specifies the target dataset and its mount path. | | Required: \{\} <br /> |
| `processor` _[Processor](#processor)_ | Processor specify how to process data. | | Required: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |


Expand Down
8 changes: 4 additions & 4 deletions docs/zh/dev/api_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ _Appears in:_
| `dataset` _string_ | Dataset defines the target dataset of the DataBackup | | |
| `backupPath` _string_ | BackupPath defines the target path to save data of the DataBackup | | |
| `runAs` _[User](#user)_ | Manage the user to run Alluxio DataBackup | | |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |


Expand Down Expand Up @@ -564,7 +564,7 @@ _Appears in:_
| `schedulerName` _string_ | SchedulerName sets the scheduler to be used for DataLoad pod | | Optional: \{\} <br /> |
| `policy` _[Policy](#policy)_ | including Once, Cron, OnEvent | Once | Enum: [Once Cron OnEvent] <br />Optional: \{\} <br /> |
| `schedule` _string_ | The schedule in Cron format, only set when policy is cron, see https://en.wikipedia.org/wiki/Cron. | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |
| `resources` _[ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#resourcerequirements-v1-core)_ | Resources that will be requested by the DataLoad job. <br> | | Optional: \{\} <br /> |

Expand Down Expand Up @@ -615,7 +615,7 @@ _Appears in:_
| `tolerations` _[Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#toleration-v1-core) array_ | Tolerations defines tolerations for DataMigrate pod | | Optional: \{\} <br /> |
| `nodeSelector` _object (keys:string, values:string)_ | NodeSelector defiens node selector for DataMigrate pod | | Optional: \{\} <br /> |
| `schedulerName` _string_ | SchedulerName sets the scheduler to be used for DataMigrate pod | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |
| `resources` _[ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#resourcerequirements-v1-core)_ | Resources that will be requested by the DataMigrate job. <br> | | Optional: \{\} <br /> |
| `parallelism` _integer_ | Parallelism defines the parallelism tasks numbers for DataMigrate. If the value is greater than 1, the job acts<br />as a launcher, and users should define the WorkerSpec. | 1 | Minimum: 1 <br />Optional: \{\} <br /> |
Expand Down Expand Up @@ -674,7 +674,7 @@ _Appears in:_
| --- | --- | --- | --- |
| `dataset` _[TargetDatasetWithMountPath](#targetdatasetwithmountpath)_ | Dataset specifies the target dataset and its mount path. | | Required: \{\} <br /> |
| `processor` _[Processor](#processor)_ | Processor specify how to process data. | | Required: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow | | Optional: \{\} <br /> |
| `runAfter` _[OperationRef](#operationref)_ | Specifies that the preceding operation in a workflow.<br />The operation waits for the preceding operation only if runAfter is set when the operation is created.<br />Removing runAfter while the operation is waiting ends the wait.<br />Adding runAfter later does not make the operation wait. | | Optional: \{\} <br /> |
| `ttlSecondsAfterFinished` _integer_ | TTLSecondsAfterFinished is the time second to clean up data operations after finished or failed | | Optional: \{\} <br /> |


Expand Down
2 changes: 2 additions & 0 deletions pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ const (
DataOperationNotFound = "DataOperationNotFound"

DataOperationWaiting = "DataOperationWaiting"

DataOperationWaitingEnded = "DataOperationWaitingEnded"
)

// Events related to DataLoad
Expand Down
98 changes: 98 additions & 0 deletions pkg/controllers/v1alpha1/dataflow/dataflow_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,104 @@ var _ = Describe("DataFlowReconciler", func() {
Expect(err).NotTo(HaveOccurred())
Expect(result).To(Equal(ctrl.Result{}))
})

It("should not panic and should release a DataLoad whose RunAfter was removed while it was waiting", func() {
s := runtime.NewScheme()
_ = datav1alpha1.AddToScheme(s)

waitingLoad := &datav1alpha1.DataLoad{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"},
Status: datav1alpha1.OperationStatus{
Phase: common.PhasePending,
WaitingFor: datav1alpha1.WaitingStatus{
OperationComplete: ptr.To(true),
},
},
}

r := newTestDataFlowReconciler(s, waitingLoad)
req := ctrl.Request{
NamespacedName: types.NamespacedName{Name: "test", Namespace: "default"},
}

var (
result ctrl.Result
err error
)
Expect(func() { result, err = r.Reconcile(context.TODO(), req) }).NotTo(Panic())
Expect(err).NotTo(HaveOccurred())
Expect(result).To(Equal(ctrl.Result{}))

updated := &datav1alpha1.DataLoad{}
Expect(r.Get(context.TODO(), req.NamespacedName, updated)).To(Succeed())
Expect(updated.Status.WaitingFor.OperationComplete).To(HaveValue(BeFalse()))
})

// Reconcile runs every data operation kind for the request name, so a waiting DataLoad
// also makes it fetch a same-name DataBackup that has no runAfter and is not waiting.
It("should leave a same-name operation of another kind that is not waiting untouched", func() {
s := runtime.NewScheme()
_ = datav1alpha1.AddToScheme(s)

precedingLoad := &datav1alpha1.DataLoad{
ObjectMeta: metav1.ObjectMeta{Name: "preceding", Namespace: "default"},
Status: datav1alpha1.OperationStatus{
Phase: common.PhaseComplete,
},
}
waitingLoad := &datav1alpha1.DataLoad{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"},
Spec: datav1alpha1.DataLoadSpec{
RunAfter: &datav1alpha1.OperationRef{
ObjectRef: datav1alpha1.ObjectRef{
Kind: "DataLoad",
Name: "preceding",
},
},
},
Status: datav1alpha1.OperationStatus{
Phase: common.PhasePending,
WaitingFor: datav1alpha1.WaitingStatus{
OperationComplete: ptr.To(true),
},
},
}
completedBackup := &datav1alpha1.DataBackup{
ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"},
Status: datav1alpha1.OperationStatus{
Phase: common.PhaseComplete,
},
}

r := newTestDataFlowReconciler(s, precedingLoad, waitingLoad, completedBackup)
req := ctrl.Request{
NamespacedName: types.NamespacedName{Name: "test", Namespace: "default"},
}
backupBefore := &datav1alpha1.DataBackup{}
Expect(r.Get(context.TODO(), req.NamespacedName, backupBefore)).To(Succeed())

var (
result ctrl.Result
err error
)
Expect(func() { result, err = r.Reconcile(context.TODO(), req) }).NotTo(Panic())
Expect(err).NotTo(HaveOccurred())
Expect(result).To(Equal(ctrl.Result{}))

releasedLoad := &datav1alpha1.DataLoad{}
Expect(r.Get(context.TODO(), req.NamespacedName, releasedLoad)).To(Succeed())
Expect(releasedLoad.Status.WaitingFor.OperationComplete).To(HaveValue(BeFalse()))

backupAfter := &datav1alpha1.DataBackup{}
Expect(r.Get(context.TODO(), req.NamespacedName, backupAfter)).To(Succeed())
Expect(backupAfter.ResourceVersion).To(Equal(backupBefore.ResourceVersion))
Expect(backupAfter.Status).To(Equal(backupBefore.Status))

// Only the DataLoad stopped waiting.
events := r.Recorder.(*record.FakeRecorder).Events
Expect(events).To(Receive(ContainSubstring(common.DataOperationWaitingEnded)))
Expect(events).To(BeEmpty())
})
})
})

Expand Down
Loading
Loading