Skip to content

Fix templateId not applying disk and volume settings from template#219

Open
pantafive wants to merge 1 commit intorunpod:mainfrom
pantafive:fix/template-id-disk-volume-settings
Open

Fix templateId not applying disk and volume settings from template#219
pantafive wants to merge 1 commit intorunpod:mainfrom
pantafive:fix/template-id-disk-volume-settings

Conversation

@pantafive
Copy link
Contributor

Summary

  • When --templateId is specified, disk/volume settings from template are now used instead of being overwritten by CLI flag defaults

Problem

CLI flags have non-zero defaults (--containerDiskSize=20, --volumeSize=1, --volumePath=/runpod) that were always sent to the API, overriding template settings even when user didn't explicitly set them.

Solution

  • Added omitempty to containerDiskInGb, volumeInGb, volumeMountPath JSON tags
  • Added TemplateFieldFlags struct and ClearUnchangedTemplateFields method to clear these fields when templateId is set and flags were not explicitly changed
  • Zero values are now omitted from JSON, allowing API to use template values

Fixes #163

  When --templateId is specified, CLI flag defaults (containerDiskSize=20,
  volumeSize=1, volumePath=/runpod) were overriding template settings.

  Now these fields are cleared when templateId is set and flags were not
  explicitly changed by the user, allowing template values to be used.

  Fixes runpod#163
Copy link
Contributor

@jojje jojje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR; The container disk size is not pulled from the template, but otherwise looks good.

Overall take on the PR

Can't think of a better way to balance the convenience of having "sensible defaults" in the CLI, and for being able to avoid having to explicitly repeat whatever was already defined in a template. So this seems a good compromise to me since if a user specifies a template, then it's most likely they intend for whatever is configured in the template to be used rather than whatever happens to be the default for the CLI options.

Here's an example template defined in the web console.

image

And here is the creation and resulting pod configuration using your PR in its current state.

go run main.go create pod --templateId d751tdf11q --gpuType "NVIDIA RTX A4500"

resulting pod config:

{
  "Id": "nkznyu6lsufvih",
  "ContainerDiskInGb": 20,
  "CostPerHr": 0.19,
  "DesiredStatus": "RUNNING",
  "DataCenterId": "",
  "DockerArgs": "sleep 3600",
  "Env": [
    "AN_ENV=alpine-env-var"
  ],
  "GpuCount": 1,
  "ImageName": "alpine",
  "MemoryInGb": 31,
  "Name": "alpine",
  "PodType": "RESERVED",
  "Ports": "",
  "VcpuCount": 8,
  "VolumeInGb": 1,
  "VolumeMountPath": "/runpod",
  "Machine": {
    "GpuDisplayName": "RTX A4500",
    "Location": "FR"
  },
  "Runtime": {
    "Ports": [
      {
        "Ip": "100.65.15.55",
        "IsIpPublic": false,
        "PrivatePort": 19123,
        "PublicPort": 60854,
        "PortType": "http"
      }
    ]
  }
}

As you can see ContainerDiskInGb isn't pulled from the template. it was set to 6GB in the template, but the CLI default of 20 was used instead.

Other thought

I think we need to create a holistic issue for template handling as these piece-meal issues and PRs tackling one or two option values at a time risk loosing track of the larger picture, that template handling isn't consistent. I made the same remark in a related issue, and I'll go ahead and create this overall issue where I'll link the relevant PRs and issues.

@jojje jojje mentioned this pull request Jan 22, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specifying --templateId does not apply disk and volume size/path settings

2 participants