diff --git a/src/managers/k8s.py b/src/managers/k8s.py index 3d07c4e2..f89fa12f 100644 --- a/src/managers/k8s.py +++ b/src/managers/k8s.py @@ -42,7 +42,7 @@ def apply_service(self, service: Service) -> None: if e.status.code == 403: logger.error("Could not apply service, application needs `juju trust`") return - if e.status.code == 422 and "port is already allocated" in e.status.message: + if e.status.code == 422 and "port is already allocated" in str(e.status.message): logger.error(e.status.message) return else: @@ -190,7 +190,7 @@ def get_nodeport(self, auth: Literal["plain", "tls"]) -> int: raise Exception("Could not find Service spec or ports") for port in service.spec.ports: - if str(port.name).endswith(auth): + if str(port.name).endswith(auth) and isinstance(port.nodePort, int): return port.nodePort raise Exception(f"Unable to find NodePort using {auth} for the {service} service")