Fix templateId not applying disk and volume settings from template#219
Fix templateId not applying disk and volume settings from template#219pantafive wants to merge 1 commit intorunpod:mainfrom
Conversation
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
There was a problem hiding this comment.
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.
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.
Summary
--templateIdis specified, disk/volume settings from template are now used instead of being overwritten by CLI flag defaultsProblem
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
omitemptytocontainerDiskInGb,volumeInGb,volumeMountPathJSON tagsTemplateFieldFlagsstruct andClearUnchangedTemplateFieldsmethod to clear these fields when templateId is set and flags were not explicitly changedFixes #163