← Back to Pull requests

Support pod clone for remote clients #30403

Open
axel7083 opened this pull request with 836 lines diff across 8 files
View on GitHub
axel7083 axel7083 commented on Nov 30, 2026 13:18 UTC
Author

Fixes https://github.com/podman-container-tools/podman/issues/29975

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:
<!-- Use [x] to mark as done, or click the checkbox after opening PR -->

  • I have read and understood our contributing guidelines and will not have more than two open PRs as a new contributor.

  • PR description, commit message, and GitHub comments are human-written, per LLM Policy

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by including your Signed-off-by line in all

  • commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. Read the DCO Sign-off requirements
    and ensure you follow them before signing off your commits.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)

  • Tests have been added/updated (or no tests are needed)

  • Documentation has been updated (or no documentation changes are needed)

  • All commits pass make validatepr (format/lint checks)

  • Release note entered in the section below (or None if no user-facing changes)
  • Does this PR introduce a user-facing change?

    Following https://github.com/podman-container-tools/podman/pull/30049 (podman container clone) adding the second (and last) part: podman pod clone.

    :new: the good news: The pod clone e2e tests now also run against remote

    ``release-note
    Support podman pod clone on remote target
    ``

    disclose: I used AI to help me implement the fix

    Diff: 836 lines (+830 / -6) across 8 files Reviewer: Honny1 Review duration: 6950m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.58) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.58 · 836 lines diff across 8 files
    0.58
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 5 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    91%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    11 items
    Honny1 Honny1 commented on code on Dec 01, 2026 12:02 UTC
    Code Review
    pkg/domain/infra/tunnel/pods.go:1
    @@ -203,8 +204,27 @@ func (ic *ContainerEngine) PodCreate(_ context.Context, specg entities.PodSpec)
     	return pods.CreatePodFromSpec(ic.ClientCtx, &specg)
     }
     
    -func (ic *ContainerEngine) PodClone(_ context.Context, _ entities.PodCloneOptions) (*entities.PodCloneReport, error) {
    -	return nil, nil
    +func (ic *ContainerEngine) PodClone(_ context.Context, podClone entities.PodCloneOptions) (*entities.PodCloneReport, error) {

    Please only call With* when the value is actually set (non-empty / true). Always sending empties/false works today mostly by accident via FillOutSpecGen, but it’s fragile (same footgun as wiping fields like GPUs).

    Honny1 Honny1 commented on code on Dec 01, 2026 12:03 UTC
    Code Review
    pkg/api/handlers/libpod/pods.go:1
    @@ -623,3 +623,75 @@ func PodStats(w http.ResponseWriter, r *http.Request) {
     		}
     	}
     }
    +
    +func PodClone(w http.ResponseWriter, r *http.Request) {
    +	runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
    +	var body handlers.PodCloneEntities
    +	if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
    +		utils.Error(w, http.StatusBadRequest, fmt.Errorf("decode(): %w", err))
    +		return
    +	}
    +
    +	perContainerOptions, err := newCloneCreateOptions(runtime)
    +	if err != nil {
    +		utils.InternalServerError(w, err)
    +		return
    +	}
    +	options := entities.PodCloneOptions{
    +		ID:                  utils.GetName(r),
    +		InfraOptions:        entities.NewInfraContainerCreateOptions(),
    +		PerContainerOptions: perContainerOptions,
    +	}
    +	options.InfraOptions.StopTimeout = perContainerOptions.StopTimeout
    +	setIfNotNil(&options.CreateOpts.Name, body.Name)
    +	setIfNotNil(&options.Start, body.Start)
    +	setIfNotNil(&options.Destroy, body.Destroy)
    +
    +	c := &options.InfraOptions
    +	setIfNotNil(&c.BlkIOWeight, body.BlkIOWeight)
    +	c.BlkIOWeightDevice = body.BlkIOWeightDevice
    +	setIfNotNil(&c.CgroupParent, body.CgroupParent)
    +	setIfNotNil(&c.CPUShares, body.CPUShares)
    +	setIfNotNil(&c.CPUS, body.CPUs)
    +	setIfNotNil(&c.CPUSetCPUs, body.CPUSetCPUs)
    +	setIfNotNil(&c.CPUSetMems, body.CPUSetMems)
    +	c.Devices = body.Devices
    +	c.DeviceReadBPs = body.DeviceReadBPs
    +	c.DeviceWriteBPs = body.DeviceWriteBPs
    +	c.GIDMap = body.GIDMap
    +	c.GPUs = body.GPUs
    +	setIfNotNil(&c.Hostname, body.Hostname)
    +	c.Entrypoint = body.InfraCommand
    +	setIfNotNil(&c.ConmonPIDFile, body.InfraConmonPidFile)
    +	setIfNotNil(&c.Name, body.InfraName)
    +	for k, v := range body.Labels {
    +		c.Label = append(c.Label, k+"="+v)
    +	}
    +	setIfNotNil(&c.Memory, body.Memory)
    +	setIfNotNil(&c.MemorySwap, body.MemorySwap)
    +	setIfNotNil(&c.PID, body.PID)
    +	setIfNotNil(&c.Restart, body.Restart)
    +	c.SecurityOpt = body.SecurityOpt
    +	setIfNotNil(&c.ShmSize, body.ShmSize)
    +	setIfNotNil(&c.ShmSizeSystemd, body.ShmSizeSystemd)
    +	setIfNotNil(&c.SubGIDName, body.SubGIDName)
    +	setIfNotNil(&c.SubUIDName, body.SubUIDName)
    +	c.Sysctl = body.Sysctl
    +	c.UIDMap = body.UIDMap
    +	setIfNotNil(&c.UserNS, body.UserNS)
    +	setIfNotNil(&c.UTS, body.UTS)
    +	c.Volume = body.Volume
    +	c.VolumesFrom = body.VolumesFrom
    +
    +	containerEngine := abi.ContainerEngine{Libpod: runtime}
    +	report, err := containerEngine.PodClone(r.Context(), options)
    +	if err != nil {
    +		if errors.Is(err, define.ErrNoSuchPod) {
    +			utils.PodNotFound(w, options.ID, err)
    +			return
    +		}
    +		utils.InternalServerError(w, err)
    +		return
    +	}
    +	utils.WriteResponse(w, http.StatusCreated, report)

    Prefer returning entities.IDResponse{ID: report.Id} so this matches swagger/ pod create/container clone.

    Honny1 Honny1 approved these changes on Dec 01, 2026 13:10 UTC
    Approved Reviewer

    LGTM

    PTAL @podman-container-tools/podman-reviewers @podman-container-tools/podman-maintainers

    mheon mheon commented on Dec 01, 2026 14:04 UTC
    Contributor

    Weird that we didn't support this already, I didn't realize we had gaps like this. Might be worth pointing an LLM at this to fuzz what commands are missing from remote and verify they all have a valid reason.

    mheon mheon commented on code on Dec 01, 2026 14:11 UTC
    Code Review
    pkg/bindings/pods/types.go:1
    @@ -82,3 +82,49 @@ type RemoveOptions struct {
     //
     //go:generate go run ../generator/generator.go ExistsOptions
     type ExistsOptions struct{}
    +
    +// CloneOptions are optional options for cloning a pod.
    +//
    +//go:generate go run ../generator/generator.go CloneOptions
    +type CloneOptions struct {

    Can we share this with PodCloneEntitites? Would simplify things a bit if we could - no copying from one to the other when we do the REST API operation?

    axel7083 axel7083 commented on code on Dec 01, 2026 15:50 UTC
    Code Review
    pkg/bindings/pods/types.go:1
    @@ -82,3 +82,49 @@ type RemoveOptions struct {
     //
     //go:generate go run ../generator/generator.go ExistsOptions
     type ExistsOptions struct{}
    +
    +// CloneOptions are optional options for cloning a pod.
    +//
    +//go:generate go run ../generator/generator.go CloneOptions
    +type CloneOptions struct {

    Good point, I've merged them: pods.CloneOptions now carries the JSON tags and the handler decodes into it directly, so PodCloneEntities is gone (the swagger model keeps the same name). Container clone from #30049 still has the two separate types, so it may need a follow-up to match this pattern.

    Honny1 Honny1 commented on Dec 03, 2026 16:38 UTC
    Contributor

    @mheon

    mheon mheon commented on code on Dec 03, 2026 21:38 UTC
    Code Review
    pkg/domain/infra/tunnel/pods.go:1
    @@ -203,8 +204,74 @@ func (ic *ContainerEngine) PodCreate(_ context.Context, specg entities.PodSpec)
     	return pods.CreatePodFromSpec(ic.ClientCtx, &specg)
     }
     
    -func (ic *ContainerEngine) PodClone(_ context.Context, _ entities.PodCloneOptions) (*entities.PodCloneReport, error) {
    -	return nil, nil
    +func (ic *ContainerEngine) PodClone(_ context.Context, podClone entities.PodCloneOptions) (*entities.PodCloneReport, error) {
    +	c := podClone.InfraOptions
    +	// Label files are on the client, read them here.
    +	labels, err := parse.GetAllLabels(c.LabelFile, c.Label)
    +	if err != nil {
    +		return nil, err
    +	}
    +	// Only send the options that are set, unset options keep the value of the original pod.
    +	options := new(pods.CloneOptions)

    Do we still need this? Could just pass podClone over the network, no?

    mheon mheon commented on code on Dec 03, 2026 21:38 UTC
    Code Review
    pkg/domain/infra/tunnel/pods.go:1
    @@ -203,8 +204,74 @@ func (ic *ContainerEngine) PodCreate(_ context.Context, specg entities.PodSpec)
     	return pods.CreatePodFromSpec(ic.ClientCtx, &specg)
     }
     
    -func (ic *ContainerEngine) PodClone(_ context.Context, _ entities.PodCloneOptions) (*entities.PodCloneReport, error) {
    -	return nil, nil
    +func (ic *ContainerEngine) PodClone(_ context.Context, podClone entities.PodCloneOptions) (*entities.PodCloneReport, error) {

    Should probably accept a *entities.PodCloneOptions

    axel7083 axel7083 commented on code on Dec 04, 2026 09:39 UTC
    Code Review
    pkg/domain/infra/tunnel/pods.go:1
    @@ -203,8 +204,74 @@ func (ic *ContainerEngine) PodCreate(_ context.Context, specg entities.PodSpec)
     	return pods.CreatePodFromSpec(ic.ClientCtx, &specg)
     }
     
    -func (ic *ContainerEngine) PodClone(_ context.Context, _ entities.PodCloneOptions) (*entities.PodCloneReport, error) {
    -	return nil, nil
    +func (ic *ContainerEngine) PodClone(_ context.Context, podClone entities.PodCloneOptions) (*entities.PodCloneReport, error) {

    From my understanding PodCloneOptions is filled with defaults from the client's containers.conf (volumes, ulimits, timezone…), which would then be applied on the server.

    Its fields are also plain values, so the server can't tell unset from empty. That's why the handler builds the defaults on the server side, same as container clone in #30049.

    Reviewers
    Assignees
    axel7083 axel7083
    Labels
    risk: low confidence: 91.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 58.2% (MEDIUM) · Higher = larger blast radius
    58.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 91.3% · Lower = rushed or shallow review
    91.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.1% · Safe to merge
    5.1%