Skip to content

Commit 6ace0a7

Browse files
authored
Merge branch 'main' into feature/trunk-ci-debug
2 parents 388f59a + c0fa117 commit 6ace0a7

File tree

13 files changed

+111
-66
lines changed

13 files changed

+111
-66
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464
},
6565
"remoteUser": "vscode",
66-
"postCreateCommand": "poetry install --no-interaction --no-ansi --no-root --group=docs --group=dev",
66+
"postCreateCommand": "poetry install --no-interaction --no-ansi --no-root --with docs,dev",
6767
"postAttachCommand": {},
6868
"portsAttributes": {
6969
"6379": {

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ jobs:
1919
uses: scality/workflows/.github/workflows/docker-build.yaml@v2
2020
with:
2121
name: runner-manager
22-
namespace: scality
22+
namespace: ${{ github.repository_owner }}
2323
tag: ${{ github.ref_name == 'main' && 'latest' || github.sha }}

.github/workflows/test-deployment.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ name: test-deployment
44
on: pull_request
55

66
permissions:
7-
contents: read
7+
contents: write
8+
packages: write
89

910
jobs:
1011
docker-build:
1112
permissions:
12-
contents: read
13+
contents: write
1314
packages: write
1415
uses: scality/workflows/.github/workflows/docker-build.yaml@v2
1516
with:
1617
name: runner-manager
17-
namespace: scality
18+
namespace: ${{ github.repository_owner }}
19+
1820
test-deployment:
1921
needs: docker-build
2022
runs-on: ubuntu-latest
@@ -23,7 +25,7 @@ jobs:
2325
- uses: helm/kind-action@v1
2426
- name: Edit the runner-manager image
2527
working-directory: manifests
26-
run: kustomize edit set image ghcr.io/scality/runner-manager:${{ github.sha }}
28+
run: kustomize edit set image ghcr.io/${{ github.repository_owner }}/runner-manager:${{ github.sha }}
2729
- name: Deploy runner-manager
2830
run: kubectl apply -k manifests
2931
- name: Check if deployment is ready

codecov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ coverage:
1111
codecov:
1212
notify:
1313
wait_for_ci: true
14+
15+
flag_management:
16+
default_rules:
17+
carryforward: true
18+
statuses:
19+
- type: project
20+
target: auto
21+
threshold: 1%
22+
- type: patch
23+
target: 80%

mkdocs.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ markdown_extensions:
5252
- pymdownx.highlight:
5353
anchor_linenums: true
5454
- pymdownx.emoji:
55-
emoji_index: !!python/name:materialx.emoji.twemoji
56-
emoji_generator: !!python/name:materialx.emoji.to_svg
55+
emoji_index: !!python/name:material.extensions.emoji.twemoji
56+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
5757
- pymdownx.inlinehilite
5858
- pymdownx.snippets
59-
- pymdownx.superfences
59+
- pymdownx.superfences:
60+
custom_fences:
61+
- name: mermaid
62+
class: mermaid
63+
format: !!python/name:pymdownx.superfences.fence_code_format
6064
- tables
6165
- attr_list
6266
- md_in_html

poetry.lock

Lines changed: 49 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ python = "^3.11"
1313
fastapi = "^0.110.0"
1414
uvicorn = { extras = ["standard"], version = "^0.29.0" }
1515
pydantic = ">=1.10.2,<2.0"
16-
redis-om = "^0.2.1"
16+
redis-om = "^0.2.2"
1717
rq = "^1.16.1"
1818
pyyaml = "^6.0.1"
1919
redis = "^4.6.0"
2020
docker = "^7.0.0"
2121
google-cloud-compute = "^1.18.0"
2222
boto3 = "^1.28.85"
2323
botocore = "^1.31.85"
24-
boto3-stubs = { extras = ["ec2"], version = "^1.34.70" }
24+
boto3-stubs = { extras = ["ec2"], version = "^1.34.75" }
2525
githubkit = { extras = ["auth-app"], version = "^0.11.3" }
2626
rq-scheduler = "^0.13.1"
2727

@@ -30,20 +30,20 @@ rq-scheduler = "^0.13.1"
3030
optional = true
3131

3232
[tool.poetry.group.docs.dependencies]
33-
mkdocs-material = "^9.5.15"
33+
mkdocs-material = "^9.5.16"
3434
mkdocs = "^1.5.3"
3535

3636
[tool.poetry.group.dev.dependencies]
3737
connexion = "^3.0.5"
3838
pytest = "^8.1.1"
3939
pytest-cov = "^5.0.0"
40-
hypothesis = "^6.99.13"
41-
pyright = "^1.1.355"
40+
hypothesis = "^6.100.0"
41+
pyright = "^1.1.356"
4242
black = "^24.3.0"
4343
isort = "^5.13.2"
44-
ruff = "^0.3.4"
44+
ruff = "^0.3.5"
4545
yamllint = "^1.35.1"
46-
types-redis = "^4.6.0.20240218"
46+
types-redis = "^4.6.0.20240311"
4747

4848

4949
[build-system]

runner_manager/models/backend.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from mypy_boto3_ec2.type_defs import (
88
BlockDeviceMappingTypeDef,
99
EbsBlockDeviceTypeDef,
10+
IamInstanceProfileTypeDef,
1011
TagSpecificationTypeDef,
1112
TagTypeDef,
1213
)
@@ -133,6 +134,7 @@ class AWSConfig(BackendConfig):
133134
"BlockDeviceMappings": Sequence[BlockDeviceMappingTypeDef],
134135
"MaxCount": int,
135136
"MinCount": int,
137+
"IamInstanceProfile": IamInstanceProfileTypeDef,
136138
},
137139
)
138140

