Skip to content

Commit 8ddbfed

Browse files
committed
🚑 hotfix
modified: controllers/pod_controller.go; modified: controllers/pod_controller_functions.go
1 parent 9af419d commit 8ddbfed

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

controllers/pod_controller.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
5757
// we'll ignore not-found errors, since they can't be fixed by an immediate
5858
// requeue (we'll need to wait for a new notification), and we can get them
5959
// on deleted requests.
60-
return ctrl.Result{}, nil
60+
return ctrl.Result{}, err
6161
}
6262
log.Error(err, "unable to fetch Pod")
6363
return ctrl.Result{}, err
@@ -75,7 +75,7 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
7575

7676
if err != nil {
7777
log.Error(err, "failed to get stats from pod")
78-
return ctrl.Result{}, nil
78+
return ctrl.Result{}, err
7979
}
8080
PodUsageData := GeneratePodRequestsObjectFromRestData(data)
8181

@@ -175,6 +175,7 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
175175
replica, err := r.ClientSet.AppsV1().ReplicaSets(pod.Namespace).Get(ctx, pod.OwnerReferences[0].Name, metav1.GetOptions{})
176176
if err != nil {
177177
log.Error(err, err.Error())
178+
return ctrl.Result{}, err
178179
}
179180

180181
ownerName = replica.OwnerReferences[0].Name
@@ -183,11 +184,13 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
183184
deployment, err := r.ClientSet.AppsV1().Deployments(pod.Namespace).Get(ctx, ownerName, metav1.GetOptions{})
184185
if err != nil {
185186
log.Error(err, err.Error())
187+
return ctrl.Result{}, err
186188
}
187189
UpdatePodController(deployment, Requests, ctx)
188190
return r.UpdateKubeObject(deployment, ctx)
189191
} else {
190192
log.Info("Is Owned by Unknown CRD")
193+
return ctrl.Result{}, nil
191194
}
192195
case "DaemonSet":
193196
log.Info("Is Owned by DaemonSet")
@@ -196,6 +199,7 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
196199
deployment, err := r.ClientSet.AppsV1().DaemonSets(pod.Namespace).Get(ctx, ownerName, metav1.GetOptions{})
197200
if err != nil {
198201
log.Error(err, err.Error())
202+
return ctrl.Result{}, err
199203
}
200204
UpdatePodController(deployment, Requests, ctx)
201205
return r.UpdateKubeObject(deployment, ctx)
@@ -206,6 +210,7 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
206210
deployment, err := r.ClientSet.AppsV1().StatefulSets(pod.Namespace).Get(ctx, ownerName, metav1.GetOptions{})
207211
if err != nil {
208212
log.Error(err, err.Error())
213+
return ctrl.Result{}, err
209214
}
210215

211216
UpdatePodController(deployment, Requests, ctx)
@@ -222,5 +227,5 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
222227
}
223228
}
224229

225-
return ctrl.Result{}, nil
230+
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
226231
}

controllers/pod_controller_functions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (r *PodReconciler) UpdateKubeObject(pod client.Object, ctx context.Context)
3636
if apierrors.IsConflict(err) {
3737
// The Pod has been updated since we read it.
3838
// Requeue the Pod to try to reconciliate again.
39-
return ctrl.Result{Requeue: true}, err
39+
return ctrl.Result{RequeueAfter: 10 * time.Second}, err
4040
}
4141
if apierrors.IsNotFound(err) {
4242
// The Pod has been deleted since we read it.
@@ -46,7 +46,7 @@ func (r *PodReconciler) UpdateKubeObject(pod client.Object, ctx context.Context)
4646
log.Error(err, "unable to update pod")
4747
return ctrl.Result{}, err
4848
}
49-
return ctrl.Result{}, nil
49+
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
5050
}
5151

5252
func UpdatePodController(deployment interface{}, Requests []NewContainerRequests, ctx context.Context) {

0 commit comments

Comments
 (0)