Skip to content

Commit

Permalink
Conditions update
Browse files Browse the repository at this point in the history
  • Loading branch information
videlov committed Jul 15, 2024
1 parent 4cfdc56 commit 19262f9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
11 changes: 6 additions & 5 deletions api/v1alpha2/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ func ConditionFromReason(reason ReasonWithMessage) *metav1.Condition {
}

var conditionReasons = map[ConditionReason]conditionMeta{
ConditionReasonReconcileSucceeded: {Type: ConditionTypeReady, Status: metav1.ConditionTrue, Message: ConditionReasonReconcileSucceededMessage},
ConditionReasonReconcileFailed: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonReconcileFailedMessage},
ConditionReasonReconcileUnknown: {Type: ConditionTypeReady, Status: metav1.ConditionUnknown, Message: ConditionReasonReconcileUnknownMessage},
ConditionReasonValidationFailed: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonValidationFailedMessage},
ConditionReasonOlderCRExists: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonOlderCRExistsMessage},
ConditionReasonReconcileSucceeded: {Type: ConditionTypeReady, Status: metav1.ConditionTrue, Message: ConditionReasonReconcileSucceededMessage},
ConditionReasonReconcileFailed: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonReconcileFailedMessage},
ConditionReasonReconcileUnknown: {Type: ConditionTypeReady, Status: metav1.ConditionUnknown, Message: ConditionReasonReconcileUnknownMessage},
ConditionReasonReconcileProxyResetRequeued: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonReconcileProxyResetRequeuedMessage},
ConditionReasonValidationFailed: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonValidationFailedMessage},
ConditionReasonOlderCRExists: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonOlderCRExistsMessage},

ConditionReasonIstioInstallNotNeeded: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonIstioInstallNotNeededMessage},
ConditionReasonIstioInstallSucceeded: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonIstioInstallSucceededMessage},
Expand Down
22 changes: 12 additions & 10 deletions api/v1alpha2/istio_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ const (
ConditionTypeProxySidecarRestartSucceeded ConditionType = "ProxySidecarRestartSucceeded"

// general
ConditionReasonReconcileSucceeded ConditionReason = "ReconcileSucceeded"
ConditionReasonReconcileSucceededMessage = "Reconciliation succeeded"
ConditionReasonReconcileUnknown ConditionReason = "ReconcileUnknown"
ConditionReasonReconcileUnknownMessage = "Module readiness is unknown. Either a reconciliation is progressing, or failed previously. Check status of other conditions"
ConditionReasonReconcileFailed ConditionReason = "ReconcileFailed"
ConditionReasonReconcileFailedMessage = "Reconciliation failed"
ConditionReasonValidationFailed ConditionReason = "ValidationFailed"
ConditionReasonValidationFailedMessage = "Reconciliation did not happen as Istio Custom Resource failed to validate"
ConditionReasonOlderCRExists ConditionReason = "OlderCRExists"
ConditionReasonOlderCRExistsMessage = "This Istio custom resource is not the oldest one and does not represent the module state"
ConditionReasonReconcileSucceeded ConditionReason = "ReconcileSucceeded"
ConditionReasonReconcileSucceededMessage = "Reconciliation succeeded"
ConditionReasonReconcileUnknown ConditionReason = "ReconcileUnknown"
ConditionReasonReconcileUnknownMessage = "Module readiness is unknown. Either a reconciliation is progressing, or failed previously. Check status of other conditions"
ConditionReasonReconcileProxyResetRequeued ConditionReason = "ProxyResetRequeued"
ConditionReasonReconcileProxyResetRequeuedMessage = "Proxy reset is still ongoing. Reconciliation requeued"
ConditionReasonReconcileFailed ConditionReason = "ReconcileFailed"
ConditionReasonReconcileFailedMessage = "Reconciliation failed"
ConditionReasonValidationFailed ConditionReason = "ValidationFailed"
ConditionReasonValidationFailedMessage = "Reconciliation did not happen as Istio Custom Resource failed to validate"
ConditionReasonOlderCRExists ConditionReason = "OlderCRExists"
ConditionReasonOlderCRExistsMessage = "This Istio custom resource is not the oldest one and does not represent the module state"

// install / uninstall
ConditionReasonIstioInstallNotNeeded ConditionReason = "IstioInstallNotNeeded"
Expand Down
1 change: 1 addition & 0 deletions controllers/istio_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (r *IstioReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
}
return ctrl.Result{}, err
} else if requeue {
r.statusHandler.SetCondition(&istioCR, operatorv1alpha2.NewReasonWithMessage(operatorv1alpha2.ConditionReasonReconcileProxyResetRequeued))
return r.requeueReconciliationWithoutError(ctx, &istioCR)
}

