MCPcopy
hub / github.com/apecloud/kubeblocks / newReconcilerTree

Function newReconcilerTree

controllers/trace/reconciler_tree.go:124–155  ·  view source on GitHub ↗
(ctx context.Context, mClient client.Client, recorder record.EventRecorder, rules []OwnershipRule)

Source from the content-addressed store, hash-verified

122}
123
124func newReconcilerTree(ctx context.Context, mClient client.Client, recorder record.EventRecorder, rules []OwnershipRule) (ReconcilerTree, error) {
125 dag := graph.NewDAG()
126 reconcilers := make(map[tracev1.ObjectType]reconcile.Reconciler)
127 for _, rule := range rules {
128 dag.AddVertex(rule.Primary)
129 reconciler, err := newReconciler(mClient, recorder, rule.Primary)
130 if err != nil {
131 return nil, err
132 }
133 reconcilers[rule.Primary] = reconciler
134 for _, resource := range rule.OwnedResources {
135 dag.AddVertex(resource.Secondary)
136 dag.Connect(rule.Primary, resource.Secondary)
137 reconciler, err = newReconciler(mClient, recorder, resource.Secondary)
138 if err != nil {
139 return nil, err
140 }
141 reconcilers[resource.Secondary] = reconciler
142 }
143 }
144 // DAG should be valid(one and only one root without cycle)
145 if err := dag.Validate(); err != nil {
146 return nil, err
147 }
148
149 return &reconcilerTree{
150 ctx: ctx,
151 cli: mClient,
152 tree: dag,
153 reconcilers: reconcilers,
154 }, nil
155}
156
157func newReconciler(mClient client.Client, recorder record.EventRecorder, objectType tracev1.ObjectType) (reconcile.Reconciler, error) {
158 reconcilerF, ok := reconcilerFuncMap[objectType]

Callers 2

generatePlanMethod · 0.85

Calls 5

AddVertexMethod · 0.95
ConnectMethod · 0.95
ValidateMethod · 0.95
NewDAGFunction · 0.92
newReconcilerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…