Fix crash when parsing invalid kubevela in app creation message
Fixes https://bugs.launchpad.net/nebulous/+bug/2067032 Change-Id: I21690a3c4c314f54aaf7a242ba021415473aff3e
This commit is contained in:
parent
9bea9c4e43
commit
16090749b9
@ -213,17 +213,25 @@ public class NebulousApp {
|
|||||||
* Creates a NebulousApp object.
|
* Creates a NebulousApp object.
|
||||||
*
|
*
|
||||||
* @param app_message The whole app creation message (JSON)
|
* @param app_message The whole app creation message (JSON)
|
||||||
* @param kubevela A parsed representation of the deployable KubeVela App model (YAML)
|
* @param kubevela_string The deployable KubeVela App model (YAML string)
|
||||||
* @param ampl_message_channel A publisher for sending the generated AMPL file, or null
|
* @param ampl_message_channel A publisher for sending the generated AMPL file, or null
|
||||||
*/
|
*/
|
||||||
// Note that example KubeVela and parameter files can be found at
|
// Note that example KubeVela and parameter files can be found at
|
||||||
// optimiser-controller/src/test/resources/
|
// optimiser-controller/src/test/resources/
|
||||||
public NebulousApp(JsonNode app_message, ObjectNode kubevela, ExnConnector exnConnector) {
|
public NebulousApp(JsonNode app_message, String kubevela_string, ExnConnector exnConnector) {
|
||||||
this.UUID = app_message.at(uuid_path).textValue();
|
this.UUID = app_message.at(uuid_path).textValue();
|
||||||
this.name = app_message.at(name_path).textValue();
|
this.name = app_message.at(name_path).textValue();
|
||||||
this.state = State.NEW;
|
this.state = State.NEW;
|
||||||
this.clusterName = NebulousApps.calculateUniqueClusterName(this.UUID);
|
this.clusterName = NebulousApps.calculateUniqueClusterName(this.UUID);
|
||||||
this.originalAppMessage = app_message;
|
this.originalAppMessage = app_message;
|
||||||
|
ObjectNode kubevela = null;
|
||||||
|
try {
|
||||||
|
kubevela = (ObjectNode)readKubevelaString(kubevela_string);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
this.state = State.FAILED;
|
||||||
|
log.error("Could not parse KubeVela YAML in app creation message: " + e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.originalKubevela = kubevela;
|
this.originalKubevela = kubevela;
|
||||||
this.exnConnector = exnConnector;
|
this.exnConnector = exnConnector;
|
||||||
JsonNode parameters = app_message.at(variables_path);
|
JsonNode parameters = app_message.at(variables_path);
|
||||||
@ -328,8 +336,7 @@ public class NebulousApp {
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Main.logFile("incoming-kubevela-" + UUID + ".yaml", kubevela_string);
|
Main.logFile("incoming-kubevela-" + UUID + ".yaml", kubevela_string);
|
||||||
return new NebulousApp(app_message,
|
return new NebulousApp(app_message, kubevela_string, exnConnector);
|
||||||
(ObjectNode)readKubevelaString(kubevela_string), exnConnector);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Could not read app creation message", e);
|
log.error("Could not read app creation message", e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user