-
Notifications
You must be signed in to change notification settings - Fork 15
Create a design-document for the controller #181
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
17d08f5
Start documenting the controller's logic
lllamnyp 885f9ab
Merge branch 'main' into docs/design
lllamnyp be237d5
update design doc to better describe current algorithm of the controller
lllamnyp c39426b
Merge branch 'main' into docs/design
lllamnyp 075ebc4
Add reconciliation flowchart
lllamnyp 246ba85
update reconciliation flowchart
lllamnyp b81595b
update flowchart
lllamnyp 23004f9
more updates to flowchart
lllamnyp 9c99b6c
Reconciliation flowchart v0.1
lllamnyp 0c1257b
Merge branch 'main' into docs/design
lllamnyp f999f5f
Remove unnecessary force-new-cluster
lllamnyp 9509c1e
svg append
hiddenmarten 3708e26
updates to flowchart
lllamnyp ba4a76f
Merge branch 'main' into docs/design
lllamnyp 8a17155
Update docs/DESIGN.md
lllamnyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Design | ||
|
||
This document describes the interaction between `EtcdCluster` custom resources and other Kubernetes | ||
primitives and gives an overview of the underlying implementation. | ||
|
||
## Reconciliation flowchart | ||
|
||
```mermaid | ||
flowchart TD | ||
Start(Start) --> A[Ensure service.] | ||
A --> AA{Are there any\nendpoints?} | ||
AA --> |Yes| AAA[Connect to the cluster\nand fetch all statuses.] | ||
AAA --> |Got some response| AAAA{All reachable\nmembers have the\nsame cluster ID?} | ||
AAAA --> |Yes| AAAAA{Is cluster\nin quorum?} | ||
AAAAA --> |Yes| AAAAAA{Are all members \nmanaged by the operator?} | ||
AAAAAA --> |Yes| AAAAAAA["` | ||
Promote any learners. | ||
Ensure configmap with initial cluster matching existing members and cluster state=existing. | ||
Ensure StatefulSet with replicas = max member ordinal + 1 | ||
`"] | ||
AAAAAAA --> |OK| AAAAAAAA{Are all\nmembers healthy?} | ||
AAAAAAAA --> |Yes| AAAAAAAAA{Are all STS pods present\nin the member list?} | ||
AAAAAAAAA --> |Yes| AAAAAAAAAA{Is the\nEtcdCluster\nsize equal to the\nStatefulSet\nsize?} | ||
AAAAAAAAAA -->|Yes| AAAAAAAAAAA[Set cluster\nstatus to ready.] | ||
AAAAAAAAAAA --> HappyStop([Stop]) | ||
lllamnyp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
AAAAAAAAAA --> |No, desired\nsize larger| AAAAAAAAAAB[Ensure ConfigMap with\ninitial cluster state existing\nand initial cluster URLs\nequal to current cluster\nplus one member, do\n'member add' API call and\nincrement StatefulSet size.] | ||
AAAAAAAAAAB --> ScaleUpStop([Stop]) | ||
|
||
AAAAAAAAAA --> |No, desired\nsize smaller| AAAAAAAAAAC[Member remove API\ncall, then decrement\nStatefulSet size\nthen delete PVC.] | ||
AAAAAAAAAAC --> ScaleDownStop([Stop]) | ||
|
||
AAAAAAAAAA --> |Etcd replicas=0\nSTS replicas=1| AAAAAAAAAAD[Decrement\nSTS to zero] | ||
AAAAAAAAAAD --> ScaleToZeroStop([Stop]) | ||
|
||
AAAAAAAA --> |No| AAAAAAAAB1[On timeout evict member.] | ||
AAAAAAAAB1 --> AAAAAAAAB2[Delete PVC, ensure ConfigMap with\nmembers + this one and delete pod.] | ||
|
||
AAAAAAAAA --> |No| AAAAAAAAB2 | ||
|
||
AAAAAAA -->|Error| AAAAAAAB([Requeue]) | ||
|
||
AAAAAA --> |No| AAAAAAB([Not implemented,\nstop.]) | ||
|
||
AAAAA --> |No| AAAAAB([Quorum Loss Detected: | ||
1. Check for temporary issues: | ||
- Network partitions | ||
- Pod scheduling problems | ||
2. If temporary, wait for recovery | ||
3. If permanent: | ||
- Alert operators | ||
- Document disaster recovery steps | ||
- Consider backup restoration]) | ||
|
||
AAAA --> |No| AAAAB[Cluster is in\nsplit-brain. Set\nerror status.] | ||
AAAAB --> AAAABStop([Stop]) | ||
|
||
AAA --> |No members\nreached| AAAB{Is the STS\npresent?} | ||
AAAB --> |Yes| AAABA{"`Does it have the correct pod spec?`"} | ||
AAABA --> |Yes| AAABAA(["`The statefulset cannot be ready, as the ready and liveness probes must be failing. Hope it becomes ready or wait for user intervention.`"]) | ||
AAABA --> |No| AAABAB["`Patch the podspec`"] | ||
|
||
AAAB --> |No| AAABB(["`Looks like it was deleted with cascade=orphan. Create it again and see what happens`"]) | ||
|
||
AA --> |No| AAB{Is the STS\npresent?} | ||
AAB --> |Yes| AABA{Does it have the\ncorrect pod spec?} | ||
AABA --> |Yes| AABAA{Is it\nready?} | ||
AABAA --> |Yes| AABAAA{Then it must have\nspec.replicas==0\n Is EtcdCluster\n.spec.replicas==0?} | ||
AABAAA --> |Yes| AABAAAA([Cluster successfully\nscaled to zero, stop.]) | ||
AABAAA --> |No| AABAAAB["` | ||
Ensure ConfigMap with initial cluster = new, | ||
initial cluster peers with single member name-0, | ||
increment STS size. | ||
`"] | ||
|
||
AABAA --> |No| AABAAB([Stop and wait, either\nit will turn ready soon\nand the next reconcile\nwill move things along,\nor user intervention is\nneeded]) | ||
|
||
AABA --> |No| AABAB[Patch the podspec] | ||
|
||
AAB --> |No| AABB[Create configmap, initial state new\ninitial cluster according to spec.\nreplicas, create statefulset.] | ||
``` | ||
lllamnyp marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.