-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: implement OnEventStatusHandler.GetOperationStatus for DataLoad and DataMigrate #5945
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
base: master
Are you sure you want to change the base?
Changes from all commits
a9ede94
deb4765
86c0727
340d4d0
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 | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -75,7 +75,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| finishedJobCondition := kubeclient.GetFinishedJobCondition(job) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if finishedJobCondition == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ctx.Log.V(1).Info("DataLoad job still running", "namespace", ctx.Namespace, "jobName", jobName) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Check failure on line 78 in pkg/controllers/v1alpha1/dataload/status_handler.go
|
||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| isJobSucceed := finishedJobCondition.Type == batchv1.JobComplete | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -188,6 +188,54 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| func (o *OnEventStatusHandler) GetOperationStatus(ctx cruntime.ReconcileRequestContext, opStatus *datav1alpha1.OperationStatus) (result *datav1alpha1.OperationStatus, err error) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| //TODO implement me | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, nil | ||||||||||||||||||||||||||||||||||||||||||||||||
| result = opStatus.DeepCopy() | ||||||||||||||||||||||||||||||||||||||||||||||||
| releaseName := utils.GetDataLoadReleaseName(o.dataLoad.GetName()) | ||||||||||||||||||||||||||||||||||||||||||||||||
| jobName := utils.GetDataLoadJobName(releaseName) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| ctx.Log.V(1).Info("DataLoad chart already existed, check its running status") | ||||||||||||||||||||||||||||||||||||||||||||||||
| job, err := kubeclient.GetJob(o.Client, jobName, ctx.Namespace) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if utils.IgnoreNotFound(err) == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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. This job-missing branch (the
Author
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. The job-missing path is hard to cover in unit tests because DeleteReleaseIfExists shells out to the ddc-helm binary which isn't present in the test environment the same gap exists in OnceStatusHandler. I attempted to add a NotFound test but it fails with exec: "ddc-helm": executable file not found. Happy to add it if there's a recommended way to mock helm calls in this codebase, otherwise I'll leave it consistent with the existing OnceStatusHandler pattern. |
||||||||||||||||||||||||||||||||||||||||||||||||
| ctx.Log.Info("Related Job missing, will delete helm chart and retry", "namespace", ctx.Namespace, "jobName", jobName) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err = helm.DeleteReleaseIfExists(releaseName, ctx.Namespace); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ctx.Log.Error(err, "can't delete dataload release", "namespace", ctx.Namespace, "releaseName", releaseName) | ||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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. Good call adding the explicit |
||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| ctx.Log.Error(err, "can't get dataload job", "namespace", ctx.Namespace, "jobName", jobName) | ||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+197
to
+208
Contributor
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. There is a missing
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| finishedJobCondition := kubeclient.GetFinishedJobCondition(job) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if finishedJobCondition == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ctx.Log.V(1).Info("DataLoad job still running", "namespace", ctx.Namespace, "jobName", jobName) | ||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| isJobSucceed := finishedJobCondition.Type == batchv1.JobComplete | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if result.NodeAffinity == nil && isJobSucceed { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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. The success-path tests use jobs without the affinity-inject annotation, so |
||||||||||||||||||||||||||||||||||||||||||||||||
| result.NodeAffinity, err = dataflow.GenerateNodeAffinity(job) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, errors.Wrap(err, "error to generate the node labels") | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| result.Conditions = []datav1alpha1.Condition{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| Type: common.ConditionType(finishedJobCondition.Type), | ||||||||||||||||||||||||||||||||||||||||||||||||
| Status: finishedJobCondition.Status, | ||||||||||||||||||||||||||||||||||||||||||||||||
| Reason: finishedJobCondition.Reason, | ||||||||||||||||||||||||||||||||||||||||||||||||
| Message: finishedJobCondition.Message, | ||||||||||||||||||||||||||||||||||||||||||||||||
| LastProbeTime: finishedJobCondition.LastProbeTime, | ||||||||||||||||||||||||||||||||||||||||||||||||
| LastTransitionTime: finishedJobCondition.LastTransitionTime, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| if isJobSucceed { | ||||||||||||||||||||||||||||||||||||||||||||||||
| result.Phase = common.PhaseComplete | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| result.Phase = common.PhaseFailed | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| result.Duration = utils.CalculateDuration(job.CreationTimestamp.Time, finishedJobCondition.LastTransitionTime.Time) | ||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
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.
This is almost a line-for-line copy of OnceStatusHandler.GetOperationStatus above (lines 54-111), and the same duplication shows up in the datamigrate package. Could the shared body be pulled into a small helper (e.g. one that takes the client plus releaseName/jobName and returns the updated OperationStatus) so the two handlers do not drift over time? Not blocking, but it would make future status-handling fixes a single edit instead of four.
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.
Acknowledged . I'll keep this fix focused and open a separate issue + PR for the refactor to avoid expanding scope here. Happy to do it as a follow-up once this merges.