@@ -150,6 +152,7 @@ class AWSInstanceConfig(InstanceConfig):
150152
tags: Dict[str, str] = {}
151153
volume_type: VolumeTypeType = "gp3"
152154
disk_size_gb: int = 20
155+
iam_instance_profile_arn: str = ""
153156

154157
def configure_instance(self, runner: Runner) -> AwsInstance:
155158
"""Configure instance."""
@@ -178,8 +181,15 @@ def configure_instance(self, runner: Runner) -> AwsInstance:
178181
TagSpecificationTypeDef(
179182
ResourceType="instance",
180183
Tags=tags,
181-
)
184+
),
185+
TagSpecificationTypeDef(
186+
ResourceType="volume",
187+
Tags=tags,
188+
),
182189
]
190+
iam_instance_profile: IamInstanceProfileTypeDef = IamInstanceProfileTypeDef(
191+
Arn=self.iam_instance_profile_arn
192+
)
183193
return AwsInstance(
184194
ImageId=self.image,
185195
InstanceType=self.instance_type,
@@ -190,4 +200,5 @@ def configure_instance(self, runner: Runner) -> AwsInstance:
190200
MaxCount=self.max_count,
191201
MinCount=self.min_count,
192202
BlockDeviceMappings=block_device_mappings,
203+
IamInstanceProfile=iam_instance_profile,
193204
)

runner_manager/models/runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def find_from_webhook(cls, webhook: WorkflowJobEvent) -> "Runner | None":
8383
Returns:
8484
Runner: A runner object
8585
"""
86-
86+
if webhook.workflow_job.runner_id is None:
87+
return None
8788
try:
8889
runner: Runner | None = cls.find(
8990
cls.id == webhook.workflow_job.runner_id

runner_manager/models/runner_group.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def save(
271271
return super().save(pipeline=pipeline)
272272

273273
@classmethod
274-
def find_from_webhook(cls, webhook: WorkflowJobEvent) -> "RunnerGroup":
274+
def find_from_webhook(cls, webhook: WorkflowJobEvent) -> "RunnerGroup | None":
275275
"""Find the runner group from a webhook instance.
276276
277277
Args:
@@ -280,6 +280,8 @@ def find_from_webhook(cls, webhook: WorkflowJobEvent) -> "RunnerGroup":
280280
Returns:
281281
RunnerGroup: Runner group instance.
282282
"""
283+
if webhook.workflow_job.runner_group_id is None:
284+
return None
283285
try:
284286
group: RunnerGroup | None = cls.find(
285287
(cls.id == webhook.workflow_job.runner_group_id)

tests/unit/backend/test_aws.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,23 @@ def aws_runner(runner: Runner, aws_group: RunnerGroup) -> Runner:
4646
def test_aws_instance_config(runner: Runner):
4747
AWSConfig()
4848
instance_config = AWSInstanceConfig(
49-
tags={"test": "test"}, subnet_id="i-0f9b0a3b7b3b3b3b3"
49+
tags={"test": "test"},
50+
subnet_id="i-0f9b0a3b7b3b3b3b3",
51+
iam_instance_profile_arn="test",
5052
)
5153
instance: AwsInstance = instance_config.configure_instance(runner)
5254
assert instance["ImageId"] == instance_config.image
5355
assert instance["SubnetId"] == instance_config.subnet_id
56+
assert (
57+
instance["IamInstanceProfile"]["Arn"]
58+
== instance_config.iam_instance_profile_arn
59+
)
5460
assert runner.name in instance["UserData"]
5561
tags = instance["TagSpecifications"][0]["Tags"]
5662
assert TagTypeDef(Key="test", Value="test") in tags
5763
assert TagTypeDef(Key="Name", Value=runner.name) in tags
5864
assert runner.encoded_jit_config in instance["UserData"]
65+
assert instance["TagSpecifications"][1]["ResourceType"] == "volume"
5966

6067

6168
@mark.skipif(not os.getenv("AWS_ACCESS_KEY_ID"), reason="AWS credentials not found")

tests/unit/models/test_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def test_find_from_webhook(runner: Runner, webhook: WorkflowJobCompleted):
5252
assert Runner.find_from_webhook(webhook) == runner
5353
runner.delete(runner.pk)
5454
assert Runner.find_from_webhook(webhook) is None
55+
webhook.workflow_job.runner_id = None
56+
assert Runner.find_from_webhook(webhook) is None
5557

5658

5759
def test_update_from_github(runner: Runner, github: GitHub):

tests/unit/models/test_runner_group.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def test_find_from_webhook(runner_group: RunnerGroup, webhook: WorkflowJobComple
9494
assert RunnerGroup.find_from_webhook(webhook) == runner_group
9595
runner_group.delete(runner_group.pk)
9696
assert RunnerGroup.find_from_webhook(webhook) is None
97+
webhook.workflow_job.runner_group_name = None
98+
webhook.workflow_job.runner_group_id = None
99+
assert RunnerGroup.find_from_webhook(webhook) is None
97100

98101

99102
def test_runner_group_delete_method(runner_group: RunnerGroup, github: GitHub):

0 commit comments

Comments
 (0)