Skip to content

Commit 466e6aa

Browse files
authored
[MISC] Migrate to microceph (#155)
1 parent 0e64a4c commit 466e6aa

7 files changed

Lines changed: 70 additions & 25 deletions

File tree

.github/workflows/ci-gpu.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ jobs:
103103
snap alias microk8s.kubectl kubectl
104104
usermod -aG microk8s ubuntu
105105
106+
- name: Setup microceph
107+
run: |
108+
sudo snap install microceph
109+
sudo microceph cluster bootstrap
110+
sudo microceph disk add loop,1G,3
111+
sudo microceph enable rgw
112+
sudo microceph.radosgw-admin user create --uid test --display-name test --access-key=foo --secret-key=bar
113+
106114
- name: Configure user, microk8s and juju
107115
run: |
108116
su ubuntu -c "/bin/bash ./tests/integration/setup/setup-ec2-gpu.sh"
@@ -120,6 +128,8 @@ jobs:
120128
mv ./** /home/ubuntu/workdir
121129
chown -R ubuntu /home/ubuntu
122130
cd /home/ubuntu/workdir
131+
echo -e "S3_SERVER_URL=http://$(ip -4 -j route get 2.2.2.2 | yq '.[].prefsrc'):80/\nS3_ACCESS_KEY=foo\nS3_SECRET_KEY=bar" > .env
132+
chown ubuntu:ubuntu .env
123133
su ubuntu -c "~/.local/bin/tox run -e integration-gpu"
124134
125135
stop-runner:

.github/workflows/ci.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ jobs:
8888
df --human-readable
8989
- name: Checkout
9090
uses: actions/checkout@v5
91-
- name: Get prefsrc
92-
# One IP needed to test external access
93-
run: |
94-
echo "IPADDR=$(ip -4 -j route get 2.2.2.2 | jq -r '.[] | .prefsrc')" >> $GITHUB_ENV
91+
9592
- name: Setup operator environment
9693
# TODO: Replace with custom image on self-hosted runner
9794
uses: charmed-kubernetes/actions-operator@main
@@ -101,7 +98,18 @@ jobs:
10198
provider: microk8s
10299
channel: 1.32-strict/stable
103100
microk8s-group: snap_microk8s
104-
microk8s-addons: "rbac hostpath-storage dns minio metallb:${{ env.IPADDR }}-${{ env.IPADDR }}"
101+
microk8s-addons: "rbac hostpath-storage dns minio metallb:10.64.140.43-10.64.140.49"
102+
103+
- name: Setup microceph
104+
id: microceph
105+
run: |
106+
sudo snap install microceph
107+
sudo microceph cluster bootstrap
108+
sudo microceph disk add loop,1G,3
109+
sudo microceph enable rgw
110+
sudo microceph.radosgw-admin user create --uid test --display-name test --access-key=foo --secret-key=bar
111+
echo -e "S3_SERVER_URL=http://$(ip -4 -j route get 2.2.2.2 | jq -r '.[] | .prefsrc'):80/\nS3_ACCESS_KEY=foo\nS3_SECRET_KEY=bar" > .env
112+
105113
- name: Download packed charm(s)
106114
uses: actions/download-artifact@v5
107115
with:

poetry.lock

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ spark-k8s-test = "^0.0.4"
6969
jubilant = "^1.4.0"
7070
tomli = "^2.2.1"
7171
tomli-w = "^1.2.0"
72+
python-dotenv = "^1.2.1"
7273

7374
[tool.poetry.group.build-refresh-version]
7475
optional = true

tests/integration/conftest.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# See LICENSE file for licensing details.
44

55
import logging
6+
import os
67
import subprocess
78
from pathlib import Path
89
from string import Template
@@ -14,9 +15,11 @@
1415
import pytest
1516
import yaml
1617
from botocore.client import Config
18+
from dotenv import load_dotenv
1719

18-
from .types import IntegrationTestsCharms, TestCharm
20+
from .types import IntegrationTestsCharms, S3Info, TestCharm
1921

22+
load_dotenv()
2023
logger = logging.getLogger(__name__)
2124
logging.getLogger("jubilant.wait").setLevel(logging.WARNING)
2225

@@ -112,23 +115,29 @@ def charm_versions() -> IntegrationTestsCharms:
112115

113116

114117
@pytest.fixture(scope="module")
115-
def s3_bucket_and_creds(request: pytest.FixtureRequest):
118+
def s3_bucket_and_creds(request: pytest.FixtureRequest) -> Iterable[S3Info]:
116119
keep_models = bool(request.config.getoption("--keep-models"))
117-
logger.info("Fetching S3 credentials from minio.....")
118120

119-
fetch_s3_output = (
120-
subprocess.check_output(
121-
"./tests/integration/setup/fetch_s3_credentials.sh | tail -n 3",
122-
shell=True,
123-
stderr=None,
121+
if any(
122+
(
123+
(access_key := os.environ.get("S3_ACCESS_KEY", None)) is None,
124+
(secret_key := os.environ.get("S3_SECRET_KEY", None)) is None,
125+
(endpoint_url := os.environ.get("S3_SERVER_URL", None)) is None,
126+
)
127+
):
128+
logger.info("Fetching S3 credentials from minio.....")
129+
fetch_s3_output = (
130+
subprocess.check_output(
131+
"./tests/integration/setup/fetch_s3_credentials.sh | tail -n 3",
132+
shell=True,
133+
stderr=None,
134+
)
135+
.decode("utf-8")
136+
.strip()
124137
)
125-
.decode("utf-8")
126-
.strip()
127-
)
128-
129-
logger.info(f"fetch_s3_credentials output:\n{fetch_s3_output}")
130138

131-
endpoint_url, access_key, secret_key = fetch_s3_output.strip().splitlines()
139+
logger.info(f"fetch_s3_credentials output:\n{fetch_s3_output}")
140+
endpoint_url, access_key, secret_key = fetch_s3_output.strip().splitlines()
132141

133142
session = boto3.session.Session(aws_access_key_id=access_key, aws_secret_access_key=secret_key)
134143
s3 = session.resource(
@@ -155,13 +164,14 @@ def s3_bucket_and_creds(request: pytest.FixtureRequest):
155164
# Create the test bucket
156165
s3.create_bucket(Bucket=TEST_BUCKET_NAME)
157166
logger.info(f"Created bucket: {TEST_BUCKET_NAME}")
158-
test_bucket.put_object(Key=TEST_PATH_NAME)
167+
test_bucket.put_object(Key=os.path.join(TEST_PATH_NAME, "touch"))
159168
yield {
160-
"endpoint": endpoint_url,
161-
"access_key": access_key,
162-
"secret_key": secret_key,
169+
"endpoint": str(endpoint_url),
170+
"access_key": str(access_key),
171+
"secret_key": str(secret_key),
163172
"bucket": TEST_BUCKET_NAME,
164173
"path": TEST_PATH_NAME,
174+
"ca_bundle_path": os.environ.get("S3_CA_BUNDLE_PATH", ""),
165175
}
166176

167177
if not keep_models:

tests/integration/setup/setup-ec2-gpu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sudo microk8s status --wait-ready
88
mkdir ~/.kube
99
mkdir ~/workdir
1010
sudo microk8s config > ~/.kube/config
11-
sudo microk8s enable hostpath-storage dns rbac nvidia minio
11+
sudo microk8s enable hostpath-storage dns rbac nvidia
1212
sudo microk8s status --wait-ready
1313

1414
while ! sudo microk8s.kubectl logs -n gpu-operator-resources -l app=nvidia-operator-validator | grep "all validations are successful"

tests/integration/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"secret_key": str,
1414
"bucket": str,
1515
"path": str,
16+
"ca_bundle_path": str,
1617
},
1718
)
1819

0 commit comments

Comments
 (0)