Skip to content

Commit

Permalink
fix(controller): v2 pod controller error log for missing ip (#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanStough authored Nov 2, 2023
1 parent c1ed354 commit e50c8e2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/3162.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
control-plane: remove extraneous error log in v2 pod controller when a pod is scheduled, but not yet allocated an IP.
```
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ func (r *Controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
r.Log.Info("retrieved", "name", pod.Name, "ns", pod.Namespace)

if inject.HasBeenMeshInjected(pod) {

// It is possible the pod was scheduled but doesn't have an allocated IP yet, so safely requeue
if pod.Status.PodIP == "" {
r.Log.Info("pod does not have IP allocated; re-queueing request", "pod", req.Name, "ns", req.Namespace)
return ctrl.Result{Requeue: true}, nil
}

if err := r.writeProxyConfiguration(ctx, pod); err != nil {
// We could be racing with the namespace controller.
// Requeue (which includes backoff) to try again.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,8 @@ func TestReconcileCreatePod(t *testing.T) {
metrics bool
telemetry bool

expErr string
requeue bool
expErr string
}

run := func(t *testing.T, tc testCase) {
Expand Down Expand Up @@ -1290,7 +1291,7 @@ func TestReconcileCreatePod(t *testing.T) {
} else {
require.NoError(t, err)
}
require.False(t, resp.Requeue)
require.Equal(t, tc.requeue, resp.Requeue)

wID := getWorkloadID(tc.podName, metav1.NamespaceDefault, constants.DefaultConsulPartition)
expectedWorkloadMatches(t, context.Background(), resourceClient, wID, tc.expectedWorkload)
Expand Down Expand Up @@ -1382,6 +1383,16 @@ func TestReconcileCreatePod(t *testing.T) {
expectedProxyConfiguration: createProxyConfiguration("foo", pbmesh.ProxyMode_PROXY_MODE_DEFAULT),
expectedDestinations: createDestinations(),
},
{
name: "pod w/o IP",
podName: "foo",
k8sObjects: func() []runtime.Object {
pod := createPod("foo", "", true, true)
pod.Status.PodIP = ""
return []runtime.Object{pod}
},
requeue: true,
},
// TODO: make sure multi-error accumulates errors
}

Expand Down

0 comments on commit e50c8e2

Please sign in to comment.