Skip to content

Commit 37da84b

Browse files
committed
Merge branch 'stable' into stable-to-develop
2 parents 2ad38f2 + 22f12c4 commit 37da84b

33 files changed

+1072
-46
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179

180180
- name: "Setup Python environment"
181181
run: |
182-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
182+
pipx install -f poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
183183
poetry config virtualenvs.create true --local
184184
poetry env use 3.12
185185
@@ -525,7 +525,7 @@ jobs:
525525
python-version: 3.12
526526
- name: "Setup environment"
527527
run: |
528-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
528+
pipx install -f poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
529529
poetry config virtualenvs.create true --local
530530
poetry env use 3.12
531531
pip install invoke toml
@@ -642,7 +642,7 @@ jobs:
642642
python-version: "3.12"
643643
- name: "Setup Python environment"
644644
run: |
645-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
645+
pipx install -f poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
646646
poetry config virtualenvs.create true --local
647647
poetry env use 3.12
648648
- name: "Install dependencies"

.github/workflows/poetry-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
python-version: "3.12"
2626
- name: "Setup environment"
2727
run: |
28-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
28+
pipx install -f poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
2929
- name: "Validate pyproject.toml and consistency with poetry.lock"
3030
run: |
3131
poetry check

.github/workflows/publish-dev-docker-image.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,9 @@ on:
2424
description: additional image tag
2525
default: ''
2626
required: false
27-
pull_request:
28-
types:
29-
- labeled
30-
- synchronize
3127

3228
jobs:
3329
meta_data:
34-
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'cd/preview')
3530
runs-on:
3631
group: huge-runners
3732
outputs:
@@ -41,7 +36,7 @@ jobs:
4136
short_ref: ${{ steps.short_ref.outputs.short_ref }}
4237
steps:
4338
- name: Set GIT ref
44-
run: echo "ref=${{ inputs.commit == '' && (github.event.pull_request.head.sha == '' && github.sha || github.event.pull_request.head.sha) || inputs.commit }} " >> $GITHUB_OUTPUT
39+
run: echo "ref=${{ inputs.commit == '' && github.sha || inputs.commit }} " >> $GITHUB_OUTPUT
4540
id: ref
4641
- name: Set GIT short ref
4742
run: echo "short_ref=$(echo ${{ steps.ref.outputs.ref }} | cut -c1-7)" >> $GITHUB_OUTPUT
@@ -62,8 +57,7 @@ jobs:
6257
latest=false
6358
6459
65-
publish-docker-image-dispatch:
66-
if: github.event_name == 'workflow_dispatch'
60+
publish-docker-image:
6761
uses: ./.github/workflows/ci-docker-image.yml
6862
needs: meta_data
6963
secrets: inherit
@@ -74,16 +68,3 @@ jobs:
7468
tags: ${{needs.meta_data.outputs.tags}}
7569
labels: ${{needs.meta_data.outputs.labels}}
7670
platforms: ${{ inputs.platforms }}
77-
78-
publish-docker-image-pr:
79-
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cd/preview')
80-
uses: ./.github/workflows/ci-docker-image.yml
81-
needs: meta_data
82-
secrets: inherit
83-
with:
84-
publish: true
85-
version: dev-${{ needs.meta_data.outputs.short_ref }}
86-
ref: ${{ needs.meta_data.outputs.ref }}
87-
tags: ${{ needs.meta_data.outputs.tags }}
88-
labels: ${{ needs.meta_data.outputs.labels }}
89-
platforms: "linux/amd64"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# yamllint disable rule:truthy rule:line-length
3+
name: Publish preview development docker image
4+
5+
on:
6+
pull_request:
7+
types:
8+
- labeled
9+
- synchronize
10+
11+
jobs:
12+
meta_data:
13+
if: contains(github.event.pull_request.labels.*.name, 'cd/preview')
14+
runs-on:
15+
group: huge-runners
16+
outputs:
17+
tags: ${{ steps.meta.outputs.tags }}
18+
labels: ${{ steps.meta.outputs.labels }}
19+
ref: ${{ steps.ref.outputs.ref }}
20+
short_ref: ${{ steps.short_ref.outputs.short_ref }}
21+
steps:
22+
- name: Set GIT ref
23+
run: echo "ref=${{ github.event.pull_request.head.sha == '' && github.sha || github.event.pull_request.head.sha }} " >> $GITHUB_OUTPUT
24+
id: ref
25+
- name: Set GIT short ref
26+
run: echo "short_ref=$(echo ${{ steps.ref.outputs.ref }} | cut -c1-7)" >> $GITHUB_OUTPUT
27+
id: short_ref
28+
- name: Set docker image meta data
29+
id: meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: |
33+
${{ vars.HARBOR_HOST }}/${{ github.repository }}
34+
tags: |
35+
type=raw,value=dev-${{ steps.short_ref.outputs.short_ref }}
36+
labels: |
37+
org.opencontainers.image.source=${{ github.repository }}
38+
org.opencontainers.image.version=dev-${{ steps.short_ref.outputs.short_ref }}
39+
flavor: |
40+
latest=false
41+
42+
publish-docker-image:
43+
if: contains(github.event.pull_request.labels.*.name, 'cd/preview')
44+
uses: ./.github/workflows/ci-docker-image.yml
45+
needs: meta_data
46+
secrets: inherit
47+
with:
48+
publish: true
49+
version: dev-${{ needs.meta_data.outputs.short_ref }}
50+
ref: ${{ needs.meta_data.outputs.ref }}
51+
tags: ${{ needs.meta_data.outputs.tags }}
52+
labels: ${{ needs.meta_data.outputs.labels }}
53+
platforms: "linux/amd64"

