Fix NPE.
This commit is contained in:
parent
134e4c02f4
commit
e1c710d473
1 changed files with 6 additions and 4 deletions
|
|
@ -66,12 +66,14 @@ import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
||||||
"pods", channel.client());
|
"pods", channel.client());
|
||||||
var existing = K8s.get(podApi, event.object().getMetadata());
|
var existing = K8s.get(podApi, event.object().getMetadata());
|
||||||
|
|
||||||
// Get state
|
// Get state. Note that model is only available if event type
|
||||||
var state = GsonPtr.to((JsonObject) model.get("cr")).to("spec", "vm")
|
// is not DELETED.
|
||||||
.getAsString("state").get();
|
var delete = event.type() == Type.DELETED
|
||||||
|
|| GsonPtr.to((JsonObject) model.get("cr")).to("spec", "vm")
|
||||||
|
.getAsString("state").orElse("").equals(STATE_STOPPED);
|
||||||
|
|
||||||
// If deleted or stopped, delete
|
// If deleted or stopped, delete
|
||||||
if (event.type() == Type.DELETED || STATE_STOPPED.equals(state)) {
|
if (delete) {
|
||||||
if (existing.isPresent()) {
|
if (existing.isPresent()) {
|
||||||
K8s.delete(podApi, existing.get());
|
K8s.delete(podApi, existing.get());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue