-
Notifications
You must be signed in to change notification settings - Fork 267
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
Improve DataVolume status reporting with populators #2928
Changes from all commits
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 |
---|---|---|
|
@@ -244,21 +244,36 @@ func (r *ImportPopulatorReconciler) updateImportProgress(podPhase string, pvc, p | |
cc.AddAnnotation(pvc, cc.AnnPopulatorProgress, "100.0%") | ||
return nil | ||
} | ||
importPod, err := r.getImportPod(pvcPrime) | ||
|
||
importPodName, ok := pvcPrime.Annotations[cc.AnnImportPod] | ||
if !ok { | ||
return nil | ||
} | ||
|
||
importPod, err := r.getImportPod(pvcPrime, importPodName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if importPod == nil { | ||
_, ok := pvc.Annotations[cc.AnnPopulatorProgress] | ||
// Initialize the progress once PVC Prime is bound | ||
if !ok && pvcPrime.Status.Phase == corev1.ClaimBound { | ||
cc.AddAnnotation(pvc, cc.AnnPopulatorProgress, "N/A") | ||
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 is a nasty patch to force a reconcile in the DV controller when the PVC' gets bound disguised as an annotation to initialize progress. It should fix the error in the tests, and it matches the behavior in the DV controller. After spending hours on this I think this is the best-looking solution. |
||
} | ||
return nil | ||
} | ||
|
||
// This will only work when the import pod is running | ||
if importPod != nil && importPod.Status.Phase != corev1.PodRunning { | ||
if importPod.Status.Phase != corev1.PodRunning { | ||
return nil | ||
} | ||
|
||
url, err := cc.GetMetricsURL(importPod) | ||
if err != nil { | ||
if url == "" || err != nil { | ||
return err | ||
} | ||
if url == "" { | ||
return nil | ||
} | ||
|
||
// We fetch the import progress from the import pod metrics | ||
importRegExp := regexp.MustCompile("progress\\{ownerUID\\=\"" + string(pvc.UID) + "\"\\} (\\d{1,3}\\.?\\d*)") | ||
httpClient = cc.BuildHTTPClient(httpClient) | ||
|
@@ -275,12 +290,7 @@ func (r *ImportPopulatorReconciler) updateImportProgress(podPhase string, pvc, p | |
return nil | ||
} | ||
|
||
func (r *ImportPopulatorReconciler) getImportPod(pvc *corev1.PersistentVolumeClaim) (*corev1.Pod, error) { | ||
importPodName, ok := pvc.Annotations[cc.AnnImportPod] | ||
if !ok { | ||
return nil, nil | ||
} | ||
|
||
func (r *ImportPopulatorReconciler) getImportPod(pvc *corev1.PersistentVolumeClaim, importPodName string) (*corev1.Pod, error) { | ||
pod := &corev1.Pod{} | ||
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: importPodName, Namespace: pvc.GetNamespace()}, pod); err != nil { | ||
if !k8serrors.IsNotFound(err) { | ||
|
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.
Is this function duplicated in import controller?
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.
There's common code but one function uses
isPVCImportPopulation
andAnnImportPod
and the other the upload equivalent. I can try to have one shared function but I think this practice is somewhat common in our controllers.