refactor codebase:
- trailing whitespace in docs - reduce panic and return err - use log instead of fmt
This commit is contained in:
Родитель
0d27b61614
Коммит
e042578269
|
@ -14,7 +14,7 @@ For each reconciling cycle, we get P from k8s API. Comparing M and P, we have th
|
|||
2. P’ consist of remaining pods of P
|
||||
3. If P’ = M, the current state matches the membership state. GOTO Resize.
|
||||
4. If len(P’) < len(M)/2 + 1, quorum lost. Go to recovery process (TODO).
|
||||
5. Remove one member that in M but does not in P's. GOTO Resize.
|
||||
5. Remove one member that in M but does not in P's. GOTO Resize.
|
||||
|
||||
### Resize
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ func (c *Cluster) create(spec *Spec) {
|
|||
panic(fmt.Sprintf("(TODO: we need to clean up already created ones.)\nError: %v", err))
|
||||
}
|
||||
c.idCounter++
|
||||
fmt.Println("created cluster:", members)
|
||||
log.Println("created cluster:", members)
|
||||
}
|
||||
|
||||
func (c *Cluster) Update(spec *Spec) {
|
||||
|
|
|
@ -44,15 +44,15 @@ func (c *Cluster) reconcile(running etcdutil.MemberSet) error {
|
|||
c.updateMembers(etcdcli)
|
||||
}
|
||||
|
||||
log.Println("Running pods:", running)
|
||||
log.Println("Expected membership:", c.members)
|
||||
log.Println("Running pods:\t", running)
|
||||
log.Println("Expected membership:\t", c.members)
|
||||
|
||||
unknownMembers := running.Diff(c.members)
|
||||
if unknownMembers.Size() > 0 {
|
||||
log.Println("Removing unexpected pods:", unknownMembers)
|
||||
for _, m := range unknownMembers {
|
||||
if err := c.removePodAndService(m.Name); err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,11 +63,11 @@ func (c *Cluster) reconcile(running etcdutil.MemberSet) error {
|
|||
}
|
||||
|
||||
if L.Size() < c.members.Size()/2+1 {
|
||||
fmt.Println("Disaster recovery")
|
||||
log.Println("Disaster recovery")
|
||||
return c.disasterRecovery()
|
||||
}
|
||||
|
||||
fmt.Println("Recovering one member")
|
||||
log.Println("Recovering one member")
|
||||
toRecover := c.members.Diff(L).PickOne()
|
||||
|
||||
if err := c.removeMember(toRecover); err != nil {
|
||||
|
@ -101,7 +101,7 @@ func (c *Cluster) addOneMember() error {
|
|||
newMember := &etcdutil.Member{Name: newMemberName}
|
||||
resp, err := etcdcli.MemberAdd(context.TODO(), []string{newMember.PeerAddr()})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
newMember.ID = resp.Member.ID
|
||||
c.members.Add(newMember)
|
||||
|
|
Загрузка…
Ссылка в новой задаче