From 08a11ad2c309b5707973190373d04cb76be1b2d1 Mon Sep 17 00:00:00 2001 From: Wim Van Deun Date: Fri, 16 Aug 2024 09:16:52 +0200 Subject: [PATCH 01/16] Fixes SDK upsert mutations not including HFID (#4119) --- python_sdk/infrahub_sdk/node.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python_sdk/infrahub_sdk/node.py b/python_sdk/infrahub_sdk/node.py index 79b27eb70e..8b7c8d5f86 100644 --- a/python_sdk/infrahub_sdk/node.py +++ b/python_sdk/infrahub_sdk/node.py @@ -1325,13 +1325,14 @@ async def _process_mutation_result(self, mutation_name: str, response: dict[str, setattr(self, rel_name, related_node) async def create(self, allow_upsert: bool = False) -> None: - input_data = self._generate_input_data(exclude_hfid=True) mutation_query = self._generate_mutation_query() if allow_upsert: + input_data = self._generate_input_data(exclude_hfid=False) mutation_name = f"{self._schema.kind}Upsert" tracker = f"mutation-{str(self._schema.kind).lower()}-upsert" else: + input_data = self._generate_input_data(exclude_hfid=True) mutation_name = f"{self._schema.kind}Create" tracker = f"mutation-{str(self._schema.kind).lower()}-create" query = Mutation( @@ -1785,13 +1786,14 @@ def _process_mutation_result(self, mutation_name: str, response: dict[str, Any]) setattr(self, rel_name, related_node) def create(self, allow_upsert: bool = False) -> None: - input_data = self._generate_input_data(exclude_hfid=True) mutation_query = self._generate_mutation_query() if allow_upsert: + input_data = self._generate_input_data(exclude_hfid=False) mutation_name = f"{self._schema.kind}Upsert" tracker = f"mutation-{str(self._schema.kind).lower()}-upsert" else: + input_data = self._generate_input_data(exclude_hfid=True) mutation_name = f"{self._schema.kind}Create" tracker = f"mutation-{str(self._schema.kind).lower()}-create" query = Mutation( From aae9ced8fc76eb3d523317a74d1437ff1504fc62 Mon Sep 17 00:00:00 2001 From: wvandeun Date: Mon, 19 Aug 2024 12:01:45 +0200 Subject: [PATCH 02/16] bump Python SDK to 0.12.4 --- poetry.lock | 2 +- python_sdk/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index 4e05348646..fc03543a6e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1774,7 +1774,7 @@ testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs [[package]] name = "infrahub-sdk" -version = "0.12.2" +version = "0.12.4" description = "Python Client to interact with Infrahub" optional = false python-versions = "^3.9" diff --git a/python_sdk/pyproject.toml b/python_sdk/pyproject.toml index e379251868..ada2e44b46 100644 --- a/python_sdk/pyproject.toml +++ b/python_sdk/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "infrahub-sdk" -version = "0.12.3" +version = "0.12.4" description = "Python Client to interact with Infrahub" authors = ["OpsMill "] readme = "README.md" From d1d3f94a7b1fb0e51f36c97bb8779b74631f7c8f Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Mon, 19 Aug 2024 17:01:19 +0200 Subject: [PATCH 03/16] feat(codespaces): ensure demo data is included in prebuilt Signed-off-by: Fatih Acar --- .devcontainer/demo-container/devcontainer.json | 2 +- .devcontainer/{postStartCommand.sh => updateContentCommand.sh} | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename .devcontainer/{postStartCommand.sh => updateContentCommand.sh} (61%) diff --git a/.devcontainer/demo-container/devcontainer.json b/.devcontainer/demo-container/devcontainer.json index 3612fcb565..f3d37df687 100644 --- a/.devcontainer/demo-container/devcontainer.json +++ b/.devcontainer/demo-container/devcontainer.json @@ -39,7 +39,7 @@ ], "onCreateCommand": "./.devcontainer/onCreateCommand.sh", "postCreateCommand": "./.devcontainer/postCreateCommand.sh", - "postStartCommand": "./.devcontainer/postStartCommand.sh", + "updateContentCommand": "./.devcontainer/updateContentCommand.sh", "postAttachCommand": "./.devcontainer/postAttachCommand.sh", "features": { "docker-in-docker": "latest", diff --git a/.devcontainer/postStartCommand.sh b/.devcontainer/updateContentCommand.sh similarity index 61% rename from .devcontainer/postStartCommand.sh rename to .devcontainer/updateContentCommand.sh index c4ef87bb65..fb25901cb9 100755 --- a/.devcontainer/postStartCommand.sh +++ b/.devcontainer/updateContentCommand.sh @@ -1,4 +1,6 @@ #!/bin/bash +invoke demo.build demo.start sleep 30 invoke demo.load-infra-schema demo.load-infra-data +invoke demo.stop \ No newline at end of file From 3585efcf5200daaf6bac27efecbf9c2d4b84ac60 Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Mon, 19 Aug 2024 20:24:24 +0200 Subject: [PATCH 04/16] fix(tasks): copy lists before append This should fix issues where docker compose restarts service due to duplicate appends when chaining invoke commands like: invoke demo.build demo.start Signed-off-by: Fatih Acar --- tasks/shared.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tasks/shared.py b/tasks/shared.py index d092545a06..50386581a1 100644 --- a/tasks/shared.py +++ b/tasks/shared.py @@ -220,9 +220,9 @@ def build_compose_files_cmd(database: str, namespace: str = "") -> str: sys.exit(f"{database} is not a valid database ({SUPPORTED_DATABASES})") if database == DatabaseType.MEMGRAPH.value: - COMPOSE_FILES = COMPOSE_FILES_MEMGRAPH + COMPOSE_FILES = COMPOSE_FILES_MEMGRAPH.copy() elif database == DatabaseType.NEO4J.value: - COMPOSE_FILES = COMPOSE_FILES_NEO4J + COMPOSE_FILES = COMPOSE_FILES_NEO4J.copy() if os.path.exists(OVERRIDE_FILE_NAME): print("!! Found an override file for docker-compose !!") @@ -244,9 +244,9 @@ def build_dev_compose_files_cmd(database: str) -> str: sys.exit(f"{database} is not a valid database ({SUPPORTED_DATABASES})") if database == DatabaseType.MEMGRAPH.value: - DEV_COMPOSE_FILES = DEV_COMPOSE_FILES_MEMGRAPH + DEV_COMPOSE_FILES = DEV_COMPOSE_FILES_MEMGRAPH.copy() elif database == DatabaseType.NEO4J.value: - DEV_COMPOSE_FILES = DEV_COMPOSE_FILES_NEO4J + DEV_COMPOSE_FILES = DEV_COMPOSE_FILES_NEO4J.copy() if os.path.exists(DEV_OVERRIDE_FILE_NAME): print("!! Found a dev override file for docker-compose !!") @@ -265,9 +265,9 @@ def build_test_compose_files_cmd( sys.exit(f"{database} is not a valid database ({SUPPORTED_DATABASES})") if database == DatabaseType.MEMGRAPH.value: - DEV_COMPOSE_FILES = TEST_COMPOSE_FILES_MEMGRAPH + DEV_COMPOSE_FILES = TEST_COMPOSE_FILES_MEMGRAPH.copy() elif database == DatabaseType.NEO4J.value: - DEV_COMPOSE_FILES = TEST_COMPOSE_FILES_NEO4J + DEV_COMPOSE_FILES = TEST_COMPOSE_FILES_NEO4J.copy() # if os.path.exists(DEV_OVERRIDE_FILE_NAME): # print("!! Found a dev override file for docker-compose !!") @@ -283,9 +283,9 @@ def build_test_scale_compose_files_cmd( sys.exit(f"{database} is not a valid database ({SUPPORTED_DATABASES})") if database == DatabaseType.MEMGRAPH.value: - TEST_SCALE_COMPOSE_FILES = TEST_SCALE_COMPOSE_FILES_MEMGRAPH + TEST_SCALE_COMPOSE_FILES = TEST_SCALE_COMPOSE_FILES_MEMGRAPH.copy() elif database == DatabaseType.NEO4J.value: - TEST_SCALE_COMPOSE_FILES = TEST_SCALE_COMPOSE_FILES_NEO4J + TEST_SCALE_COMPOSE_FILES = TEST_SCALE_COMPOSE_FILES_NEO4J.copy() if os.path.exists(TEST_SCALE_OVERRIDE_FILE_NAME): print("!! Found a test scale override file for docker-compose !!") From b07b8bc30becfc0828ccce4468e4c5927a5b380f Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Mon, 19 Aug 2024 21:10:13 +0200 Subject: [PATCH 05/16] fix(docker): make gunicorn workers dynamically configurable Make use of the WEB_CONCURRENCY env var as documented here: https://docs.gunicorn.org/en/stable/settings.html#workers Signed-off-by: Fatih Acar --- development/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/docker-compose.yml b/development/docker-compose.yml index a88a31620e..4f311c59c6 100644 --- a/development/docker-compose.yml +++ b/development/docker-compose.yml @@ -103,7 +103,7 @@ services: image: "${IMAGE_NAME}:${IMAGE_VER}" pull_policy: always command: > - gunicorn --config backend/infrahub/serve/gunicorn_config.py --logger-class infrahub.serve.log.GunicornLogger infrahub.server:app + gunicorn --config backend/infrahub/serve/gunicorn_config.py -w ${WEB_CONCURRENCY:-4} --logger-class infrahub.serve.log.GunicornLogger infrahub.server:app depends_on: database: condition: service_healthy From 077234037e207dbef73d34df3d399e1e862ad851 Mon Sep 17 00:00:00 2001 From: Benoit Kohler Date: Tue, 20 Aug 2024 13:20:28 +0200 Subject: [PATCH 06/16] Fixes SDK error on save after include (#4123) (#4142) * proposal fix for 4116 --- python_sdk/infrahub_sdk/node.py | 4 +-- python_sdk/tests/unit/sdk/test_node.py | 45 ++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/python_sdk/infrahub_sdk/node.py b/python_sdk/infrahub_sdk/node.py index 8b7c8d5f86..510453cd0f 100644 --- a/python_sdk/infrahub_sdk/node.py +++ b/python_sdk/infrahub_sdk/node.py @@ -479,7 +479,7 @@ def __init__( super().__init__(name=name, schema=schema, branch=branch) self.initialized = data is not None - self._has_update = data is not None + self._has_update = False if data is None: return @@ -574,7 +574,7 @@ def __init__( super().__init__(name=name, schema=schema, branch=branch) self.initialized = data is not None - self._has_update = data is not None + self._has_update = False if data is None: return diff --git a/python_sdk/tests/unit/sdk/test_node.py b/python_sdk/tests/unit/sdk/test_node.py index e0de21a3e4..5749052d2e 100644 --- a/python_sdk/tests/unit/sdk/test_node.py +++ b/python_sdk/tests/unit/sdk/test_node.py @@ -1073,7 +1073,9 @@ async def test_create_input_data_with_relationships_03(clients, rfile_schema, cl @pytest.mark.parametrize("client_type", client_types) -async def test_create_input_data_with_relationships_03_for_update(clients, rfile_schema, client_type): +async def test_create_input_data_with_relationships_03_for_update_include_unmodified( + clients, rfile_schema, client_type +): data = { "name": {"value": "rfile01", "is_protected": True, "source": "ffffffff"}, "template_path": {"value": "mytemplate.j2"}, @@ -1088,8 +1090,13 @@ async def test_create_input_data_with_relationships_03_for_update(clients, rfile node = InfrahubNodeSync(client=clients.sync, schema=rfile_schema, data=data) node.template_path.value = "my-changed-template.j2" - assert node._generate_input_data(exclude_unmodified=True)["data"] == { + assert node._generate_input_data(exclude_unmodified=False)["data"] == { "data": { + "name": { + "is_protected": True, + "source": "ffffffff", + "value": "rfile01", + }, "query": { "id": "qqqqqqqq", "_relation__is_protected": True, @@ -1103,6 +1110,38 @@ async def test_create_input_data_with_relationships_03_for_update(clients, rfile } +@pytest.mark.parametrize("client_type", client_types) +async def test_create_input_data_with_relationships_03_for_update_exclude_unmodified( + clients, rfile_schema, client_type +): + data = { + "name": {"value": "rfile01", "is_protected": True, "source": "ffffffff"}, + "template_path": {"value": "mytemplate.j2"}, + "query": {"id": "qqqqqqqq", "source": "ffffffff", "owner": "ffffffff", "is_protected": True}, + "repository": {"id": "rrrrrrrr", "source": "ffffffff", "owner": "ffffffff"}, + "tags": [{"id": "t1t1t1t1"}, "t2t2t2t2"], + } + + if client_type == "standard": + node = InfrahubNode(client=clients.standard, schema=rfile_schema, data=data) + else: + node = InfrahubNodeSync(client=clients.sync, schema=rfile_schema, data=data) + + node.template_path.value = "my-changed-template.j2" + assert node._generate_input_data(exclude_unmodified=True)["data"] == { + "data": { + "query": { + "id": "qqqqqqqq", + "_relation__is_protected": True, + "_relation__owner": "ffffffff", + "_relation__source": "ffffffff", + }, + "template_path": {"value": "my-changed-template.j2"}, + "repository": {"id": "rrrrrrrr", "_relation__owner": "ffffffff", "_relation__source": "ffffffff"}, + } + } + + @pytest.mark.parametrize("client_type", client_types) async def test_create_input_data_with_IPHost_attribute(client, ipaddress_schema, client_type): data = {"address": {"value": ipaddress.ip_interface("1.1.1.1/24"), "is_protected": True}} @@ -1426,7 +1465,7 @@ async def test_relationships_excluded_input_data(client, location_schema, client else: node = InfrahubNodeSync(client=client, schema=location_schema, data=data) - assert node.tags.has_update is True + assert node.tags.has_update is False @pytest.mark.parametrize("client_type", client_types) From 7d6cfc6433b4f05f6ace1f9ab73c058237a8551a Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Mon, 19 Aug 2024 19:09:20 +0200 Subject: [PATCH 07/16] fix(codespaces): use two worker when prebuilding Prebuild jobs run with 2 vCPUs (show cpuinfo at startup). Sleep for 2 minutes because starting infrahub takes at least 90s. Schema loading also takes 90s. Set username of rabbitmq docker compose to prevent EACCES error on codespaces startup. Signed-off-by: Fatih Acar --- .devcontainer/onCreateCommand.sh | 2 ++ .devcontainer/postCreateCommand.sh | 2 +- .devcontainer/updateContentCommand.sh | 12 +++++++++--- development/docker-compose-deps.yml | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.devcontainer/onCreateCommand.sh b/.devcontainer/onCreateCommand.sh index 6ef50647de..9230860631 100755 --- a/.devcontainer/onCreateCommand.sh +++ b/.devcontainer/onCreateCommand.sh @@ -1,5 +1,7 @@ #!/bin/bash +cat /proc/cpuinfo /proc/meminfo + poetry config virtualenvs.create true poetry config virtualenvs.in-project true poetry install --no-interaction --no-ansi diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 29ccdd6a38..d058c7246f 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -1,4 +1,4 @@ #!/bin/bash git pull -invoke demo.build demo.start \ No newline at end of file +invoke demo.start \ No newline at end of file diff --git a/.devcontainer/updateContentCommand.sh b/.devcontainer/updateContentCommand.sh index fb25901cb9..4be12810ac 100755 --- a/.devcontainer/updateContentCommand.sh +++ b/.devcontainer/updateContentCommand.sh @@ -1,6 +1,12 @@ #!/bin/bash +export WEB_CONCURRENCY=2 invoke demo.build demo.start -sleep 30 -invoke demo.load-infra-schema demo.load-infra-data -invoke demo.stop \ No newline at end of file +sleep 120 +docker logs infrahub-infrahub-server-1 +invoke demo.load-infra-schema +docker logs infrahub-infrahub-server-1 +sleep 90 +docker logs infrahub-infrahub-server-1 +invoke demo.load-infra-data +invoke demo.stop diff --git a/development/docker-compose-deps.yml b/development/docker-compose-deps.yml index dffd8ab7fb..03b0c6a7e9 100644 --- a/development/docker-compose-deps.yml +++ b/development/docker-compose-deps.yml @@ -1,6 +1,7 @@ --- services: message-queue: + user: rabbitmq image: "${MESSAGE_QUEUE_DOCKER_IMAGE:-rabbitmq:latest}" environment: - "RABBITMQ_DEFAULT_USER=infrahub" From 853cca4fc741c34795995c27234f8102601cf9c9 Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Tue, 20 Aug 2024 14:00:52 +0200 Subject: [PATCH 08/16] fix(docker): increase rabbitmq number of healthcheck retries RabbitMQ can take up to 40 seconds to start on GitHub Codespaces. Signed-off-by: Fatih Acar --- development/docker-compose-deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/docker-compose-deps.yml b/development/docker-compose-deps.yml index 03b0c6a7e9..00ed88f1ec 100644 --- a/development/docker-compose-deps.yml +++ b/development/docker-compose-deps.yml @@ -10,7 +10,7 @@ services: test: rabbitmq-diagnostics -q check_port_connectivity interval: 5s timeout: 30s - retries: 5 + retries: 10 start_period: 3s cache: image: "${CACHE_DOCKER_IMAGE:-redis:latest}" From ce9e939c903fdd969b877e9703f09b1735e1b0bb Mon Sep 17 00:00:00 2001 From: wvandeun Date: Fri, 23 Aug 2024 17:27:21 +0200 Subject: [PATCH 09/16] change git clone command in installation guide to use https --- docs/docs/guides/installation.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/guides/installation.mdx b/docs/docs/guides/installation.mdx index 332537f252..df4e792c29 100644 --- a/docs/docs/guides/installation.mdx +++ b/docs/docs/guides/installation.mdx @@ -63,7 +63,7 @@ cd ~/source/infrahub/ Next, clone the `stable` branch of the Infrahub GitHub repository into the current directory. (This branch always holds the current stable release) ```bash -git clone -b stable --depth 1 git@github.com:opsmill/infrahub.git . +git clone -b stable --depth 1 https://github.com/opsmill/infrahub.git ``` :::note From 090d2f264de1feb4d22e0109944543416142564e Mon Sep 17 00:00:00 2001 From: wvandeun Date: Sat, 24 Aug 2024 09:04:53 +0200 Subject: [PATCH 10/16] fix schema topic in documentation --- docs/docs/topics/schema.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/topics/schema.mdx b/docs/docs/topics/schema.mdx index 71238cdcc5..234458dde3 100644 --- a/docs/docs/topics/schema.mdx +++ b/docs/docs/topics/schema.mdx @@ -185,8 +185,8 @@ Having a human friendly way to identify an object is very important to build rob In the network industry: -- the `hfid` of a device will be could be its `name` : `atl1-edge01` -- the `hfid` of an interface will be the combination of the name of the device and the name of the interface: (`atl1-edge01`, `Ethernet1`) +- the `hfid` of a device could be its `name` : `atl1-edge01` +- the `hfid` of an interface could be the combination of the name of the device and the name of the interface: (`atl1-edge01`, `Ethernet1`) ::: From ff13e2421a7018205f09748c9fbc1fc7c3c53be9 Mon Sep 17 00:00:00 2001 From: wvandeun Date: Wed, 28 Aug 2024 14:15:19 +0200 Subject: [PATCH 11/16] add dropdown to attribute kinds list to the schema topic doc --- docs/docs/topics/schema.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/topics/schema.mdx b/docs/docs/topics/schema.mdx index 234458dde3..3dec675148 100644 --- a/docs/docs/topics/schema.mdx +++ b/docs/docs/topics/schema.mdx @@ -74,6 +74,7 @@ The `kind` of a model is generated by concatenating the `namespace` and the `nam - `TextArea`: Long-form Text that can span multiple lines - `Boolean`: Flag that can be either True or False - `DateTime`: A Data and a Time +- `Dropdown`: A list of choices, each choice can have a color and description - `Email`: Email address - `Password`: A Text String that should be obfuscated - `URL`: An URL to a website or a resource over HTTP From 78f172f11607580256b739caccf9a0cfb69b2446 Mon Sep 17 00:00:00 2001 From: Lucas Guillermou Date: Fri, 6 Sep 2024 18:00:44 +0200 Subject: [PATCH 12/16] Repository name cannot contain '/' character anymore --- backend/infrahub/core/schema/definitions/core.py | 1 + .../sdk/test_node_create_constraint.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/backend/infrahub/core/schema/definitions/core.py b/backend/infrahub/core/schema/definitions/core.py index 9ce5ea81c3..922fda32f1 100644 --- a/backend/infrahub/core/schema/definitions/core.py +++ b/backend/infrahub/core/schema/definitions/core.py @@ -370,6 +370,7 @@ "attributes": [ { "name": "name", + "regex": "^[^/]*$", "kind": "Text", "unique": True, "branch": BranchSupportType.AGNOSTIC.value, diff --git a/backend/tests/integration/sdk/test_node_create_constraint.py b/backend/tests/integration/sdk/test_node_create_constraint.py index 50b2c71acf..2f2e588758 100644 --- a/backend/tests/integration/sdk/test_node_create_constraint.py +++ b/backend/tests/integration/sdk/test_node_create_constraint.py @@ -1,3 +1,4 @@ +import re from typing import Any, Dict import pytest @@ -7,6 +8,7 @@ from infrahub.core import registry from infrahub.core.node import Node from infrahub.database import InfrahubDatabase +from infrahub.exceptions import ValidationError from tests.helpers.test_app import TestInfrahubApp from ..shared import load_schema @@ -287,3 +289,16 @@ async def test_step_03_add_node_failure( await new_car.save() assert "owner-nbr_seats" in exc.value.message + + async def test_create_repository_with_slash_failure(self, db: InfrahubDatabase, initial_dataset): + repo = await Node.init(schema="CoreRepository", db=db) + with pytest.raises( + ValidationError, match=re.escape("repo/name must be conform with the regex: '^[^/]*$' at name") + ): + await repo.new(db=db, name="repo/name", location="dummy", username="dummy", password="dummy") + + repo = await Node.init(schema="CoreReadOnlyRepository", db=db) + with pytest.raises( + ValidationError, match=re.escape("repo/name must be conform with the regex: '^[^/]*$' at name") + ): + await repo.new(db=db, name="repo/name", location="dummy", username="dummy", password="dummy") From 162ad1f012d5e11a3a2d4ec627162aede4b7066f Mon Sep 17 00:00:00 2001 From: fatih-acar Date: Mon, 2 Sep 2024 09:39:52 +0200 Subject: [PATCH 13/16] fix(codespaces): wait for infrahub to start (#4152) * fix(codespaces): wait for infrahub to start --- .devcontainer/postCreateCommand.sh | 2 +- tasks/container_ops.py | 7 +++---- tasks/demo.py | 4 ++-- tasks/dev.py | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index d058c7246f..125c5ead71 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -1,4 +1,4 @@ #!/bin/bash git pull -invoke demo.start \ No newline at end of file +invoke demo.start --wait \ No newline at end of file diff --git a/tasks/container_ops.py b/tasks/container_ops.py index a5ad3f1b6b..859231a1ec 100644 --- a/tasks/container_ops.py +++ b/tasks/container_ops.py @@ -77,12 +77,11 @@ def show_service_status(context: Context, database: str, namespace: str) -> None execute_command(context=context, command=command) -def start_services(context: Context, database: str, namespace: str) -> None: +def start_services(context: Context, database: str, namespace: str, wait: bool) -> None: with context.cd(ESCAPED_REPO_PATH): compose_files_cmd = build_compose_files_cmd(database=database, namespace=namespace) - command = ( - f"{get_env_vars(context, namespace=namespace)} docker compose {compose_files_cmd} -p {BUILD_NAME} up -d" - ) + should_wait = " --wait" if wait else "" + command = f"{get_env_vars(context, namespace=namespace)} docker compose {compose_files_cmd} -p {BUILD_NAME} up -d{should_wait}" execute_command(context=context, command=command) diff --git a/tasks/demo.py b/tasks/demo.py index 9a4b9b40f9..94231b2337 100644 --- a/tasks/demo.py +++ b/tasks/demo.py @@ -62,9 +62,9 @@ def pull(context: Context, database: str = INFRAHUB_DATABASE): @task(optional=["database"]) -def start(context: Context, database: str = INFRAHUB_DATABASE): +def start(context: Context, database: str = INFRAHUB_DATABASE, wait: bool = False): """Start a local instance of Infrahub within docker compose.""" - start_services(context=context, database=database, namespace=NAMESPACE) + start_services(context=context, database=database, namespace=NAMESPACE, wait=wait) @task(optional=["database"]) diff --git a/tasks/dev.py b/tasks/dev.py index d9332618db..94f76b94af 100644 --- a/tasks/dev.py +++ b/tasks/dev.py @@ -157,9 +157,9 @@ def status(context: Context, database: str = INFRAHUB_DATABASE): @task(optional=["database"]) -def start(context: Context, database: str = INFRAHUB_DATABASE): +def start(context: Context, database: str = INFRAHUB_DATABASE, wait: bool = False): """Start a local instance of Infrahub within docker compose.""" - start_services(context=context, database=database, namespace=NAMESPACE) + start_services(context=context, database=database, namespace=NAMESPACE, wait=wait) @task(optional=["database"]) From ec78cc8066b97730b0d7151db07118bf9f1f95cf Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Tue, 10 Sep 2024 15:41:52 +0200 Subject: [PATCH 14/16] fix(codespaces): increase healthcheck retries for database DB can be slow to start on a 4 cpu core config. Signed-off-by: Fatih Acar --- development/docker-compose-database-neo4j.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/docker-compose-database-neo4j.yml b/development/docker-compose-database-neo4j.yml index 6cd0ba8729..e0ab7e00eb 100644 --- a/development/docker-compose-database-neo4j.yml +++ b/development/docker-compose-database-neo4j.yml @@ -19,7 +19,7 @@ services: test: wget http://localhost:7474 || exit 1 interval: 2s timeout: 10s - retries: 20 + retries: 40 start_period: 3s labels: infrahub_role: "database" From 49fcc64d25dc9fb59a1767d6201d39f1d8159f20 Mon Sep 17 00:00:00 2001 From: Damien Garros Date: Tue, 10 Sep 2024 17:18:06 +0200 Subject: [PATCH 15/16] Set SDK version to 0.13 and update lock file --- poetry.lock | 2 +- python_sdk/poetry.lock | 1 - python_sdk/pyproject.toml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index a39b74841d..f7c7e98b8a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1762,7 +1762,7 @@ testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs [[package]] name = "infrahub-sdk" -version = "0.13.0b1" +version = "0.13.0" description = "Python Client to interact with Infrahub" optional = false python-versions = "^3.9" diff --git a/python_sdk/poetry.lock b/python_sdk/poetry.lock index bfdb01c91d..31bfcfa40c 100644 --- a/python_sdk/poetry.lock +++ b/python_sdk/poetry.lock @@ -1510,7 +1510,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, diff --git a/python_sdk/pyproject.toml b/python_sdk/pyproject.toml index 948ba1c358..b930cf67bf 100644 --- a/python_sdk/pyproject.toml +++ b/python_sdk/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "infrahub-sdk" -version = "0.13.0b1" +version = "0.13.0" description = "Python Client to interact with Infrahub" authors = ["OpsMill "] readme = "README.md" From ac1e9c10e86ad4122d47d8962a19b021aadc595c Mon Sep 17 00:00:00 2001 From: Damien Garros Date: Tue, 10 Sep 2024 21:09:48 +0200 Subject: [PATCH 16/16] Update test_create_repository_with_slash_failure --- backend/tests/integration/sdk/test_node_create_constraint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/tests/integration/sdk/test_node_create_constraint.py b/backend/tests/integration/sdk/test_node_create_constraint.py index 2f2e588758..e04b0b9711 100644 --- a/backend/tests/integration/sdk/test_node_create_constraint.py +++ b/backend/tests/integration/sdk/test_node_create_constraint.py @@ -295,10 +295,10 @@ async def test_create_repository_with_slash_failure(self, db: InfrahubDatabase, with pytest.raises( ValidationError, match=re.escape("repo/name must be conform with the regex: '^[^/]*$' at name") ): - await repo.new(db=db, name="repo/name", location="dummy", username="dummy", password="dummy") + await repo.new(db=db, name="repo/name", location="dummy") repo = await Node.init(schema="CoreReadOnlyRepository", db=db) with pytest.raises( ValidationError, match=re.escape("repo/name must be conform with the regex: '^[^/]*$' at name") ): - await repo.new(db=db, name="repo/name", location="dummy", username="dummy", password="dummy") + await repo.new(db=db, name="repo/name", location="dummy")