Skip to content

Commit

Permalink
Merge pull request #20115 from baude/hypervstarting
Browse files Browse the repository at this point in the history
hyperv: set more realistic starting state
  • Loading branch information
openshift-merge-robot authored Sep 24, 2023
2 parents 7359a2d + 08936db commit 9ba0022
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cmd/podman/machine/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ func toHumanFormat(vms []*machine.ListResponse) ([]*entities.ListReporter, error
response.Name = vm.Name
}
switch {
case vm.Running:
response.LastUp = "Currently running"
response.Running = true
case vm.Starting:
response.LastUp = "Currently starting"
response.Starting = true
case vm.Running:
response.LastUp = "Currently running"
response.Running = true
default:
response.LastUp = units.HumanDuration(time.Since(vm.LastUp)) + " ago"
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/hyperv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (v HyperVVirtualization) List(opts machine.ListOptions) ([]*machine.ListRes
CreatedAt: mm.Created,
LastUp: mm.LastUp,
Running: vm.State() == hypervctl.Enabled,
Starting: vm.IsStarting(),
Starting: mm.isStarting(),
Stream: mm.ImageStream,
VMType: machine.HyperVVirt.String(),
CPUs: mm.CPUs,
Expand Down
20 changes: 17 additions & 3 deletions pkg/machine/hyperv/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@ func (m *HyperVMachine) Start(name string, opts machine.StartOptions) error {
if err != nil {
return fmt.Errorf("unable to start host networking: %q", err)
}

// The "starting" status from hyper v is a very small windows and not really
// the same as what we want. so modeling starting behaviour after qemu
m.Starting = true
if err := m.writeConfig(); err != nil {
return fmt.Errorf("writing JSON file: %w", err)
}

if err := vm.Start(); err != nil {
return err
}
Expand All @@ -487,16 +495,18 @@ func (m *HyperVMachine) Start(name string, opts machine.StartOptions) error {
return err
}

// set starting back false now that we are running
m.Starting = false

if m.HostUser.Modified {
if machine.UpdatePodmanDockerSockService(m, name, m.UID, m.Rootful) == nil {
// Reset modification state if there are no errors, otherwise ignore errors
// which are already logged
m.HostUser.Modified = false
_ = m.writeConfig()
}
}

return nil
// Write the config with updated starting status and hostuser modification
return m.writeConfig()
}

func (m *HyperVMachine) State(_ bool) (machine.Status, error) {
Expand Down Expand Up @@ -718,3 +728,7 @@ func (m *HyperVMachine) resizeDisk(newSize strongunits.GiB) error {
}
return nil
}

func (m *HyperVMachine) isStarting() bool {
return m.Starting
}

0 comments on commit 9ba0022

Please sign in to comment.