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

Commit

Permalink
/api/start will throw an exception if it doesn’t start.
Browse files Browse the repository at this point in the history
There is no need to parse the status at the end.
  • Loading branch information
guillaumerose authored and anjannath committed May 18, 2021
1 parent 6680d74 commit 007e3c8
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions CodeReady Containers/DaemonCommander/Handlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,12 @@ func HandleStart() {
let appDelegate = NSApplication.shared.delegate as? AppDelegate
appDelegate?.initializeMenus(status: "Starting")
}
var response: Data
do {
response = try SendCommandToDaemon(HTTPMethod.GET, "/api/start")
displayNotification(title: "Starting Cluster", body: "Starting OpenShift Cluster, this could take a few minutes..")
_ = try SendCommandToDaemon(HTTPMethod.GET, "/api/start")
displayNotification(title: "Successfully started cluster", body: "OpenShift cluster is running")
} catch let error {
DispatchQueue.main.async {
showAlertFailedAndCheckLogs(message: "Failed to start OpenShift cluster", informativeMsg: "\(error)")
let appDelegate = NSApplication.shared.delegate as? AppDelegate
appDelegate?.pollStatus()
}
return
}
do {
let startResult = try JSONDecoder().decode(StartResult.self, from: response)
if startResult.Status == "Running" {
DispatchQueue.main.async {
let appDelegate = NSApplication.shared.delegate as? AppDelegate
appDelegate?.pollStatus()
displayNotification(title: "Successfully started Cluster", body: "OpenShift Cluster is running")
}
}
} catch let jsonErr {
displayNotification(title: "Cannot parse daemon answer", body: jsonErr.localizedDescription)
showAlertFailedAndCheckLogs(message: "Failed to start OpenShift cluster", informativeMsg: "\(error)")
}
}

Expand Down

0 comments on commit 007e3c8

Please sign in to comment.