fix: Skip loading images when already done

This commit is contained in:
TheiLLeniumStudios
2026-01-09 00:34:09 +01:00
parent 76287e0420
commit 2442eddd81
3 changed files with 60 additions and 39 deletions

View File

@@ -162,6 +162,7 @@ runs:
ARGS="$ARGS --scenario=${{ inputs.scenarios }}"
ARGS="$ARGS --duration=${{ inputs.duration }}"
ARGS="$ARGS --cluster-name=${{ steps.cluster.outputs.name }}"
ARGS="$ARGS --skip-image-load"
if [ -n "${{ steps.images.outputs.old }}" ]; then
ARGS="$ARGS --old-image=${{ steps.images.outputs.old }}"

View File

@@ -29,14 +29,24 @@ func NewManager(cfg Config) *Manager {
}
// DetectContainerRuntime finds available container runtime.
// It checks if the runtime daemon is actually running, not just if the binary exists.
func DetectContainerRuntime() (string, error) {
if _, err := exec.LookPath("podman"); err == nil {
return "podman", nil
}
// Prefer docker as it's more commonly used with kind
if _, err := exec.LookPath("docker"); err == nil {
// Verify docker daemon is running
cmd := exec.Command("docker", "info")
if err := cmd.Run(); err == nil {
return "docker", nil
}
return "", fmt.Errorf("neither docker nor podman found in PATH")
}
if _, err := exec.LookPath("podman"); err == nil {
// Verify podman is functional (check if we can run a basic command)
cmd := exec.Command("podman", "info")
if err := cmd.Run(); err == nil {
return "podman", nil
}
}
return "", fmt.Errorf("neither docker nor podman is running")
}
// Exists checks if the cluster already exists.

View File

@@ -29,6 +29,7 @@ type RunConfig struct {
Scenario string
Duration int
SkipCluster bool
SkipImageLoad bool
ClusterName string
ResultsDir string
ManifestsDir string
@@ -76,6 +77,7 @@ func init() {
runCmd.Flags().IntVar(&runCfg.Duration, "duration", 60, "Test duration in seconds")
runCmd.Flags().IntVar(&runCfg.Parallelism, "parallelism", 1, "Run N scenarios in parallel on N clusters")
runCmd.Flags().BoolVar(&runCfg.SkipCluster, "skip-cluster", false, "Skip kind cluster creation (use existing)")
runCmd.Flags().BoolVar(&runCfg.SkipImageLoad, "skip-image-load", false, "Skip loading images into kind (use when images already loaded)")
runCmd.Flags().StringVar(&runCfg.ClusterName, "cluster-name", DefaultClusterName, "Kind cluster name")
runCmd.Flags().StringVar(&runCfg.ResultsDir, "results-dir", "./results", "Directory for results")
runCmd.Flags().StringVar(&runCfg.ManifestsDir, "manifests-dir", "", "Directory containing manifests (auto-detected if not set)")
@@ -179,6 +181,9 @@ func runSequential(ctx context.Context, cfg RunConfig, scenariosToRun []string,
}
defer promMgr.StopPortForward()
if cfg.SkipImageLoad {
log.Println("Skipping image loading (--skip-image-load)")
} else {
log.Println("Loading images into kind cluster...")
if runOld {
log.Printf("Loading old image: %s", cfg.OldImage)
@@ -196,6 +201,7 @@ func runSequential(ctx context.Context, cfg RunConfig, scenariosToRun []string,
log.Println("Pre-loading test images...")
testImage := "gcr.io/google-containers/busybox:1.27"
clusterMgr.LoadImage(ctx, testImage)
}
kubeClient, err := getKubeClient("")
if err != nil {
@@ -422,6 +428,9 @@ func setupWorker(ctx context.Context, cfg RunConfig, workerID int, runtime strin
return nil, fmt.Errorf("starting prometheus port-forward: %w", err)
}
if cfg.SkipImageLoad {
log.Printf("[Worker %d] Skipping image loading (--skip-image-load)", workerID)
} else {
log.Printf("[Worker %d] Loading images...", workerID)
if runOld {
if err := clusterMgr.LoadImage(ctx, cfg.OldImage); err != nil {
@@ -436,6 +445,7 @@ func setupWorker(ctx context.Context, cfg RunConfig, workerID int, runtime strin
testImage := "gcr.io/google-containers/busybox:1.27"
clusterMgr.LoadImage(ctx, testImage)
}
kubeClient, err := getKubeClient(kubeContext)
if err != nil {