Skip to content

Commit

Permalink
Modified vault unseal
Browse files Browse the repository at this point in the history
  • Loading branch information
Shifna12Zarnaz committed Sep 18, 2023
1 parent 64df23c commit 62b5aac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion internal/client/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,19 @@ func (vc *VaultClient) DeleteCredential(ctx context.Context, mountPath, secretPa
func (vc *VaultClient) JoinRaftCluster(podip string) error {
var req *api.RaftJoinRequest
address := fmt.Sprintf("http://%s:8200", podip)

err := vc.c.SetAddress(address)
if err != nil {
vc.log.Errorf("Error while setting address")
}
vc.log.Debug("Address", address)

leaderInfo, err := vc.c.Sys().Leader()
vc.log.Debug("Leader address",leaderInfo.LeaderAddress)
if err != nil {

vc.log.Debugf("Failed to retrieve leader information: %v", err)
return err

}

if leaderInfo.LeaderAddress == "" {
Expand Down
11 changes: 5 additions & 6 deletions internal/job/vault_seal_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ func (v *VaultSealWatcher) Run() {
v.log.Errorf("failed to retrieve pod ip, %s", err)
return
}
err = vc.JoinRaftCluster(podip)
if err != nil {
v.log.Errorf("Failed to join the HA cluster: %v\n", err)
return

}
_, unsealKeys, err := vc.GetVaultSecretValuesforMultiInstance()
v.log.Debug("Unseal Keys", unsealKeys)
if err != nil {
Expand All @@ -133,12 +138,6 @@ func (v *VaultSealWatcher) Run() {
v.log.Errorf("failed to unseal vault, %s", err)
return
}
err = vc.JoinRaftCluster(podip)
if err != nil {
v.log.Errorf("Failed to join the HA cluster: %v\n", err)
return

}

}

Expand Down

0 comments on commit 62b5aac

Please sign in to comment.