Skip to content

Commit

Permalink
Handle client errors when trying to get the import pod
Browse files Browse the repository at this point in the history
Signed-off-by: Bartosz Rybacki <[email protected]>
  • Loading branch information
brybacki committed May 26, 2020
1 parent 61563c3 commit 3962833
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/controller/import-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ func (r *ImportReconciler) Reconcile(req reconcile.Request) (reconcile.Result, e
func (r *ImportReconciler) findImporterPod(pvc *corev1.PersistentVolumeClaim, log logr.Logger) (*corev1.Pod, error) {
podName := getImportPodNameFromPvc(pvc)
pod := &corev1.Pod{}
err := r.client.Get(context.TODO(), types.NamespacedName{Name: podName, Namespace: pvc.GetNamespace()}, pod)

if k8serrors.IsNotFound(err) {
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: podName, Namespace: pvc.GetNamespace()}, pod); err != nil {
if !k8serrors.IsNotFound(err) {
return nil, errors.Wrapf(err, "error getting import pod %s/%s", pvc.Namespace, podName)
}
return nil, nil
}
/// TODO: what about other errors? // check upload

if !metav1.IsControlledBy(pod, pvc) {
return nil, errors.Errorf("Pod is not owned by PVC")
}
Expand Down

0 comments on commit 3962833

Please sign in to comment.