Skip to content

rebase and upgrade neo4j 2025.03.0 #6336

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

Merged
merged 6 commits into from
May 7, 2025
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
8 changes: 8 additions & 0 deletions .github/workflows/version-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
include:
- name: From 1.1.0
source_version: 1.1.0
neo4j_image: "neo4j:5.20.0-enterprise"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, is it required to set the version here,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we rely on the development/docker-compose.yml stuff for the upgrade test job, we must start the previous Infrahub version with the previous neo4j version.

I don't know any other way to do that except specifying the neo4j docker image to use when starting the previous Infrahub version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one make sense

name: ${{ matrix.name }}
runs-on:
group: huge-runners
Expand Down Expand Up @@ -68,21 +69,28 @@ jobs:
# Initialize the demo environment with the Source Version
- name: Pull External Docker Images
run: invoke demo.pull
env:
NEO4J_DOCKER_IMAGE: ${{ matrix.neo4j_image }}
- name: Initialize Demo
id: init-demo
run: invoke demo.start demo.load-infra-schema
env:
PREFECT_SERVER_COMMAND: "prefect server start --host 0.0.0.0 --ui"
NEO4J_DOCKER_IMAGE: ${{ matrix.neo4j_image }}
- name: Check Demo Status
run: invoke demo.status
env:
NEO4J_DOCKER_IMAGE: ${{ matrix.neo4j_image }}
- name: Load Infra Data
run: invoke demo.load-infra-data
env:
PREFECT_SERVER_COMMAND: "prefect server start --host 0.0.0.0 --ui"
NEO4J_DOCKER_IMAGE: ${{ matrix.neo4j_image }}
- name: Run infra data patch scripts
run: invoke demo.run-infra-patch-scripts
env:
PREFECT_SERVER_COMMAND: "prefect server start --host 0.0.0.0 --ui"
NEO4J_DOCKER_IMAGE: ${{ matrix.neo4j_image }}
- name: Stop Demo
run: invoke demo.stop