Expand Down
8 changes: 4 additions & 4 deletions controllers/istio_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,13 @@ var _ = Describe("Istio Controller", func() {

Expect(updatedIstioCR.Status.State).To(Equal(operatorv1alpha2.Processing))

By("Verifying that Istio CR has Condition Ready status with Unknown")
By("Verifying that Istio CR has Condition Ready status with ProxyResetRequeued reason")
Expect(updatedIstioCR.Status.Conditions).ToNot(BeNil())
Expect(*updatedIstioCR.Status.Conditions).To(HaveLen(1))
Expect((*updatedIstioCR.Status.Conditions)[0].Type).To(Equal(string(operatorv1alpha2.ConditionTypeReady)))
Expect((*updatedIstioCR.Status.Conditions)[0].Reason).To(Equal(string(operatorv1alpha2.ConditionReasonReconcileUnknown)))
Expect((*updatedIstioCR.Status.Conditions)[0].Message).To(Equal(operatorv1alpha2.ConditionReasonReconcileUnknownMessage))
Expect((*updatedIstioCR.Status.Conditions)[0].Status).To(Equal(metav1.ConditionUnknown))
Expect((*updatedIstioCR.Status.Conditions)[0].Reason).To(Equal(string(operatorv1alpha2.ConditionReasonReconcileProxyResetRequeued)))
Expect((*updatedIstioCR.Status.Conditions)[0].Message).To(Equal(operatorv1alpha2.ConditionReasonReconcileProxyResetRequeuedMessage))
Expect((*updatedIstioCR.Status.Conditions)[0].Status).To(Equal(metav1.ConditionFalse))
})
})
})
Expand Down
4 changes: 4 additions & 0 deletions docs/contributor/04-10-technical-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ The predicate initiates a restart of the sidecar and Ingress Gateway if the targ
The SidecarsRestarter is responsible for keeping the proxy sidecars in the desired state. It restarts Pods that are in running state and are part of the service mesh having the annotation `sidecar.istio.io/status`.
The Istio CR and [Istio Version](#istio-version) represent the desired state. Pods will be restarted in chunks with limits on how many to restart with one reconciliation and how many to list when requesting from Kubernetes API Server. If more Pods need to be restarted this will happen in next reconciliation. This happens with requeuing the reconciliation request, which will be imediately rescheduled.

During proxy sidecars restarting phase, Istio CR will be kept in `Processing` state having following status conditions:
- `Ready` condition set to `false` with `ProxyResetRequeued` reason.
- `ProxySidecarRestartSucceeded` condition set to `false` with `ProxySidecarPartiallySucceeded` reason.

This component covers the following restart triggers:

- Restart Pods with proxy sidecar when CNI config changes.
Expand Down
3 changes: 1 addition & 2 deletions pkg/lib/sidecars/pods/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func getSidecarPods(ctx context.Context, c client.Client, logger *logr.Logger, l
return nil, err
}

logger.Info("Retrieved running pods for proxy restart", "number of pods", len(podList.Items), "has more pods", podList.Continue != "")
logger.Info("Got running pods for proxy restart", "number of pods", len(podList.Items), "has more pods", podList.Continue != "")

podsWithSidecar := &v1.PodList{}
podsWithSidecar.Continue = podList.Continue
Expand All @@ -83,7 +83,6 @@ func getSidecarPods(ctx context.Context, c client.Client, logger *logr.Logger, l
}

logger.Info("Filtered pods with Istio sidecar", "number of pods", len(podsWithSidecar.Items))

return podsWithSidecar, nil
}

Expand Down

0 comments on commit 19262f9

Please sign in to comment.