mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Fix recycling of cluster private keys (#2275)
* fix recycling of private keys * Update cluster-manager.yaml
This commit is contained in:
committed by
Raul Jordan
parent
8a6b55e93c
commit
ecebea01c0
@@ -129,20 +129,29 @@ func (d *db) AllocateNewPkToPod(
|
||||
})
|
||||
}
|
||||
|
||||
// RemovePKAssignment from pod and put the private key into the unassigned
|
||||
// RemovePKAssignments from pod and put the private keys into the unassigned
|
||||
// bucket.
|
||||
func (d *db) RemovePKAssignment(_ context.Context, podName string) error {
|
||||
assignedPkCount.Dec()
|
||||
return d.db.Update(func(tx *bolt.Tx) error {
|
||||
pk := tx.Bucket(assignedPkBucket).Get([]byte(podName))
|
||||
if pk == nil {
|
||||
data := tx.Bucket(assignedPkBucket).Get([]byte(podName))
|
||||
if data == nil {
|
||||
log.WithField("podName", podName).Warn("Nil private key returned from db")
|
||||
return nil
|
||||
}
|
||||
pks := &pb.PrivateKeys{}
|
||||
if err := proto.Unmarshal(data, pks); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Bucket(assignedPkBucket).Delete([]byte(podName)); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Bucket(unassignedPkBucket).Put(pk, dummyVal)
|
||||
assignedPkCount.Sub(float64(len(pks.PrivateKeys)))
|
||||
for _, pk := range pks.PrivateKeys {
|
||||
if err := tx.Bucket(unassignedPkBucket).Put(pk, dummyVal); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ func (wt *watchtower) WatchPods() {
|
||||
|
||||
// Query k8s pods for existence.
|
||||
func (wt *watchtower) queryPodsAndUpdateDB() error {
|
||||
// log.Debug("Checking pods")
|
||||
ctx := context.Background()
|
||||
podNames, err := wt.db.AllocatedPodNames(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user