Skip to content

Commit

Permalink
[Vault] Fix client to work when url is not configured (#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
theSaarco committed Apr 12, 2021
1 parent f452040 commit 1ad4520
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mlrun/api/api/endpoints/secrets.py
Expand Up @@ -26,7 +26,10 @@ def initialize_project_secrets(

# Init is idempotent and will do nothing if infra is already in place
init_project_vault_configuration(project)
add_vault_project_secrets(project, secrets.secrets)

# If no secrets were passed, no need to touch the actual secrets.
if secrets.secrets:
add_vault_project_secrets(project, secrets.secrets)
return Response(status_code=HTTPStatus.CREATED.value)


Expand Down
2 changes: 1 addition & 1 deletion mlrun/projects/project.py
Expand Up @@ -1233,7 +1233,7 @@ def get_vault_secrets(self, secrets=None, local=False):
logger.warning(
"get_vault_secrets executed locally. This is not recommended and may become deprecated soon"
)
self._secrets.vault.get_secrets(secrets, project=self.metadata.name)
return self._secrets.vault.get_secrets(secrets, project=self.metadata.name)

run_db = get_run_db(secrets=self._secrets)
project_secrets = run_db.get_project_secrets(
Expand Down
6 changes: 6 additions & 0 deletions mlrun/utils/vault.py
Expand Up @@ -147,6 +147,12 @@ def get_secrets(self, keys, user=None, project=None):
secret_path = VaultStore._generate_path(user=user, project=project)
secrets = {}

# Since this method is called both on the client side (when constructing VaultStore before persisting to
# pod configuration) and on server side and in execution pods, we let this method fail gracefully in this case.
# Should replace with something that will explode on server-side, once we have a way to do that.
if not self.url:
return secrets

response = self._api_call("GET", secret_path)

if not response:
Expand Down

0 comments on commit 1ad4520

Please sign in to comment.