-
Notifications
You must be signed in to change notification settings - Fork 1
feat: enable toggling of hub log forwarding #41
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
Changes from all commits
af903e9
2b0a2e5
9490afc
06b8b4c
cb498f4
dfcd7ea
8454b5c
c9b56a8
b0a37ca
8bf79af
469690b
cbe7cb6
c224ad4
7680435
986934b
da2aaa3
6553612
51127fc
fe952d8
fb8ff62
1c4b9fc
b9ea9e2
d1d3bed
2a08146
fe3839a
5e2086e
111ce94
c265b60
7926dc8
207a2ee
ca70a95
c6760a7
73e674e
b581dce
000f999
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,12 +11,12 @@ | |||||||
|
|
||||||||
| class Database: | ||||||||
| def __init__(self) -> None: | ||||||||
| host = os.getenv("POSTGRES_HOST") | ||||||||
| host = os.getenv('POSTGRES_HOST') | ||||||||
| port = "5432" | ||||||||
| user = os.getenv("POSTGRES_USER") | ||||||||
| password = os.getenv("POSTGRES_PASSWORD") | ||||||||
| database = os.getenv("POSTGRES_DB") | ||||||||
| conn_uri = f'postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}' | ||||||||
| user = os.getenv('POSTGRES_USER') | ||||||||
| password = os.getenv('POSTGRES_PASSWORD') | ||||||||
| database = os.getenv('POSTGRES_DB') | ||||||||
| conn_uri = f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}" | ||||||||
| print(conn_uri) | ||||||||
|
Comment on lines
+19
to
20
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. Remove credential leakage from startup logs. Line 20 prints the full PostgreSQL URI, which includes secrets from Line 19 ( 🔧 Proposed fix- conn_uri = f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}"
- print(conn_uri)
+ conn_uri = f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| self.engine = create_engine(conn_uri, | ||||||||
| pool_pre_ping=True, | ||||||||
|
|
@@ -31,11 +31,11 @@ def reset_db(self) -> None: | |||||||
|
|
||||||||
| def get_deployment(self, deployment_name: str) -> Optional[AnalysisDB]: | ||||||||
| with self.SessionLocal() as session: | ||||||||
| return session.query(AnalysisDB).filter_by(**{"deployment_name": deployment_name}).first() | ||||||||
| return session.query(AnalysisDB).filter_by(**{'deployment_name': deployment_name}).first() | ||||||||
|
|
||||||||
| def get_latest_deployment(self, analysis_id: str) -> Optional[AnalysisDB]: | ||||||||
| with self.SessionLocal() as session: | ||||||||
| deployments = session.query(AnalysisDB).filter_by(**{"analysis_id": analysis_id}).all() | ||||||||
| deployments = session.query(AnalysisDB).filter_by(**{'analysis_id': analysis_id}).all() | ||||||||
| if deployments: | ||||||||
| return deployments[-1] | ||||||||
| return None | ||||||||
|
|
@@ -50,7 +50,7 @@ def analysis_is_running(self, analysis_id: str) -> bool: | |||||||
|
|
||||||||
| def get_deployments(self, analysis_id: str) -> list[AnalysisDB]: | ||||||||
| with self.SessionLocal() as session: | ||||||||
| return session.query(AnalysisDB).filter_by(**{"analysis_id": analysis_id}).all() | ||||||||
| return session.query(AnalysisDB).filter_by(**{'analysis_id': analysis_id}).all() | ||||||||
|
|
||||||||
| def create_analysis(self, | ||||||||
| analysis_id: str, | ||||||||
|
|
@@ -86,7 +86,7 @@ def create_analysis(self, | |||||||
|
|
||||||||
| def update_analysis(self, analysis_id: str, **kwargs) -> list[AnalysisDB]: | ||||||||
| with self.SessionLocal() as session: | ||||||||
| analysis = session.query(AnalysisDB).filter_by(**{"analysis_id": analysis_id}).all() | ||||||||
| analysis = session.query(AnalysisDB).filter_by(**{'analysis_id': analysis_id}).all() | ||||||||
| for deployment in analysis: | ||||||||
| if deployment: | ||||||||
| for key, value in kwargs.items(): | ||||||||
|
|
@@ -97,15 +97,15 @@ def update_analysis(self, analysis_id: str, **kwargs) -> list[AnalysisDB]: | |||||||
|
|
||||||||
| def update_deployment(self, deployment_name: str, **kwargs) -> AnalysisDB: | ||||||||
| with self.SessionLocal() as session: | ||||||||
| deployment = session.query(AnalysisDB).filter_by(**{"deployment_name": deployment_name}).first() | ||||||||
| deployment = session.query(AnalysisDB).filter_by(**{'deployment_name': deployment_name}).first() | ||||||||
| for key, value in kwargs.items(): | ||||||||
| setattr(deployment, key, value) | ||||||||
| session.commit() | ||||||||
| return deployment | ||||||||
|
|
||||||||
| def delete_analysis(self, analysis_id: str) -> None: | ||||||||
| with self.SessionLocal() as session: | ||||||||
| analysis = session.query(AnalysisDB).filter_by(**{"analysis_id": analysis_id}).all() | ||||||||
| analysis = session.query(AnalysisDB).filter_by(**{'analysis_id': analysis_id}).all() | ||||||||
| for deployment in analysis: | ||||||||
| if deployment: | ||||||||
| session.delete(deployment) | ||||||||
|
|
@@ -154,7 +154,7 @@ def update_analysis_status(self, analysis_id: str, status: str) -> None: | |||||||
| self.update_analysis(analysis_id, status=status) | ||||||||
|
|
||||||||
| def update_deployment_status(self, deployment_name: str, status: str) -> None: | ||||||||
| print(f"Updating deployment {deployment_name} to status {status}") | ||||||||
| print(f"PO ACTION - Updating deployment {deployment_name} to status {status}") | ||||||||
| self.update_deployment(deployment_name, status=status) | ||||||||
|
|
||||||||
| def stop_analysis(self, analysis_id: str) -> None: | ||||||||
|
|
@@ -164,19 +164,19 @@ def extract_analysis_body(self, analysis_id: str) -> Optional[dict]: | |||||||
| analysis = self.get_deployments(analysis_id) | ||||||||
| if analysis: | ||||||||
| analysis = analysis[0] | ||||||||
| return {"analysis_id": analysis.analysis_id, | ||||||||
| "project_id": analysis.project_id, | ||||||||
| "registry_url": analysis.registry_url, | ||||||||
| "image_url": analysis.image_url, | ||||||||
| "registry_user": analysis.registry_user, | ||||||||
| "registry_password": analysis.registry_password, | ||||||||
| "namespace": analysis.namespace, | ||||||||
| "kong_token": analysis.kong_token, | ||||||||
| "restart_counter": analysis.restart_counter} | ||||||||
| return {'analysis_id': analysis.analysis_id, | ||||||||
| 'project_id': analysis.project_id, | ||||||||
| 'registry_url': analysis.registry_url, | ||||||||
| 'image_url': analysis.image_url, | ||||||||
| 'registry_user': analysis.registry_user, | ||||||||
| 'registry_password': analysis.registry_password, | ||||||||
| 'namespace': analysis.namespace, | ||||||||
| 'kong_token': analysis.kong_token, | ||||||||
| 'restart_counter': analysis.restart_counter} | ||||||||
| return None | ||||||||
|
|
||||||||
| def delete_old_deployments_from_db(self, analysis_id: str) -> None: | ||||||||
| deployments = self.get_deployments(analysis_id) | ||||||||
| deployments = sorted(deployments, key=lambda x: x.time_created, reverse=True) | ||||||||
| for deployment in deployments[1:]: | ||||||||
| self.delete_deployment(deployment.deployment_name) | ||||||||
| self.delete_deployment(deployment.deployment_name) | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: PrivateAIM/node-pod-orchestration
Length of output: 2977
🏁 Script executed:
Repository: PrivateAIM/node-pod-orchestration
Length of output: 1863
🌐 Web query:
Kubernetes Python client ApiException e.reason 404 Not Found attribute💡 Result:
In the Kubernetes Python client,
ApiExceptionexposes these fields (set from the HTTP response):status(HTTP status code),reason(HTTP reason phrase),body(response payload), andheaders. So for a “404 Not Found” you typically gete.status == 404ande.reason == "Not Found". [1]If you need the Kubernetes “Status” object’s details (often includes
"reason": "NotFound"and"code": 404), parsee.body(it’s often JSON, sometimes bytes):Real 404 examples show
Reason: Not Foundplus a JSON body containing"reason":"NotFound"and"code":404. [2]Fix inverted exception handling across all resource deletion branches.
The condition is backwards: all non-404 errors are printed as "Error: Not Found" while actual 404s are silently ignored. This masks real deletion failures (permissions, connection errors, timeouts) that should either be re-raised or handled explicitly.
Lines affected: 86, 93, 100, 107, 114, 121 (deployment, service, pod, configmap, networkpolicy, job).
Fix pattern
🤖 Prompt for AI Agents