Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 83
✨ Add more probing to CER#2210
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,17 +12,18 @@ import ( | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" | ||
| "k8s.io/apimachinery/pkg/api/equality" | ||
| "k8s.io/apimachinery/pkg/api/meta" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| "k8s.io/apimachinery/pkg/util/sets" | ||
| "pkg.package-operator.run/boxcutter" | ||
| "pkg.package-operator.run/boxcutter/machinery" | ||
| machinerytypes "pkg.package-operator.run/boxcutter/machinery/types" | ||
| "pkg.package-operator.run/boxcutter/probing" | ||
| ctrl "sigs.k8s.io/controller-runtime" | ||
| "sigs.k8s.io/controller-runtime/pkg/builder" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| @@ -430,31 +431,9 @@ func toBoxcutterRevision(rev *ocv1.ClusterExtensionRevision) (*boxcutter.Revisio | ||
| opts := []boxcutter.RevisionReconcileOption{ | ||
| boxcutter.WithPreviousOwners(previous), | ||
| boxcutter.WithProbe(boxcutter.ProgressProbeType, boxcutter.ProbeFunc(func(obj client.Object) (bool, []string) { | ||
| deployGK := schema.GroupKind{ | ||
| Group: "apps", Kind: "Deployment", | ||
| } | ||
| if obj.GetObjectKind().GroupVersionKind().GroupKind() != deployGK { | ||
| return true, nil | ||
| } | ||
| ustrObj := obj.(*unstructured.Unstructured) | ||
| depl := &appsv1.Deployment{} | ||
| if err := runtime.DefaultUnstructuredConverter.FromUnstructured(ustrObj.Object, depl); err != nil { | ||
| return false, []string{err.Error()} | ||
| } | ||
| if depl.Status.ObservedGeneration != depl.Generation { | ||
| return false, []string{".status.observedGeneration outdated"} | ||
| } | ||
| for _, cond := range depl.Status.Conditions { | ||
| if cond.Type == ocv1.ClusterExtensionRevisionTypeAvailable && | ||
| cond.Status == corev1.ConditionTrue && | ||
| depl.Status.UpdatedReplicas == *depl.Spec.Replicas { | ||
| return true, nil | ||
| } | ||
| } | ||
| return false, []string{"not available or not fully updated"} | ||
| })), | ||
| boxcutter.WithProbe(boxcutter.ProgressProbeType, probing.And{ | ||
| deploymentProbe, statefulSetProbe, crdProbe, issuerProbe, certProbe, | ||
| }), | ||
| } | ||
| r := &boxcutter.Revision{ | ||
| @@ -490,3 +469,64 @@ func toBoxcutterRevision(rev *ocv1.ClusterExtensionRevision) (*boxcutter.Revisio | ||
| } | ||
| return r, opts, previous | ||
| } | ||
| var ( | ||
| deploymentProbe = &probing.GroupKindSelector{ | ||
| GroupKind: schema.GroupKind{Group: appsv1.GroupName, Kind: "Deployment"}, | ||
| Prober: deplStatefulSetProbe, | ||
| } | ||
| statefulSetProbe = &probing.GroupKindSelector{ | ||
| GroupKind: schema.GroupKind{Group: appsv1.GroupName, Kind: "StatefulSet"}, | ||
| Prober: deplStatefulSetProbe, | ||
| } | ||
| crdProbe = &probing.GroupKindSelector{ | ||
| GroupKind: schema.GroupKind{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"}, | ||
| Prober: &probing.ObservedGenerationProbe{ | ||
| Prober: &probing.ConditionProbe{ // "Available" == "True" | ||
| Type: string(apiextensions.Established), | ||
| Status: string(corev1.ConditionTrue), | ||
| }, | ||
| }, | ||
| } | ||
| certProbe = &probing.GroupKindSelector{ | ||
| GroupKind: schema.GroupKind{Group: "acme.cert-manager.io", Kind: "Certificate"}, | ||
| Prober: &probing.ObservedGenerationProbe{ | ||
| Prober: readyConditionProbe, | ||
| }, | ||
| } | ||
| issuerProbe = &probing.GroupKindSelector{ | ||
| GroupKind: schema.GroupKind{Group: "acme.cert-manager.io", Kind: "Issuer"}, | ||
| Prober: &probing.ObservedGenerationProbe{ | ||
| Prober: readyConditionProbe, | ||
| }, | ||
| } | ||
| // deplStaefulSetProbe probes Deployment, StatefulSet objects. | ||
| deplStatefulSetProbe = &probing.ObservedGenerationProbe{ | ||
| Prober: probing.And{ | ||
| availableConditionProbe, | ||
| replicasUpdatedProbe, | ||
| }, | ||
| } | ||
| // Checks if the Type: "Available" Condition is "True". | ||
| availableConditionProbe = &probing.ConditionProbe{ // "Available" == "True" | ||
| Type: string(appsv1.DeploymentAvailable), | ||
| Status: string(corev1.ConditionTrue), | ||
| } | ||
| // Checks if the Type: "Ready" Condition is "True" | ||
| readyConditionProbe = &probing.ObservedGenerationProbe{ | ||
| Prober: &probing.ConditionProbe{ | ||
| Type: "Ready", | ||
| Status: "True", | ||
| }, | ||
| } | ||
| // Checks if .status.updatedReplicas == .status.replicas. | ||
| // Works for StatefulSts, Deployments and ReplicaSets. | ||
| replicasUpdatedProbe = &probing.FieldsEqualProbe{ | ||
Contributor 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. Nit, this is used only in one place (i.e. only one other reference). Contributor 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. But i's AND'd with one other probe, to make it easier to read. | ||
| FieldA: ".status.updatedReplicas", | ||
| FieldB: ".status.replicas", | ||
| } | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Nit, this is used only in one place (i.e. only one other reference).