-
Notifications
You must be signed in to change notification settings - Fork 182
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
feat: Support Reconciliation Tracing #8143
base: main
Are you sure you want to change the base?
Conversation
why use these two markers:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8143 +/- ##
==========================================
+ Coverage 60.35% 60.63% +0.28%
==========================================
Files 357 376 +19
Lines 42555 45195 +2640
==========================================
+ Hits 25684 27404 +1720
- Misses 14559 15241 +682
- Partials 2312 2550 +238
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
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.
To be continued.
// Unmarshal the patched JSON back into the object | ||
return json.Unmarshal(patchedJSON, obj) | ||
// Unmarshal the patched JSON into a new clean object | ||
newObj := obj.DeepCopyObject().(client.Object) |
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.
Can use reflection to create a new zeroed object directly, to avoid this deep-copying.
@@ -1865,6 +1865,8 @@ controllers: | |||
enabled: true | |||
experimental: | |||
enabled: false | |||
trace: | |||
enabled: true |
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.
How about setting it to false for now and re-enabling it when the performance issue is solved?
Background
"Reconciliation Tracing" refers to the process of tracking the reconciliation workflow of an Operator or Controller and presenting it in a task flow format. This allows for a more intuitive observation of the reconciliation process and helps in problem identification. This feature can be considered an observability tool for Operators or Controllers.
Goals and Motivation
The tracking of the reconciliation process has two extremes. One is to simply observe whether the current status (usually the Status section) of the primary resource aligns with the desired state (typically the Spec section), which represents the highest-level observation.
The other direction is to observe changes related to the primary resource and all associated secondary resources to gain a comprehensive understanding of the entire reconciliation process. The former aspect has been sufficiently considered in the design of each API or Custom Resource Definition (CRD), while this proposal focuses on the latter.
The goal of this proposal is to track and display the reconciliation process of KubeBlocks to facilitate a detailed understanding of the reconciliation process or to identify issues. Specifically, it includes the following objectives:
Proposal Design
Mental Model
Object Tree
The reconciliation process revolves around the object tree and the changes within it. An object tree consists of a primary object and all its associated secondary objects. For a KB Cluster, the structure of its object tree is as follows:
Object Change
The reconciliation process ultimately manifests as the addition, removal, or state change of nodes within the object tree. By recording these changes and presenting them along a timeline, we can obtain a clear and detailed view of the reconciliation process.
The recorded content includes two types: one is the changes to the objects themselves within the object tree, and the other is the events associated with those objects in the object tree.
Reconciliation Cycle
Throughout the entire lifecycle of a Cluster, from creation to eventual destruction, it undergoes multiple reconciliation loops. At the end of each reconciliation loop, the Cluster either reaches a terminal state or does not. We refer to all reconciliations occurring between two instances of the terminal state as a reconciliation cycle.
Metaphorically, the object tree can be viewed as a tree in nature, and what we aim to describe is the growth and changes of this tree over the course of a year (or one growth cycle).
API Design
For detailed design, please refer to the pull request (PR). Below is an example:
kbcli Interaction Design
Command Line
Command Path:
kbcli trace
Subcommands:
TUI Display
In the Trace subcommand, the watch command provides real-time tracking and display of the reconciliation process, presented in a TUI format within kbcli. The layout is as follows:
Implementation of the Proposal
Reconciliation Process Tracking
Tracking the reconciliation process involves monitoring all primary and secondary resources related to a KB Cluster, as well as associated events, and meticulously recording each change. The basic flow is as follows:
Reconciliation Process Prediction
Prediction refers to forecasting all reconciliation processes that will occur from the current state until the terminal state is reached. The format and approach for this are similar to process tracking, described through changes in the object tree.
The key difference is that the prediction mechanism builds a simulated environment, where the current state (the Cluster and all its secondary objects) serves as input until the simulation reaches a terminal state. All object changes that occur during this period are recorded as part of the reconciliation process prediction. The basic flow is as follows:
Predictions occur in two scenarios:
When there is a change in the Cluster Spec, initiating a new reconciliation cycle, the upcoming reconciliation process is predicted and updated in trace.status.desiredState.
During a dry run, the desired specification from the dry run is first applied to the current Cluster object in the simulated environment, after which the subsequent reconciliation process is predicted and updated in trace.status.dryRunResult.
kubectl Display
In kubectl, the current reconciliation progress can be viewed in real-time using the command:
For example:
Screenshot:
kbcli Display
Through kbcli, more detailed information can be displayed. For example, the following shows the tracking of the reconciliation process for a Redis cluster: