Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
Fix pseudostate in statusform
Browse files Browse the repository at this point in the history
This is to fix:

HTTP/1.0" 500 47
ERRO Cannot load machine: machine crc does not exist
\\.\pipe\crc-http - - [29/Jun/2021:14:19:39 +0800] "GET /api/status HTTP/1.0" 500 47
ERRO Cannot load machine: machine crc does not exist
\\.\pipe\crc-http - - [29/Jun/2021:14:19:44 +0800] "GET /api/status HTTP/1.0" 500 47

in which the daemon returns a 500 (n result is returned), but we do need
to have some status shown. In the application we use a the Success flag
to determine if a call was successful. In this case, the StatusForm can
show a psuedostate of Stopped instead.

Without this change:

     Invoke(c, new StatusResult { CrcStatus = InitialState, OpenshiftStatus = "Stopped"});

will cause the StatusForm to flicker Stopped, Running on failing
requests that either timedout or were cancelled.
  • Loading branch information
gbraad authored and anjannath committed Jun 29, 2021
1 parent 02e7598 commit 8842c99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
24 changes: 9 additions & 15 deletions Forms/StatusForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,24 @@ private void UpdateReceived(StatusResult status)
}
else
{
var cacheFolderPath = string.Format("{0}\\.crc\\cache",
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
if (status.Success)
{
if (status.CrcStatus != "")
CrcStatus.Text = status.CrcStatus;

if (status.CrcStatus != "")
CrcStatus.Text = status.CrcStatus;
if (status.OpenshiftStatus != "")
OpenShiftStatus.Text = StatusText(status);
}

if (status.OpenshiftStatus != "")
OpenShiftStatus.Text = StatusText(status);
var cacheFolderPath = string.Format("{0}\\.crc\\cache",
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));

DiskUsage.Text = string.Format("{0} of {1} (Inside the CRC VM)",
FileSize.HumanReadable(status.DiskUse), FileSize.HumanReadable(status.DiskSize));
CacheUsage.Text = FileSize.HumanReadable(GetFolderSize.SizeInBytes(cacheFolderPath));
CacheFolder.Text = cacheFolderPath;
}
}
else
{
// TODO: workaround for no VM
if (CrcStatus.InvokeRequired)
{
UpdateReceivedCallback c = UpdateReceived;
Invoke(c, new StatusResult { CrcStatus = InitialState, OpenshiftStatus = "Stopped"});
}
}
}

private static string StatusText(StatusResult status)
Expand Down
6 changes: 3 additions & 3 deletions Helpers/Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public static StatusResult Status()
{
StatusResult result = getResultsOrDefault(DaemonCommander.Status);

if (StatusReceived != null)
StatusReceived(result);

// TODO: workaround for daemon returning 500/Error state when no VM exists
if (result == null)
return null;

if (StatusReceived != null)
StatusReceived(result);

lock (_statusChangeLock)
{
if (StatusChanged != null && _previousStatus != result.OpenshiftStatus)
Expand Down

0 comments on commit 8842c99

Please sign in to comment.