.github/workflows/update-compose-file-and-chart.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
python-version: 3.12
4242
- name: "Setup environment"
4343
run: |
44-
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
45-
poetry config virtualenvs.prefer-active-python true
44+
pipx install -f poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
45+
poetry config virtualenvs.create true --local
4646
- name: "Install Package"
4747
run: "poetry install --all-extras"
4848

.github/workflows/version-upgrade.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ jobs:
5656
python-version: 3.12
5757
- name: "Setup python environment"
5858
run: |
59-
pipx install poetry==${{ env.POETRY_VERSION }}
60-
poetry config virtualenvs.prefer-active-python true
59+
pipx install -f poetry==${{ env.POETRY_VERSION }}
60+
poetry config virtualenvs.create true --local
6161
pip install invoke toml
6262
- name: "Install Package"
6363
run: "poetry install"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
GRAPH_VERSION = 29
1+
GRAPH_VERSION = 30

backend/infrahub/core/migrations/graph/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .m027_delete_isolated_nodes import Migration027
3232
from .m028_delete_diffs import Migration028
3333
from .m029_duplicates_cleanup import Migration029
34+
from .m030_illegal_edges import Migration030
3435

3536
if TYPE_CHECKING:
3637
from infrahub.core.root import Root
@@ -67,6 +68,7 @@
6768
Migration027,
6869
Migration028,
6970
Migration029,
71+
Migration030,
7072
]
7173

7274

backend/infrahub/core/migrations/graph/m029_duplicates_cleanup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ class PerformHardDeletes(Query):
536536
async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> None: # noqa: ARG002
537537
query = """
538538
CALL {
539-
MATCH (n:Node)
539+
MATCH (n)
540540
WHERE n.to_delete = TRUE
541541
DETACH DELETE n
542542
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING, Any, Sequence
4+
5+
from infrahub.core.migrations.shared import GraphMigration, MigrationResult
6+
from infrahub.log import get_logger
7+
8+
from ...query import Query, QueryType
9+
10+
if TYPE_CHECKING:
11+
from infrahub.database import InfrahubDatabase
12+
13+
log = get_logger()
14+
15+
16+
class DeletePosthumousEdges(Query):
17+
name = "delete_posthumous_edges_query"
18+
type = QueryType.WRITE
19+
insert_return = False
20+
21+
async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> None: # noqa: ARG002
22+
query = """
23+
// ------------
24+
// find deleted nodes
25+
// ------------
26+
MATCH (n:Node)-[e:IS_PART_OF]->(:Root)
27+
WHERE e.status = "deleted" OR e.to IS NOT NULL
28+
WITH DISTINCT n, e.branch AS delete_branch, e.branch_level AS delete_branch_level, CASE
29+
WHEN e.status = "deleted" THEN e.from
30+
ELSE e.to
31+
END AS delete_time
32+
// ------------
33+
// find the edges added to the deleted node after the delete time
34+
// ------------
35+
MATCH (n)-[added_e]-(peer)
36+
WHERE added_e.from > delete_time
37+
AND type(added_e) <> "IS_PART_OF"
38+
// if the node was deleted on a branch (delete_branch_level > 1), and then updated on main/global (added_e.branch_level = 1), we can ignore it
39+
AND added_e.branch_level >= delete_branch_level
40+
AND (added_e.branch = delete_branch OR delete_branch_level = 1)
41+
WITH DISTINCT n, delete_branch, delete_time, added_e, peer
42+
// ------------
43+
// get the branched_from for the branch on which the node was deleted
44+
// ------------
45+
CALL (added_e) {
46+
MATCH (b:Branch {name: added_e.branch})
47+
RETURN b.branched_from AS added_e_branched_from
48+
}
49+
// ------------
50+
// account for the following situations, given that the edge update time is after the node delete time
51+
// - deleted on main/global, updated on branch
52+
// - illegal if the delete is before branch.branched_from
53+
// - deleted on branch, updated on branch
54+
// - illegal
55+
// ------------
56+
WITH n, delete_branch, delete_time, added_e, peer
57+
WHERE delete_branch = added_e.branch
58+
OR delete_time < added_e_branched_from
59+
DELETE added_e
60+
// --------------
61+
// the peer _should_ only be an Attribute, but I want to make sure we don't
62+
// inadvertently delete Root or an AttributeValue or a Boolean
63+
// --------------
64+
WITH peer
65+
WHERE "Attribute" IN labels(peer)
66+
DETACH DELETE peer
67+
"""
68+
self.add_to_query(query)
69+
70+
71+
class Migration030(GraphMigration):
72+
"""
73+
Edges could have been added to Nodes after the Node was deleted, so we need to hard-delete those illegal edges
74+
"""
75+
76+
name: str = "030_delete_illegal_edges"
77+
minimum_version: int = 29
78+
queries: Sequence[type[Query]] = [DeletePosthumousEdges]
79+
80+
async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: # noqa: ARG002
81+
result = MigrationResult()
82+
return result

0 commit comments

Comments
 (0)