Skip to content

Commit d2f1234

Browse files
committed
Add "NoVM" state
This would simplify podman-desktop ext status handling Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
1 parent 2671ff9 commit d2f1234

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

cmd/crc/cmd/status.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/crc-org/crc/v2/pkg/crc/constants"
1414
"github.com/crc-org/crc/v2/pkg/crc/daemonclient"
1515
crcErrors "github.com/crc-org/crc/v2/pkg/crc/errors"
16+
"github.com/crc-org/crc/v2/pkg/crc/machine/state"
1617
"github.com/crc-org/crc/v2/pkg/crc/machine/types"
1718
"github.com/crc-org/crc/v2/pkg/crc/preset"
1819
"github.com/docker/go-units"
@@ -146,6 +147,9 @@ func getStatus(client *daemonclient.Client, cacheDir string) *status {
146147
}
147148
return &status{Success: false, Error: crcErrors.ToSerializableError(err)}
148149
}
150+
if clusterStatus.CrcStatus == string(state.NoVM) {
151+
return &status{Success: false, Error: crcErrors.ToSerializableError(crcErrors.VMNotExist)}
152+
}
149153
var size int64
150154
err = filepath.Walk(cacheDir, func(_ string, info os.FileInfo, err error) error {
151155
if !info.IsDir() {

pkg/crc/api/handlers.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ func NewHandler(config *crcConfig.Config, machine machine.Client, logger Logger,
5050
}
5151

5252
func (h *Handler) Status(c *context) error {
53-
exists, err := h.Client.Exists()
54-
if err != nil {
55-
return err
56-
}
57-
if !exists {
58-
return c.String(http.StatusInternalServerError, string(errors.VMNotExist))
59-
}
60-
6153
res, err := h.Client.Status()
6254
if err != nil {
6355
return err

pkg/crc/machine/state/state.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const (
1010
Stopped State = "Stopped"
1111
Stopping State = "Stopping"
1212
Starting State = "Starting"
13+
NoVM State = "NoVM"
1314
Error State = "Error"
1415
)
1516

pkg/crc/machine/status.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ func (client *client) Status() (*types.ClusterStatusResult, error) {
1818
if err != nil {
1919
if errors.Is(err, errMissingHost(client.name)) {
2020
return &types.ClusterStatusResult{
21-
CrcStatus: state.Stopped,
22-
OpenshiftStatus: types.OpenshiftStopped,
21+
CrcStatus: state.NoVM,
2322
}, nil
2423
}
2524
return nil, errors.Wrap(err, fmt.Sprintf("Cannot load '%s' virtual machine", client.name))

0 commit comments

Comments
 (0)