Skip to content

Commit

Permalink
Merge pull request #556 from gefyrahq/fix-dns-name
Browse files Browse the repository at this point in the history
fix: dns_search as list
  • Loading branch information
SteinRobert committed Mar 6, 2024
2 parents 4ff7cc1 + 402b8ea commit e4789dd
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-tester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ jobs:
poetry run coveralls --service=github
- uses: actions/upload-artifact@v4
with:
name: coverage_data
name: coverage_data-${{ matrix.os }}
path: ./client/.coverage*

test:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/python/black.git
rev: 23.3.0
rev: 24.1.1
hooks:
- id: black
language_version: python3

# flake8 - style guide enforcement
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
args: [--max-line-length=120]
Expand Down
2 changes: 1 addition & 1 deletion client/gefyra/api/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def delete_client(
config = ClientConfiguration(
kube_config_file=kubeconfig,
kube_context=kubecontext,
connection_name=connection_name if connection_name else "no-connection-name"
connection_name=connection_name if connection_name else "no-connection-name",
# use no-connection-name to make sure you use admin access to the cluster
)
return handle_delete_gefyraclient(config, client_id, force, wait=wait)
Expand Down
4 changes: 3 additions & 1 deletion client/gefyra/api/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def run(
else:
ns_source = "--namespace argument"

dns_search = f"{namespace}.svc.cluster.local svc.cluster.local cluster.local k8s"
dns_search = (
f"{namespace}.svc.cluster.local svc.cluster.local cluster.local k8s".split(" ")
)
#
# Confirm the wireguard connection working
#
Expand Down
2 changes: 1 addition & 1 deletion client/gefyra/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
toc = time.perf_counter()
logger.debug(
f"Operation time for '{func.__name__}(...)' was {(toc - tic)*1000:0.4f}ms"
f"Operation time for '{func.__name__}(...)' was {(toc - tic) * 1000:0.4f}ms"
)
return result

Expand Down
4 changes: 2 additions & 2 deletions client/gefyra/cli/updown.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def cluster_up(ctx, minikube: Optional[str] = None, preset: Optional[str] = None
else:
raise ClientConfigurationError(
f"Could not set up the client '{client_id}'. This is most probably a problem of Gefyra operator. \n"
f"Try running 'gefyra up{' --preset '+preset if preset else ''}' again after some time."
f"Try running 'gefyra up{' --preset ' + preset if preset else ''}' again after some time."
)

# create a temporary file with the client config
Expand All @@ -163,7 +163,7 @@ def cluster_up(ctx, minikube: Optional[str] = None, preset: Optional[str] = None
f"Gefyra could not successfully establish the connection to '{config.CARGO_ENDPOINT.split(':')[0]}'.\n"
"If you have run 'gefyra up' with a remote cluster, a newly created route may not be working "
"immediately.\n"
f"Try running 'gefyra up{' --preset '+preset if preset else ''}' again after some time. "
f"Try running 'gefyra up{' --preset ' + preset if preset else ''}' again after some time. "
f"Error: {e}"
) from None
fh.close()
Expand Down
2 changes: 1 addition & 1 deletion client/gefyra/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def format_commands(self, ctx, formatter) -> None:
alias = ",".join(acmd.alias)
else:
alias = None
commands.append((f"{subcommand} {'('+alias+')' if alias else ''}", cmd))
commands.append((f"{subcommand} {'(' + alias + ')' if alias else ''}", cmd))

# allow for 3 times the default spacing
if len(commands):
Expand Down
11 changes: 7 additions & 4 deletions client/gefyra/local/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def handle_create_gefyrabridge(config: ClientConfiguration, body, target: str):
if e.status == 409:
raise RuntimeError(f"Workload {target} already bridged.")
logger.error(
f"A Kubernetes API Error occured. \nReason:{e.reason} \nBody:{e.body}"
f"A Kubernetes API Error occured. \nReason: {e.reason} \nBody: {e.body}"
)
raise e from None
return ireq
Expand Down Expand Up @@ -139,10 +139,13 @@ def deploy_app_container(
ports: Optional[Dict] = None,
env: Optional[Dict] = None,
auto_remove: bool = False,
dns_search: str = "default",
dns_search: Optional[List[str]] = None,
) -> Container:
import docker

if not dns_search:
dns_search = ["default"]

gefyra_net = config.DOCKER.networks.get(f"{config.NETWORK_NAME}")

net_add = gefyra_net.attrs["IPAM"]["Config"][0]["Subnet"].split("/")[0]
Expand All @@ -155,10 +158,10 @@ def deploy_app_container(
"ports": ports,
"detach": True,
"dns": [config.STOWAWAY_IP],
"dns_search": [dns_search],
"dns_search": dns_search,
"auto_remove": auto_remove,
"environment": env,
"pid_mode": f"container:{config.CARGO_CONTAINER_NAME}",
"pid_mode": f"container:{config.CARGO_CONTAINER_NAME}", # noqa: E231
}
not_none_kwargs = {k: v for k, v in all_kwargs.items() if v is not None}

Expand Down
48 changes: 24 additions & 24 deletions client/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ click = "^8.1.3"

[tool.poetry.group.dev.dependencies]
flake8-bugbear = ">=23.3.12,<25.0.0"
black = "^23.1.0"
flake8 = ">=6,<8"
black = "^24.2.0"
flake8 = "^7.0.0"
flake8-black = "^0.3.6"
pytest = "^7.2.2"
coverage = {extras = ["toml"], version = "^6.5.0"}
Expand Down
6 changes: 3 additions & 3 deletions client/tests/e2e/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,9 @@ def test_c_run_gefyra_bridge_with_container_with_command(self):
run(**run_params)
with self.assertRaises(RuntimeError) as rte:
bridge_params = self.default_bridge_params
bridge_params[
"target"
] = "deployment/hello-nginxdemo-command/hello-nginx-command"
bridge_params["target"] = (
"deployment/hello-nginxdemo-command/hello-nginx-command"
)
bridge_params["namespace"] = "commands"
bridge(**bridge_params)
self.assertIn("Cannot bridge pod", str(rte.exception))
Expand Down

0 comments on commit e4789dd

Please sign in to comment.