This commit is contained in:
@@ -22,6 +22,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python3 -m py_compile controller.py
|
python3 -m py_compile controller.py
|
||||||
python3 -m unittest discover -s tests -v
|
python3 -m unittest discover -s tests -v
|
||||||
|
sh -n scripts/install-controller.sh scripts/ces-controller
|
||||||
|
|
||||||
|
- name: Deploy verified controller
|
||||||
|
run: |
|
||||||
|
sh scripts/install-controller.sh "$GITHUB_SHA"
|
||||||
|
test "$(cat /opt/ces-controller/current/VERSION)" = "$GITHUB_SHA"
|
||||||
|
/usr/local/bin/ces-controller --help >/dev/null
|
||||||
|
|
||||||
- name: Confirm no paid action ran
|
- name: Confirm no paid action ran
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -23,17 +23,15 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
AUTODL_API_TOKEN: ${{ secrets.AUTODL_API_TOKEN }}
|
AUTODL_API_TOKEN: ${{ secrets.AUTODL_API_TOKEN }}
|
||||||
TRAINING_RUNNER_REGISTRATION_TOKEN: ${{ secrets.TRAINING_RUNNER_REGISTRATION_TOKEN }}
|
TRAINING_RUNNER_REGISTRATION_TOKEN: ${{ secrets.TRAINING_RUNNER_REGISTRATION_TOKEN }}
|
||||||
GITEA_JOB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
OPERATION: ${{ inputs.operation }}
|
OPERATION: ${{ inputs.operation }}
|
||||||
IMAGE_UUID: ${{ inputs.image_uuid }}
|
IMAGE_UUID: ${{ inputs.image_uuid }}
|
||||||
CONFIRM_SPEND: ${{ inputs.confirm_spend }}
|
CONFIRM_SPEND: ${{ inputs.confirm_spend }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout controller source
|
- name: Select deployed controller
|
||||||
run: |
|
run: |
|
||||||
git init .
|
test -x /usr/local/bin/ces-controller
|
||||||
git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git"
|
test "$(cat /opt/ces-controller/current/VERSION)" = "$GITHUB_SHA"
|
||||||
git -c http.extraHeader="Authorization: token $GITEA_JOB_TOKEN" fetch --depth 1 origin "$GITHUB_SHA"
|
echo "controller_version=$GITHUB_SHA"
|
||||||
git checkout --detach FETCH_HEAD
|
|
||||||
|
|
||||||
- name: Validate requested operation
|
- name: Validate requested operation
|
||||||
run: |
|
run: |
|
||||||
@@ -44,7 +42,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Manage AutoDL Pro instance
|
- name: Manage AutoDL Pro instance
|
||||||
run: |
|
run: |
|
||||||
python3 controller.py "$OPERATION" \
|
/usr/local/bin/ces-controller "$OPERATION" \
|
||||||
--image-uuid "$IMAGE_UUID" \
|
--image-uuid "$IMAGE_UUID" \
|
||||||
--confirm-spend "$CONFIRM_SPEND"
|
--confirm-spend "$CONFIRM_SPEND"
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,26 @@ AutoDL GPU Runner 的 `TRAINING_RUNNER_REGISTRATION_TOKEN`。
|
|||||||
|
|
||||||
Runner online 后,第一次 push 只执行 `Controller CI`,不会创建实例或产生 AutoDL 费用。
|
Runner online 后,第一次 push 只执行 `Controller CI`,不会创建实例或产生 AutoDL 费用。
|
||||||
|
|
||||||
|
## 阿里云长期部署
|
||||||
|
|
||||||
|
每次 push 到 `main` 后,`Controller CI` 会先运行测试,再把通过验证的控制器安装到:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/opt/ces-controller/releases/<git-commit>/
|
||||||
|
```
|
||||||
|
|
||||||
|
`/opt/ces-controller/current` 原子指向当前版本,并安装 Terminal 入口
|
||||||
|
`/usr/local/bin/ces-controller`。管理 workflow 只执行这个长期部署的版本,并拒绝执行与当前
|
||||||
|
workflow commit 不一致的旧版本。部署目录不保存 AutoDL Token 或 Runner Registration Token;
|
||||||
|
Secret 仍只在单次 Actions 任务中注入。
|
||||||
|
|
||||||
|
通过 SSH 可以检查版本或查看帮助:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat /opt/ces-controller/current/VERSION
|
||||||
|
ces-controller --help
|
||||||
|
```
|
||||||
|
|
||||||
## 管理 workflow
|
## 管理 workflow
|
||||||
|
|
||||||
从 Actions 手动运行 `Manage AutoDL GPU runner`:
|
从 Actions 手动运行 `Manage AutoDL GPU runner`:
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
exec python3 /opt/ces-controller/current/controller.py "$@"
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ] || [ -z "$1" ]; then
|
||||||
|
echo "usage: $0 GIT_COMMIT" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
commit=$1
|
||||||
|
root=/opt/ces-controller
|
||||||
|
release="$root/releases/$commit"
|
||||||
|
temporary_link="$root/.current.$$"
|
||||||
|
|
||||||
|
install -d -m 700 "$root" "$root/releases" "$release"
|
||||||
|
install -m 700 controller.py "$release/controller.py"
|
||||||
|
install -m 600 README.md "$release/README.md"
|
||||||
|
printf '%s\n' "$commit" > "$release/VERSION"
|
||||||
|
chmod 600 "$release/VERSION"
|
||||||
|
|
||||||
|
ln -s "$release" "$temporary_link"
|
||||||
|
mv -Tf "$temporary_link" "$root/current"
|
||||||
|
install -m 755 scripts/ces-controller /usr/local/bin/ces-controller
|
||||||
|
|
||||||
|
echo "deployed_controller=$commit"
|
||||||
Reference in New Issue
Block a user