Skip to content

Commit

Permalink
Merge branch 'stable' into release-1.0.9-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
BeArchiTek authored Dec 10, 2024
2 parents c3aa86a + fab6295 commit 9730d08
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,10 @@ jobs:
secrets: inherit
with:
publish: true

update-submodule:
needs: check_release
uses: ./.github/workflows/update-submodule.yml
secrets: inherit
with:
version: ${{ github.ref_name }}
71 changes: 71 additions & 0 deletions .github/workflows/trigger-submodule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# yamllint disable rule:truthy rule:line-length
name: Handle Submodule Trigger

on:
repository_dispatch:
types:
- trigger-submodule-update

jobs:
update-dependencies:
strategy:
matrix:
branch-name:
- stable
- develop
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: "${{ matrix.branch-name }}"
submodules: recursive

- name: Set branch name
id: set-branch-name
run: |
SUBMODULE_PATH="python_sdk"
SDK_VERSION="${{ github.event.client_payload.version }}"
BRANCH_NAME="${{ matrix.branch-name}}-${SUBMODULE_PATH}-${SDK_VERSION}"
echo "SUBMODULE_PATH=$SUBMODULE_PATH" >> $GITHUB_ENV
echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Use the version from the client payload to update the submodule
run: |
echo "Updating submodule to version: ${{ env.SDK_VERSION }}"
echo "Branch name: ${{ env.BRANCH_NAME }}"
# Navigate to the submodule and update it to the specified version
cd ${{ env.SUBMODULE_PATH }}
git fetch --tags
git checkout ${{ env.SDK_VERSION }}
cd -
- name: Prepare the branch for the update
id: prepare-branch
run: |
echo "Checking if branch ${{ env.BRANCH_NAME }} exists..."
BRANCH_EXISTS=$(git ls-remote --heads origin ${{ env.BRANCH_NAME }} | wc -l)
echo "BRANCH_EXISTS=$BRANCH_EXISTS" >> $GITHUB_ENV
- name: Commit and push changes with github-actions-x/commit
uses: github-actions-x/[email protected]
with:
github-token: ${{ secrets.GH_UPDATE_PACKAGE_OTTO }}
push-branch: ${{ env.BRANCH_NAME }}
commit-message: "chore: update submodule ${{ env.SUBMODULE_PATH }} to version ${{ env.SDK_VERSION }}"
files: ${{ env.SUBMODULE_PATH }}/
name: opsmill-bot
email: [email protected]
rebase: ${{ env.BRANCH_EXISTS == 1 }}

- name: Create a pull request
run: |
echo ${{ secrets.GH_UPDATE_PACKAGE_OTTO }} | gh auth login --with-token
gh pr create \
--title "Update ${{ env.SUBMODULE_PATH }} to version ${{ env.SDK_VERSION }} against ${{ matrix.branch-name}}" \
--body "This PR updates the submodule ${{ env.SUBMODULE_PATH }} to version ${{ env.SDK_VERSION }}." \
--base ${{ matrix.branch-name}} \
--head ${{ env.BRANCH_NAME }}
44 changes: 44 additions & 0 deletions .github/workflows/update-submodule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# yamllint disable rule:truthy rule:line-length
name: Trigger Submodule update

on:
workflow_dispatch:
inputs:
runs-on:
description: "The OS to run the job on"
required: false
default: "ubuntu-22.04"
type: string
version:
type: string
required: false
description: The string to extract semver from.
default: ''
workflow_call:
inputs:
runs-on:
description: "The OS to run the job on"
required: false
default: "ubuntu-22.04"
type: string
version:
type: string
required: false
description: The string to extract semver from.
default: ''

jobs:
trigger-submodule:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Trigger submodule update
run: |
curl -X POST \
-H 'Authorization: token ${{ secrets.GH_UPDATE_PACKAGE_OTTO }}' \
-H 'Accept: application/vnd.github.v3+json' \
'https://api.github.com/repos/${{ secrets.INFRAHUB_ENTERPRISE_REPOSITORY }}/dispatches' \
-d '{"event_type":"trigger-submodule-update","client_payload":{"version":"${{ inputs.version }}"}}'
2 changes: 2 additions & 0 deletions .vale/styles/spelling-exceptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ validator
upsert
Upserting
upserting
uuid
UUID
validators
Version Control
Vitest
Expand Down
5 changes: 0 additions & 5 deletions backend/infrahub/core/schema/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
from typing import TYPE_CHECKING, Any, Optional, Union

