<commit_before># Cluster Membership Reconciliation

## Recovery

Given a desired size S, we have two membership states:
- running pods P in k8s cluster
- membership M in controller knowledge

Recovery is the process to make these two states consistent.  Assuming “len(M) = S” here.

For each reconciling cycle, we get P from k8s API. Comparing M and P, we have the following steps:

1. Remove all pods from set P that does not belong to set M
2. P’ consist of remaining pods of P
3. If P’ = M, the current state matches the membership state. END.
4. If len(P’) < len(M)/2 + 1, quorum lost. Go to recovery process (TODO).
5. Add one missing member. END.

## Resize

(TODO)<commit_msg>add resize doc<commit_after># Cluster Membership Reconciliation

## Recovery

Given a desired size S, we have two membership states:
- running pods P in k8s cluster
- membership M in controller knowledge

Recovery is the process to make these two states consistent.  Assuming “len(M) = S” here.

For each reconciling cycle, we get P from k8s API. Comparing M and P, we have the following steps:

1. Remove all pods from set P that does not belong to set M
2. P’ consist of remaining pods of P
3. If P’ = M, the current state matches the membership state. END.
4. If len(P’) < len(M)/2 + 1, quorum lost. Go to recovery process (TODO).
5. Add one missing member. END.

## Resize

Before resizing an etcd cluster, we need to ensure the running Pods set matches the membership knowledge. Or we need to do recovery first.

Given a desired size S and membership size M:

1. If S = M, then END.
2. If S > M, add one member. END.
3. If S < M, remove one member. END
{'fraction_non_alphanumeric': 0.07134146341463414, 'fraction_numerical': 0.012804878048780487, 'mean_word_length': 3.5457063711911356, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7426680', 'n_tokens_mistral': 506, 'n_tokens_neox': 484, 'n_words': 281}