mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
* ci: key the ECR Public prefetch on the classes that start each image prefetch-images.sh keyed the four Lambda runtimes on any /lambda/ path in shard.txt, and partition.sh spreads the Lambda tests over every shard, so each of the four shards pulled all four runtimes (674 MiB) plus the Firelens router (105 MiB) from ECR Public anonymously before its tests started. ECR Public counts that transfer per runner IP, and once the quota is spent every later anonymous pull fails with "toomanyrequests: Data limit exceeded", which is how a 2 MiB busybox pull took a shard down on main twice on 2026-09-27. Measured from a full four-shard run by pairing each ImageCacheService "Pulling image" / "Image already present locally" line with the class that logged it: nodejs:20 is reached from every shard, python:3.14 and python:3.12 each have one Docker-backed class, nodejs:18 was pulled by every shard and started by none, and the Firelens router has one class. Each entry now keys on those classes, which cuts a shard's ECR Public prefetch from about 800 MiB to between 120 and 330 MiB. A class the list misses pulls inline, as before. The tests also used three busybox tags (latest, 1.36, stable) for the same 2 MiB image. They now share one pin, TestImages.BUSYBOX (busybox:stable, the tag application.yml and the compatibility suites already use), and the prefetch script reads that pin from the class the way it reads the sidecar pins from application.yml, so one prefetch serves every test and the two cannot drift apart. The one test that pulls the other architecture keeps a tag of its own: a foreign-platform pull replaces what the local tag points at on a daemon without the containerd image store, and the docker build in the VolumesFrom test resolves its base from that local tag. Each key that names a class is checked against src/test/java, and a stale name is written to the log, so a rename cannot silently turn a prefetch off. The prefetch also set off ECR Public's per-second limit on its own: every pull started in the background at once, so the shard's ECR Public pulls landed in the same second. They are now queued and pulled one after another, a second apart, small images first because core/common/docker sorts near the top of every shard, while the Docker Hub pulls stay parallel. And each pull now writes one result line to prefetch-images.log, printed by a step after the tests, so a failed or still-running prefetch can be told apart from a test pulling the image itself. * ci: pull the Docker library test images from Docker Hub The first run of the prefetch results log showed where the quota actually runs out. On the two shards that failed, the very first pull of the job, docker/library/busybox or docker/library/python from the ECR Public mirror, came back with "toomanyrequests: Data limit exceeded" before the job had transferred anything, so the shard's own volume was not what spent it. The same runner then pulled busybox from Docker Hub seven seconds later and a 116 MiB lambda/ image from ECR Public half a minute after that, both fine. The mirror at public.ecr.aws/docker/library has an anonymous quota of its own, shared by runner IP and often already spent when a job starts, while GitHub-hosted runners pull Docker Hub without a limit: the fourteen Docker Hub images each shard prefetches have never failed. TestImages now names busybox and python-alpine the Docker Hub way, with the reason in its Javadoc, and the prefetch pulls them with the other Docker Hub images instead of queuing them behind the ECR Public runtimes. The three python-alpine literals share one pin. The pin is read with a regex that tolerates spacing, and a pin the script cannot read writes a "prefetch skipped" line instead of silently pulling nothing. An image two entries name is pulled once. The results step also lists any docker pull still running, so an early exit does not make an unfinished pull look like one that never ran. * test(compat): pull the SageMaker and CodeBuild images from Docker Hub The SageMaker compatibility tests (Java and Python) and the CodeBuild one named busybox through the public.ecr.aws/docker/library mirror, the same namespace whose anonymous quota fails the Build and Test shards, and the native Python jobs of another PR failed on it the same way. They now name the image the Docker Hub way. The CodeBuild digest is the same on both registries, so that reference only changes its host.
75 lines
3.2 KiB
Python
75 lines
3.2 KiB
Python
import os
|
|
import time
|
|
import uuid
|
|
|
|
import boto3
|
|
import pytest
|
|
from botocore.config import Config
|
|
|
|
|
|
def client(service):
|
|
return boto3.client(
|
|
service,
|
|
# Every other test file gets this from the conftest.py fixtures, which read
|
|
# FLOCI_ENDPOINT (the test runner container's compat-net hostname for floci, e.g.
|
|
# http://floci:4566). This file has no fixture of its own, so it must read the same
|
|
# variable directly instead of hardcoding localhost, which only resolves to floci
|
|
# when running the suite straight on the host rather than in its own CI container.
|
|
endpoint_url=os.environ.get("FLOCI_ENDPOINT", "http://localhost:4566"),
|
|
region_name="us-east-1",
|
|
aws_access_key_id="test",
|
|
aws_secret_access_key="test",
|
|
config=Config(retries={"max_attempts": 1}),
|
|
)
|
|
|
|
|
|
def test_sagemaker_control_plane_and_training():
|
|
sm = client("sagemaker")
|
|
s3 = client("s3")
|
|
suffix = uuid.uuid4().hex[:8]
|
|
model = f"compat-sm-{suffix}"
|
|
cfg = f"compat-sm-cfg-{suffix}"
|
|
bucket = f"compat-sm-{suffix}"
|
|
|
|
sm.create_model(ModelName=model, PrimaryContainer={"Image": "busybox:stable"}, ExecutionRoleArn="arn:aws:iam::000000000000:role/r")
|
|
assert sm.describe_model(ModelName=model)["ModelName"] == model
|
|
sm.create_endpoint_config(EndpointConfigName=cfg, ProductionVariants=[{"VariantName": "AllTraffic", "ModelName": model, "InitialInstanceCount": 1, "InstanceType": "ml.t2.medium"}])
|
|
assert any(c["EndpointConfigName"] == cfg for c in sm.list_endpoint_configs()["EndpointConfigs"])
|
|
|
|
s3.create_bucket(Bucket=bucket)
|
|
s3.put_object(Bucket=bucket, Key="input/data.txt", Body=b"hello")
|
|
job = f"compat-train-{suffix}"
|
|
sm.create_training_job(
|
|
TrainingJobName=job,
|
|
RoleArn="arn:aws:iam::000000000000:role/r",
|
|
AlgorithmSpecification={
|
|
"TrainingImage": "busybox:stable",
|
|
"TrainingInputMode": "File",
|
|
"ContainerEntrypoint": ["/bin/sh", "-c"],
|
|
"ContainerArguments": ["mkdir -p /opt/ml/model && echo ok > /opt/ml/model/model.txt"],
|
|
},
|
|
InputDataConfig=[{
|
|
"ChannelName": "train",
|
|
"DataSource": {"S3DataSource": {"S3DataType": "S3Prefix", "S3Uri": f"s3://{bucket}/input"}},
|
|
}],
|
|
OutputDataConfig={"S3OutputPath": f"s3://{bucket}/output"},
|
|
ResourceConfig={"InstanceType": "ml.m5.large", "InstanceCount": 1, "VolumeSizeInGB": 1},
|
|
StoppingCondition={"MaxRuntimeInSeconds": 60},
|
|
)
|
|
deadline = time.time() + 120
|
|
while time.time() < deadline:
|
|
desc = sm.describe_training_job(TrainingJobName=job)
|
|
if desc["TrainingJobStatus"] == "Completed":
|
|
artifact = desc["ModelArtifacts"]["S3ModelArtifacts"]
|
|
key = artifact.split(f"s3://{bucket}/", 1)[1]
|
|
assert s3.get_object(Bucket=bucket, Key=key)["Body"].read()
|
|
break
|
|
if desc["TrainingJobStatus"] == "Failed":
|
|
pytest.fail(desc.get("FailureReason", "training failed"))
|
|
time.sleep(1)
|
|
else:
|
|
pytest.fail("Timed out waiting for SageMaker training job")
|
|
|
|
sm.delete_endpoint_config(EndpointConfigName=cfg)
|
|
sm.delete_model(ModelName=model)
|