Expand Down
3 changes: 1 addition & 2 deletions backend/infrahub/cli/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,10 @@ async def selected_export(
ORDER BY %(id_func)s(n)
SKIP toInteger($offset)
LIMIT toInteger($limit)
CALL {
CALL (n) {
// --------------
// get all the nodes and edges linked to this node up to 2 steps away, excluding IS_PART_OF
// --------------
WITH n
MATCH (n)-[r1]-(v1)-[r2]-(v2)
WHERE type(r1) <> "IS_PART_OF"
WITH collect([v1, v2]) AS vertex_pairs, collect([r1, r2]) AS edge_pairs
Expand Down
71 changes: 24 additions & 47 deletions backend/infrahub/core/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
query = """
MATCH (account:%(generic_account_node)s)
WHERE account.uuid = $account_id
CALL {
WITH account
CALL (account) {
MATCH (account)-[r:IS_PART_OF]-(root:Root)
WHERE %(branch_filter)s
RETURN account as account1, r as r1
Expand All @@ -80,8 +79,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
WITH account, r1 as r
WHERE r.status = "active"
WITH account
CALL {
WITH account
CALL (account) {
MATCH (account)-[r1:IS_RELATED]->(:Relationship {name: "group_member"})<-[r2:IS_RELATED]-(account_group:%(account_group_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH account_group, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -92,8 +90,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH account_group

CALL {
WITH account_group
CALL (account_group) {
MATCH (account_group)-[r1:IS_RELATED]->(:Relationship {name: "role__accountgroups"})<-[r2:IS_RELATED]-(account_role:%(account_role_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH account_role, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -104,8 +101,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH account_role

CALL {
WITH account_role
CALL (account_role) {
MATCH (account_role)-[r1:IS_RELATED]->(:Relationship {name: "role__permissions"})<-[r2:IS_RELATED]-(global_permission:%(global_permission_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH global_permission, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -116,7 +112,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH global_permission

CALL {
CALL (global_permission) {
WITH global_permission
MATCH (global_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "action"})-[r2:HAS_VALUE]->(global_permission_action:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
Expand All @@ -127,8 +123,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
WITH global_permission, global_permission_action, is_active AS gpa_is_active
WHERE gpa_is_active = TRUE

CALL {
WITH global_permission
CALL (global_permission) {
MATCH (global_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "decision"})-[r2:HAS_VALUE]->(global_permission_decision:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN global_permission_decision, (r1.status = "active" AND r2.status = "active") AS is_active
Expand Down Expand Up @@ -183,8 +178,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
query = """
MATCH (account:%(generic_account_node)s)
WHERE account.uuid = $account_id
CALL {
WITH account
CALL (account) {
MATCH (account)-[r:IS_PART_OF]-(root:Root)
WHERE %(branch_filter)s
RETURN account as account1, r as r1
Expand All @@ -194,8 +188,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
WITH account, r1 as r
WHERE r.status = "active"
WITH account
CALL {
WITH account
CALL (account) {
MATCH (account)-[r1:IS_RELATED]->(:Relationship {name: "group_member"})<-[r2:IS_RELATED]-(account_group:%(account_group_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH account_group, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -206,8 +199,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH account_group

CALL {
WITH account_group
CALL (account_group) {
MATCH (account_group)-[r1:IS_RELATED]->(:Relationship {name: "role__accountgroups"})<-[r2:IS_RELATED]-(account_role:%(account_role_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH account_role, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -218,8 +210,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH account_role

CALL {
WITH account_role
CALL (account_role) {
MATCH (account_role)-[r1:IS_RELATED]->(:Relationship {name: "role__permissions"})<-[r2:IS_RELATED]-(object_permission:%(object_permission_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH object_permission, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -230,8 +221,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission

CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "namespace"})-[r2:HAS_VALUE]->(object_permission_namespace:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_namespace, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -240,8 +230,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission, object_permission_namespace, is_active AS opn_is_active
WHERE opn_is_active = TRUE
CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "name"})-[r2:HAS_VALUE]->(object_permission_name:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_name, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -250,8 +239,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission, object_permission_namespace, object_permission_name, is_active AS opn_is_active
WHERE opn_is_active = TRUE
CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "action"})-[r2:HAS_VALUE]->(object_permission_action:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_action, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -260,8 +248,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission, object_permission_namespace, object_permission_name, object_permission_action, is_active AS opa_is_active
WHERE opa_is_active = TRUE
CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "decision"})-[r2:HAS_VALUE]->(object_permission_decision:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_decision, (r1.status = "active" AND r2.status = "active") AS is_active
Expand Down Expand Up @@ -336,8 +323,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
query = """
MATCH (account_role:%(account_role_node)s)
WHERE account_role.uuid = $role_id
CALL {
WITH account_role
CALL (account_role) {
MATCH (account_role)-[r:IS_PART_OF]-(root:Root)
WHERE %(branch_filter)s
RETURN account_role as account_role1, r as r1
Expand All @@ -348,8 +334,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
WHERE r.status = "active"
WITH account_role

CALL {
WITH account_role
CALL (account_role) {
MATCH (account_role)-[r1:IS_RELATED]->(:Relationship {name: "role__permissions"})<-[r2:IS_RELATED]-(global_permission:%(global_permission_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH global_permission, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -360,8 +345,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH global_permission

CALL {
WITH global_permission
CALL (global_permission) {
MATCH (global_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "action"})-[r2:HAS_VALUE]->(global_permission_action:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN global_permission_action, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -371,8 +355,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
WITH global_permission, global_permission_action, is_active AS gpa_is_active
WHERE gpa_is_active = TRUE

CALL {
WITH global_permission
CALL (global_permission) {
MATCH (global_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "decision"})-[r2:HAS_VALUE]->(global_permission_decision:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN global_permission_decision, (r1.status = "active" AND r2.status = "active") AS is_active
Expand Down Expand Up @@ -425,8 +408,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
query = """
MATCH (account_role:%(account_role_node)s)
WHERE account_role.uuid = $role_id
CALL {
WITH account_role
CALL (account_role) {
MATCH (account_role)-[r:IS_PART_OF]-(root:Root)
WHERE %(branch_filter)s
RETURN account_role as account_role1, r as r1
Expand All @@ -437,8 +419,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
WHERE r.status = "active"
WITH account_role

CALL {
WITH account_role
CALL (account_role) {
MATCH (account_role)-[r1:IS_RELATED]->(:Relationship {name: "role__permissions"})<-[r2:IS_RELATED]-(object_permission:%(object_permission_node)s)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
WITH object_permission, r1, r2, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -449,8 +430,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission

CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "namespace"})-[r2:HAS_VALUE]->(object_permission_namespace:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_namespace, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -459,8 +439,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission, object_permission_namespace, is_active AS opn_is_active
WHERE opn_is_active = TRUE
CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "name"})-[r2:HAS_VALUE]->(object_permission_name:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_name, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -469,8 +448,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission, object_permission_namespace, object_permission_name, is_active AS opn_is_active
WHERE opn_is_active = TRUE
CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "action"})-[r2:HAS_VALUE]->(object_permission_action:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_action, (r1.status = "active" AND r2.status = "active") AS is_active
Expand All @@ -479,8 +457,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
}
WITH object_permission, object_permission_namespace, object_permission_name, object_permission_action, is_active AS opa_is_active
WHERE opa_is_active = TRUE
CALL {
WITH object_permission
CALL (object_permission) {
MATCH (object_permission)-[r1:HAS_ATTRIBUTE]->(:Attribute {name: "decision"})-[r2:HAS_VALUE]->(object_permission_decision:AttributeValue)
WHERE all(r IN [r1, r2] WHERE (%(branch_filter)s))
RETURN object_permission_decision, (r1.status = "active" AND r2.status = "active") AS is_active
Expand Down
6 changes: 1 addition & 5 deletions backend/infrahub/core/diff/query/all_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,18 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa
($diff_id IS NOT NULL AND root.uuid = $diff_id)
OR ($tracking_id IS NOT NULL AND root.tracking_id = $tracking_id AND root.diff_branch = $diff_branch_name)
)
CALL {
WITH root
CALL (root) {
MATCH (root)-[:DIFF_HAS_NODE]->(node:DiffNode)-[:DIFF_HAS_CONFLICT]->(node_conflict:DiffConflict)
RETURN node.path_identifier AS path_identifier, node_conflict AS conflict
UNION
WITH root
MATCH (root)-[:DIFF_HAS_NODE]->(node:DiffNode)-[:DIFF_HAS_ATTRIBUTE]->(:DiffAttribute)
-[:DIFF_HAS_PROPERTY]->(property:DiffProperty)-[:DIFF_HAS_CONFLICT]->(attr_property_conflict:DiffConflict)
RETURN property.path_identifier AS path_identifier, attr_property_conflict AS conflict
UNION
WITH root
MATCH (root)-[:DIFF_HAS_NODE]->(node:DiffNode)-[:DIFF_HAS_RELATIONSHIP]->(:DiffRelationship)
-[:DIFF_HAS_ELEMENT]->(element:DiffRelationshipElement)-[:DIFF_HAS_CONFLICT]->(rel_element_conflict:DiffConflict)
RETURN element.path_identifier AS path_identifier, rel_element_conflict AS conflict
UNION
WITH root
MATCH (root)-[:DIFF_HAS_NODE]->(node:DiffNode)-[:DIFF_HAS_RELATIONSHIP]->(:DiffRelationship)
-[:DIFF_HAS_ELEMENT]->(:DiffRelationshipElement)-[:DIFF_HAS_PROPERTY]->(property:DiffProperty)
-[:DIFF_HAS_CONFLICT]->(rel_property_conflict:DiffConflict)
Expand Down
Loading
Loading