Skip to content

Commit 725cce1

Browse files
authored
Fix CI (#329)
1 parent 279b712 commit 725cce1

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,21 @@ name: CI
33
on:
44
push:
55
branches: [master]
6-
tags: [v*.*, v*.*.*]
6+
tags: [v*]
77
pull_request:
88
branches: [master]
9-
pull_request_target:
10-
branches: [master]
119
schedule:
1210
- cron: 0 4 * * *
1311

1412
jobs:
1513
test:
1614
name: Run tests
1715
runs-on: ubuntu-latest
18-
if: |
19-
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
20-
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
2116
steps:
2217
- name: Checkout commit
2318
uses: actions/checkout@v2
2419
- name: Install python
25-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v5
2621
with:
2722
python-version: 3.9
2823
- name: Cache packages

.github/workflows/setup-automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Enable auto-merge
22
on:
3-
pull_request_target:
3+
pull_request:
44
types: [opened]
55

66
permissions:

Makefile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
GOPATH ?= $(HOME)/go
22

3-
WAIT_FOR_IT_URL = https://raw.githubusercontent.com/eficode/wait-for/master/wait-for
4-
WAIT_FOR_IT = curl -s $(WAIT_FOR_IT_URL) | bash -s --
5-
63
setup:
74
pip install -U pip
85
pip install -e .[build-tools]
@@ -25,15 +22,8 @@ test_unit:
2522

2623
test_integration: minikube_image_load
2724
echo tests/integration/k8s/* | xargs -n 1 kubectl --context minikube apply -f
28-
29-
export CRI_ADDRESS=$$(minikube service cri --url | sed -e "s/^http:\/\///"); \
30-
$(WAIT_FOR_IT) $$CRI_ADDRESS -- echo "cri is up"
31-
export RUNTIME_ADDRESS=$$(minikube service runtime --url | sed -e "s/^http:\/\///"); \
32-
$(WAIT_FOR_IT) $$RUNTIME_ADDRESS -- echo "runtime is up"
33-
export REGISTRY_ADDRESS=$$(minikube service registry --url | sed -e "s/^http:\/\///"); \
34-
$(WAIT_FOR_IT) $$REGISTRY_ADDRESS -- echo "registry is up"
35-
export SVC_ADDRESS=$$(minikube service platform-container-runtime --url | sed -e "s/^http:\/\///"); \
36-
$(WAIT_FOR_IT) $$SVC_ADDRESS -- echo "service is up"
25+
kubectl --context minikube get po -o name | xargs -n 1 kubectl --context minikube wait --for=jsonpath='{.status.phase}'=Running
26+
kubectl --context minikube get po
3727

3828
pytest -vv --cov=platform_container_runtime --cov-report xml:.coverage-integration.xml tests/integration
3929

platform_container_runtime/registry_client.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def get_version(self, server: str, auth: Optional[Auth] = None) -> str:
7878
) as resp:
7979
if resp.status == 404:
8080
return "v1"
81-
resp.raise_for_status()
81+
await self._raise_for_status(resp)
8282
return "v2"
8383

8484
async def check_blob(
@@ -90,7 +90,7 @@ async def check_blob(
9090
) as resp:
9191
if resp.status == 404:
9292
return False
93-
resp.raise_for_status()
93+
await self._raise_for_status(resp)
9494
return True
9595

9696
async def start_blob_upload(
@@ -100,7 +100,7 @@ async def start_blob_upload(
100100
async with self._session.post(
101101
endpoints.blob_uploads(name), headers=self._get_auth_header(auth)
102102
) as resp:
103-
resp.raise_for_status()
103+
await self._raise_for_status(resp)
104104
return URL(resp.headers[aiohttp.hdrs.LOCATION])
105105

106106
async def upload_blob(
@@ -121,7 +121,7 @@ async def upload_blob(
121121
},
122122
data=data,
123123
) as resp:
124-
resp.raise_for_status()
124+
await self._raise_for_status(resp)
125125

126126
async def update_manifest(
127127
self,
@@ -141,4 +141,13 @@ async def update_manifest(
141141
},
142142
data=json.dumps(manifest),
143143
) as resp:
144-
resp.raise_for_status()
144+
await self._raise_for_status(resp)
145+
146+
@classmethod
147+
async def _raise_for_status(cls, response: aiohttp.ClientResponse) -> None:
148+
try:
149+
response.raise_for_status()
150+
except aiohttp.ClientResponseError as exc:
151+
content = await response.text()
152+
exc.message += f"\n\n{content}"
153+
raise exc

platform_container_runtime/service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ async def exec(
178178
return Stream(self._streaming_client, url=url)
179179

180180
async def kill(self, container_id: str, timeout_s: int = 0) -> None:
181+
# NOTE: For Containerd the StopContainer RPC is idempotent, and doesn't
182+
# raise an error if the container has already been stopped.
183+
# For Docker it raises an error.
181184
await self._cri_client.stop_container(
182185
container_id=container_id,
183186
timeout_s=timeout_s,

setup.cfg

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ platforms = any
1616
include_package_data = True
1717
install_requires =
1818
aiohttp==3.8.5
19-
yarl==1.9.2
2019
neuro-logging==21.12.2
21-
grpcio==1.56.2
22-
protobuf==4.21.12
20+
grpcio==1.66.1
21+
protobuf==5.27.2
2322
aiodocker==0.21.0
2423
docker-image-py==0.1.12
2524

@@ -33,7 +32,7 @@ exclude =
3332

3433
[options.extras_require]
3534
build-tools =
36-
grpcio-tools==1.56.2
35+
grpcio-tools==1.66.1
3736
dev =
3837
mypy==1.4.1
3938
mypy-protobuf==3.5.0

tests/integration/test_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ async def test_kill_unknown(
397397
self, api: ApiEndpoints, client: aiohttp.ClientSession
398398
) -> None:
399399
async with client.post(api.kill("unknown")) as resp:
400-
assert resp.status == HTTPNotFound.status_code, await resp.text()
400+
assert resp.status in (
401+
HTTPNoContent.status_code,
402+
HTTPNotFound.status_code,
403+
), await resp.text()
401404

402405
@pytest.mark.minikube
403406
async def test_commit(
@@ -563,4 +566,5 @@ async def test_commit_unknown_registry(
563566
"no such host" in error
564567
or "failure in name resolution" in error
565568
or "Name or service not known" in error
569+
or "server misbehaving" in error
566570
)

0 commit comments

Comments
 (0)