Skip to content
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

refactor: Tune log levels #1867

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions backend/capellacollab/core/authentication/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@
return self.web_client.parse_request_body_response(
r.text, scope=self.oidc_config.get_scopes()
)
except Exception as e:
logger.debug(
"Could not refresh token because of exception %s", str(e)
)
except Exception:
logger.info("Could not refresh token", exc_info=True)

Check warning on line 150 in backend/capellacollab/core/authentication/oidc.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/core/authentication/oidc.py#L149-L150

Added lines #L149 - L150 were not covered by tests
raise exceptions.RefreshTokenSignatureExpired()
2 changes: 1 addition & 1 deletion backend/capellacollab/sessions/injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
if sid == session["metric"]["session_id"]:
return _get_last_seen(float(session["value"][1]))

log.error("No session was found.")
log.debug("Couldn't find Prometheus metrics for session %s.", sid)

Check warning on line 34 in backend/capellacollab/sessions/injection.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/injection.py#L34

Added line #L34 was not covered by tests
except Exception:
log.exception("Exception during fetching of last seen.")
return "UNKNOWN"
Expand Down
63 changes: 40 additions & 23 deletions backend/capellacollab/sessions/operators/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,25 @@
self.v1_batch.delete_namespaced_cron_job(
namespace=namespace, name=_id
)
except exceptions.ApiException:
log.exception("Error deleting cronjob with name: %s", _id)
except exceptions.ApiException as e:

Check warning on line 339 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L339

Added line #L339 was not covered by tests
# Cronjob doesn't exist or was already deleted
# Nothing to do
if e.status == http.HTTPStatus.NOT_FOUND:
return
raise

Check warning on line 344 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L343-L344

Added lines #L343 - L344 were not covered by tests

def delete_job(self, name: str):
log.info("Deleting job '%s' in cluster", name)
try:
self.v1_batch.delete_namespaced_job(
namespace=namespace, name=name, propagation_policy="Background"
)
except exceptions.ApiException:
log.error("Error deleting job with name: %s", name)
except exceptions.ApiException as e:

Check warning on line 352 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L352

Added line #L352 was not covered by tests
# Job doesn't exist or was already deleted
# Nothing to do
if e.status == http.HTTPStatus.NOT_FOUND:
return
raise

Check warning on line 357 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L356-L357

Added lines #L356 - L357 were not covered by tests

def get_pod_name_from_job_name(self, job_name: str) -> str | None:
return self._get_pod_id(label_selector=f"job-name={job_name}")
Expand Down Expand Up @@ -893,45 +901,54 @@
def _delete_deployment(self, name: str) -> client.V1Status | None:
try:
return self.v1_apps.delete_namespaced_deployment(name, namespace)
except exceptions.ApiException:
log.exception("Error deleting deployment with name: %s", name)
return None
except exceptions.ApiException as e:

Check warning on line 904 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L904

Added line #L904 was not covered by tests
# Deployment doesn't exist or was already deleted
# Nothing to do
if e.status == http.HTTPStatus.NOT_FOUND:
return None
raise

Check warning on line 909 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L908-L909

Added lines #L908 - L909 were not covered by tests

def delete_secret(self, name: str) -> kubernetes.client.V1Status | None:
try:
return self.v1_core.delete_namespaced_secret(name, namespace)
except client.exceptions.ApiException:
log.exception("Error deleting secret with name: %s", name)
return None
except exceptions.ApiException as e:

Check warning on line 914 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L914

Added line #L914 was not covered by tests
# Secret doesn't exist or was already deleted
# Nothing to do
if e.status == http.HTTPStatus.NOT_FOUND:
return None
raise

Check warning on line 919 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L918-L919

Added lines #L918 - L919 were not covered by tests

def _delete_config_map(self, name: str) -> client.V1Status | None:
try:
return self.v1_core.delete_namespaced_config_map(name, namespace)
except exceptions.ApiException:
log.exception("Error deleting config map with name: %s", name)
return None
except exceptions.ApiException as e:

Check warning on line 924 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L924

Added line #L924 was not covered by tests
# Config map doesn't exist or was already deleted
# Nothing to do
if e.status == http.HTTPStatus.NOT_FOUND:
return None
raise

Check warning on line 929 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L928-L929

Added lines #L928 - L929 were not covered by tests

def _delete_service(self, name: str) -> client.V1Status | None:
try:
return self.v1_core.delete_namespaced_service(name, namespace)
except exceptions.ApiException:
log.exception("Error deleting service with name: %s", name)
return None
except exceptions.ApiException as e:

Check warning on line 934 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L934

Added line #L934 was not covered by tests
# Service doesn't exist or was already deleted
# Nothing to do
if e.status == http.HTTPStatus.NOT_FOUND:
return None
raise

Check warning on line 939 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L938-L939

Added lines #L938 - L939 were not covered by tests

def _delete_disruptionbudget(self, name: str) -> client.V1Status | None:
try:
return self.v1_policy.delete_namespaced_pod_disruption_budget(
name, namespace
)
except exceptions.ApiException as e:
# Pod disruption budge doesn't exist or was already deleted
# Pod disruption budget doesn't exist or was already deleted
# Nothing to do
if not e.status == http.HTTPStatus.NOT_FOUND:
log.exception(
"Error deleting discruptionbudget with name: %s", name
)

return None
if e.status == http.HTTPStatus.NOT_FOUND:
return None
raise

Check warning on line 951 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L951

Added line #L951 was not covered by tests

def _get_pod_name(self, _id: str) -> str:
return self.get_pods(label_selector=f"app={_id}")[0].metadata.name
Expand Down
Loading