mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-10 15:55:01 +00:00
fix(lxc): create container when authenticated with API token (#610)
And also fix container startup behaviour: "error starting container ... - already running" Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
06ad00463c
commit
32bdc94167
@ -1226,10 +1226,18 @@ func containerCreateCustom(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
keyctl := types.CustomBool(featuresBlock[mkResourceVirtualEnvironmentContainerFeaturesKeyControl].(bool))
|
keyctl := types.CustomBool(featuresBlock[mkResourceVirtualEnvironmentContainerFeaturesKeyControl].(bool))
|
||||||
fuse := types.CustomBool(featuresBlock[mkResourceVirtualEnvironmentContainerFeaturesFUSE].(bool))
|
fuse := types.CustomBool(featuresBlock[mkResourceVirtualEnvironmentContainerFeaturesFUSE].(bool))
|
||||||
|
|
||||||
features := containers.CustomFeatures{
|
features := containers.CustomFeatures{}
|
||||||
Nesting: &nesting,
|
|
||||||
KeyControl: &keyctl,
|
if nesting {
|
||||||
FUSE: &fuse,
|
features.Nesting = &nesting
|
||||||
|
}
|
||||||
|
|
||||||
|
if keyctl {
|
||||||
|
features.KeyControl = &keyctl
|
||||||
|
}
|
||||||
|
|
||||||
|
if fuse {
|
||||||
|
features.FUSE = &fuse
|
||||||
}
|
}
|
||||||
|
|
||||||
initialization := d.Get(mkResourceVirtualEnvironmentContainerInitialization).([]interface{})
|
initialization := d.Get(mkResourceVirtualEnvironmentContainerInitialization).([]interface{})
|
||||||
@ -1567,12 +1575,7 @@ func containerCreateStart(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
|
|
||||||
containerAPI := api.Node(nodeName).Container(vmID)
|
containerAPI := api.Node(nodeName).Container(vmID)
|
||||||
|
|
||||||
// Start the container and wait for it to reach a running state before continuing.
|
// A container was started by the create operation, so wait for it to be running.
|
||||||
err = containerAPI.StartContainer(ctx, 60)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = containerAPI.WaitForContainerState(ctx, "running", 120, 5)
|
err = containerAPI.WaitForContainerState(ctx, "running", 120, 5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user