Skip to content

Commit 7902ef7

Browse files
committed
Merge branch 'main' into testing
2 parents a1a4030 + fcdb537 commit 7902ef7

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,23 @@
33
![Latest Manager](https://img.shields.io/github/v/tag/mnlipp/vm-operator?filter=manager*&label=latest)
44
![Latest Runner](https://img.shields.io/github/v/tag/mnlipp/vm-operator?filter=runner-qemu*&label=latest)
55

6-
# Run Qemu in Kubernetes Pods
6+
# Run QEMU/KVM in Kubernetes Pods
77

8-
The goal of this project is to provide simply to use and flexible components
9-
for running Qemu based VMs in Kubernetes pods.
8+
![Overview picture](webpages/index-pic.svg)
9+
10+
This project provides an easy to use and flexible solution for running
11+
QEMU/KVM based VMs in Kubernetes pods.
12+
13+
The central component of this solution is the kubernetes operator that
14+
manages "runners". These run in pods and are used to start and manage
15+
the QEMU/KVM process for the VMs (optionally together with a SW-TPM).
16+
17+
A web GUI for administrators provides an overview of the VMs together
18+
with some basic control over the VMs. A web GUI for users provides an
19+
interface to access and optionally start, stop and reset the VMs.
20+
21+
Advanced features of the operator include pooling of VMs and automatic
22+
login.
1023

1124
See the [project's home page](https://vm-operator.jdrupes.org/)
1225
for details.

org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmDefUpdater.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,19 @@ private void updateNamespace() {
125125
protected JsonObject updateCondition(VmDefinition from, String type,
126126
boolean state, String reason, String message) {
127127
JsonObject status = from.statusJson();
128-
// Optimize, as we can get this several times
128+
// Avoid redundant updates, as this may be called several times
129129
var current = status.getAsJsonArray("conditions").asList().stream()
130130
.map(cond -> (JsonObject) cond)
131131
.filter(cond -> type.equals(cond.get("type").getAsString()))
132132
.findFirst();
133-
if (current.isPresent()
134-
&& current.map(c -> c.get("status").getAsString())
135-
.map("True"::equals).map(s -> s == state).orElse(false)
133+
var stateUnchanged = current.map(c -> c.get("status").getAsString())
134+
.map("True"::equals).map(s -> s == state).orElse(false);
135+
if (stateUnchanged
136136
&& current.map(c -> c.get("reason").getAsString())
137-
.map(reason::equals).orElse(false)) {
137+
.map(reason::equals).orElse(false)
138+
&& current.map(c -> c.get("observedGeneration").getAsLong())
139+
.map(from.getMetadata().getGeneration()::equals)
140+
.orElse(false)) {
138141
return status;
139142
}
140143

@@ -143,7 +146,9 @@ protected JsonObject updateCondition(VmDefinition from, String type,
143146
"status", state ? "True" : "False",
144147
"observedGeneration", from.getMetadata().getGeneration(),
145148
"reason", reason,
146-
"lastTransitionTime", Instant.now().toString()));
149+
"lastTransitionTime", stateUnchanged
150+
? current.get().get("lastTransitionTime").getAsString()
151+
: Instant.now().toString()));
147152
if (message != null) {
148153
condition.put("message", message);
149154
}

0 commit comments

Comments
 (0)