-
Notifications
You must be signed in to change notification settings - Fork 1
Mtor/prod 15615 #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Mtor/prod 15615 #455
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7b89497
feat: add creation and deletion of Secrets and ConfigMaps
f0ad96b
fix(env): improve K8s secret not found error with actionable diagnostics
1769094
ruff: formating
d908116
update version
ec500ea
update uv.lock file & CI: azure login to v3
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,12 @@ | |
| from yaml import safe_load | ||
|
|
||
| from Babylon.commands.api.workspace import get_workspace_api_instance | ||
| from Babylon.commands.macro.deploy import get_postgres_service_host, update_object_security | ||
| from Babylon.commands.macro.deploy import ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The macro command for creating a workspace is very different from the micro-command that just reflects the API, I wonder if it is worth adding some comment in the source to make this clear |
||
| create_coal_configmap, | ||
| create_workspace_secret, | ||
| get_postgres_service_host, | ||
| update_object_security, | ||
| ) | ||
| from Babylon.utils.credentials import get_keycloak_token | ||
| from Babylon.utils.environment import Environment | ||
| from Babylon.utils.response import CommandResponse | ||
|
|
@@ -93,7 +98,7 @@ def deploy_workspace(namespace: str, file_content: str, deploy_dir: PathlibPath) | |
| should_create_schema = schema_config.get("create", False) | ||
| if should_create_schema: | ||
| db_host = get_postgres_service_host(env.environ_id) | ||
| logger.info(f" [dim]→ Initializing PostgreSQL schema for workspace {workspace_id}...[/dim]") | ||
| logger.info(f" [dim]→ Initializing PostgreSQL schema for workspace [bold cyan]{workspace_id}[/bold cyan]...[/dim]") | ||
| pg_config = env.get_config_from_k8s_secret_by_tenant("postgresql-config", env.environ_id) | ||
| api_config = env.get_config_from_k8s_secret_by_tenant("postgresql-cosmotechapi", env.environ_id) | ||
| if pg_config and api_config: | ||
|
|
@@ -102,11 +107,11 @@ def deploy_workspace(namespace: str, file_content: str, deploy_dir: PathlibPath) | |
| "namespace": env.environ_id, | ||
| "db_host": db_host, | ||
| "db_port": "5432", | ||
| "cosmotech_api_database": api_config.get("database-name"), | ||
| "cosmotech_api_admin_username": api_config.get("admin-username"), | ||
| "cosmotech_api_admin_password": api_config.get("admin-password"), | ||
| "cosmotech_api_writer_username": api_config.get("writer-username"), | ||
| "cosmotech_api_reader_username": api_config.get("reader-username"), | ||
| "cosmotech_api_database": api_config.get("database-name", ""), | ||
| "cosmotech_api_admin_username": api_config.get("admin-username", ""), | ||
| "cosmotech_api_admin_password": api_config.get("admin-password", ""), | ||
| "cosmotech_api_writer_username": api_config.get("writer-username", ""), | ||
| "cosmotech_api_reader_username": api_config.get("reader-username", ""), | ||
| "workspace_schema": schema_name, | ||
| "job_name": workspace_id, | ||
| } | ||
|
|
@@ -187,6 +192,32 @@ def deploy_workspace(namespace: str, file_content: str, deploy_dir: PathlibPath) | |
| logger.error(" [bold red]✘[/bold red] Unexpected error please check babylon logs file for details") | ||
| logger.debug(f" [bold red]✘[/bold red] {e}") | ||
|
|
||
| # --- Workspace Secret & CoAL ConfigMap --- | ||
| organization_id = api_section["organization_id"] | ||
| writer_username = api_config.get("writer-username", "") | ||
| writer_password = api_config.get("writer-password", "") | ||
| db_name = api_config.get("database-name", "") | ||
|
|
||
| logger.info(f" [dim]→ Creating workspace secret for [cyan]{workspace_id}[/cyan]...[/dim]") | ||
| create_workspace_secret( | ||
| namespace=env.environ_id, | ||
| organization_id=organization_id, | ||
| workspace_id=workspace_id, | ||
| writer_password=writer_password, | ||
| ) | ||
|
|
||
| logger.info(f" [dim]→ Creating CoAL ConfigMap for [cyan]{workspace_id}[/cyan]...[/dim]") | ||
| create_coal_configmap( | ||
| namespace=env.environ_id, | ||
| organization_id=organization_id, | ||
| workspace_id=workspace_id, | ||
| db_host=db_host, | ||
| db_port="5432", | ||
| db_name=db_name, | ||
| schema_name=schema_name, | ||
| writer_username=writer_username, | ||
| ) | ||
|
MohcineTor marked this conversation as resolved.
|
||
|
|
||
| # --- State Persistence --- | ||
| # Ensure the local and remote states are synchronized after successful API calls | ||
| env.store_state_in_local(state) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| VERSION = "5.0.0" | ||
| VERSION = "5.1.0" | ||
|
|
||
|
|
||
| def get_version(): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.