Fixes #15154 Change order when config and connections are written

When the break out or the WSL environment fails to start, the config
and connections should not be written. Placing them at the end of the
provisioning step will mitigate the issue.

[NO NEW TESTS NEEDED]

Signed-off-by: Gerard Braad <me@gbraad.nl>
This commit is contained in:
Gerard Braad
2022-08-04 14:56:54 +08:00
parent b0ef621ebf
commit d4c6e056db

View File

@ -364,14 +364,6 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
return false, err
}
if err := v.writeConfig(); err != nil {
return false, err
}
if err := setupConnections(v, opts, sshDir); err != nil {
return false, err
}
dist, err := provisionWSLDist(v)
if err != nil {
return false, err
@ -393,6 +385,14 @@ func (v *MachineVM) Init(opts machine.InitOptions) (bool, error) {
// Cycle so that user change goes into effect
_ = terminateDist(dist)
if err := v.writeConfig(); err != nil {
return false, err
}
if err := setupConnections(v, opts, sshDir); err != nil {
return false, err
}
return true, nil
}