from infrahub import lock
from infrahub.core.constants import (
InfrahubKind,
)
from infrahub.core.manager import NodeManager
from infrahub.core.models import (
HashableModelDiff,
Expand Down Expand Up @@ -234,8 +231,6 @@ async def load_schema_to_db(
branch = await registry.get_branch(branch=branch, db=db)

for item_kind in schema.node_names + schema.generic_names:
if item_kind == InfrahubKind.PROFILE:
continue
if limit and item_kind not in limit:
continue
item = schema.get(name=item_kind, duplicate=False)
Expand Down
4 changes: 3 additions & 1 deletion backend/infrahub/graphql/queries/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ async def resolve_status(
service = context.service or services.service
fields = await extract_fields_first_node(info)
response: dict[str, Any] = {}
workers = await service.component.list_workers(branch=context.branch.id or context.branch.name, schema_hash=True)
workers = await service.component.list_workers(
branch=str(context.branch.uuid) or context.branch.name, schema_hash=True
)

if summary := fields.get("summary"):
response["summary"] = {}
Expand Down
7 changes: 5 additions & 2 deletions backend/infrahub/services/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Any, Optional

from infrahub.components import ComponentType
from infrahub.core.constants import GLOBAL_BRANCH_NAME
from infrahub.core.registry import registry
from infrahub.core.timestamp import Timestamp
from infrahub.exceptions import InitializationError
Expand Down Expand Up @@ -71,16 +72,18 @@ async def list_workers(self, branch: str, schema_hash: bool) -> list[WorkerInfo]
workers[identity].add_value(key=key, value=value)
return list(workers.values())

async def refresh_schema_hash(self, branches: Optional[list[str]] = None) -> None:
async def refresh_schema_hash(self, branches: list[str] | None = None) -> None:
branches = branches or list(registry.branch.keys())
for branch in branches:
if branch == GLOBAL_BRANCH_NAME:
continue
schema_branch = registry.schema.get_schema_branch(name=branch)
hash_value = schema_branch.get_hash()

# Use branch name if we cannot find branch id in cache
branch_id: Optional[str] = None
if branch_obj := await registry.get_branch(branch=branch, db=self.service.database):
branch_id = branch_obj.id
branch_id = str(branch_obj.uuid)

if not branch_id:
branch_id = branch
Expand Down
1 change: 1 addition & 0 deletions changelog/+branch-hash-id.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the branch uuid instead of the internal database id to track the hash of the schema in the cache
1 change: 1 addition & 0 deletions changelog/+f91354a0.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Store CoreProfile in database to ensure consistent initial schema hash. Prior to this the schema was reported as being out of sync when starting the application for the first time. This error wouldn't have hade any impact but was confusing. The workaround would be to load a schema or restart the application at least once after first time initialization.
16 changes: 8 additions & 8 deletions docs/docs/guides/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ For a list of versions, check our [release notes on GitHub](https://github.com/o
<Tabs>
<TabItem value="MacOS" default>

`` `shell
```shell
curl https://infrahub.opsmill.io | docker compose -f - up -d
`` `
```

</TabItem>
<TabItem value="Ubuntu">

`` `shell
```shell
curl https://infrahub.opsmill.io | sudo docker compose -f - up -d
`` `
```

</TabItem>
</Tabs>
Expand All @@ -60,16 +60,16 @@ curl https://infrahub.opsmill.io | sudo docker compose -f - up -d
<Tabs>
<TabItem value="MacOS" default>

`` `shell
```shell
curl https://infrahub.opsmill.io | docker compose -f - down -v
`` `
```

</TabItem>
<TabItem value="Ubuntu">

`` `shell
```shell
curl https://infrahub.opsmill.io | sudo docker compose -f - down -v
`` `
```

</TabItem>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/topics/ipam.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ By default, Infrahub comes with a node inheriting from the `BuiltinIPNamespace`

## Building an IPAM

As mentioned in the previous section, an IPAM namespace is already provided with Infrahub, so there are no needs to redefined this unless more attributes are required. The default implementation is very minimal and attributes only include a name and a description.
As mentioned in the previous section, an IPAM namespace is already provided with Infrahub, so there is no need to redefine this unless more attributes are required. The default implementation is very minimal and attributes only include a name and a description.

The below schema defines two nodes: one for IP prefixes `IpamIPPrefix` and one for IP addresses `IpamIPAddress`. Both of these nodes inherit from the built-in generics.

Expand Down

0 comments on commit 9730d08

Please sign in to comment.