Skip to content

Commit

Permalink
fix get_latest_backup
Browse files Browse the repository at this point in the history
  • Loading branch information
balajisa09 committed Jan 13, 2024
1 parent 0c419ed commit ca3ec67
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
logger.info(vault_sts_name+"-"+str(i)+" is already unsealed")

if restore_enabled=="true" and backup_found and not backup_restored:
vaultClient.restoreVaultfromS3(latest_backup)
vaultClient.restoreVaultfromS3(latest_backup['Key'])
backup_restored = True

if(vaultClient.vaultHealthCheck() != None):
Expand Down
2 changes: 1 addition & 1 deletion okteto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ autocreate: true
image: okteto/python:3
command: ["/bin/sh"]
workdir: /app
context: kind-kind
context: k3d-captain
namespace: glueops-core-vault
serviceAccount: vault-init-controller
securityContext:
Expand Down
3 changes: 1 addition & 2 deletions vault_k8s_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def vaultUnseal(self,vault_url,vault_key_threshold,secret_file):

threshold = vault_key_threshold
progress = 0

logger.info("Unsealing "+vault_url.split('https://')[1].split('.')[0])
for i in range(progress, threshold):
payload = '{"key" : "%s"}' % (keys[i])
try:
Expand Down Expand Up @@ -130,7 +130,6 @@ def restoreVaultfromS3(self, latest_backup):
restore_url = "https://"+self.vault_sts_name+"-0"+"."+self.vault_k8s_service_name+"."+self.vault_namespace+":"+self.service_port+"/v1/sys/storage/raft/snapshot-force"
logger.info("Restoring vault backup "+latest_backup)
res = requests.put(restore_url, headers=headers, data=response['Body'], verify=False)
logger.info(res.text)
if res.status_code == 204:
logger.info("Existing backup was restored successfully")
except Exception as e:
Expand Down

0 comments on commit ca3ec67

Please sign in to comment.