Compare commits
No commits in common. "2572aa9e218a6720c51614e1e09ed3ffb853a5a9" and "50c11073adc94fe0512aba183e34e3a2376346ab" have entirely different histories.
2572aa9e21
...
50c11073ad
8 changed files with 33 additions and 56 deletions
|
|
@ -24,7 +24,7 @@ stages:
|
||||||
- "*/build"
|
- "*/build"
|
||||||
before_script:
|
before_script:
|
||||||
- echo -n $CI_REGISTRY_PASSWORD | podman login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
|
- echo -n $CI_REGISTRY_PASSWORD | podman login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
|
||||||
- git switch $(git branch -r --sort="authordate" --contains $CI_COMMIT_SHA | head -1 | sed -e 's#.*/##')
|
- git switch $(git branch -r --sort="authordate" --contains $CI_COMMIT_SHA | head -1 | sed -e 's#[^/]*/##')
|
||||||
- git pull
|
- git pull
|
||||||
- git reset --hard $CI_COMMIT_SHA
|
- git reset --hard $CI_COMMIT_SHA
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: vm-operator
|
- name: vm-operator
|
||||||
image: >-
|
image: >-
|
||||||
ghcr.io/mnlipp/org.jdrupes.vmoperator.manager:4.0.2
|
ghcr.io/mnlipp/org.jdrupes.vmoperator.manager:4.0.1
|
||||||
env:
|
env:
|
||||||
- name: JAVA_OPTS
|
- name: JAVA_OPTS
|
||||||
# The VM operator needs about 25 MB of memory, plus 1 MB for
|
# The VM operator needs about 25 MB of memory, plus 1 MB for
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ dependencies {
|
||||||
implementation 'org.jgrapes:org.jgrapes.io:[2.12.1,3)'
|
implementation 'org.jgrapes:org.jgrapes.io:[2.12.1,3)'
|
||||||
implementation 'org.jgrapes:org.jgrapes.http:[3.5.0,4)'
|
implementation 'org.jgrapes:org.jgrapes.http:[3.5.0,4)'
|
||||||
|
|
||||||
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.3.0,3)'
|
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.2.0,3)'
|
||||||
implementation 'org.jgrapes:org.jgrapes.webconsole.vuejs:[1.8.0,2)'
|
implementation 'org.jgrapes:org.jgrapes.webconsole.vuejs:[1.8.0,2)'
|
||||||
implementation 'org.jgrapes:org.jgrapes.webconsole.rbac:[1.4.0,2)'
|
implementation 'org.jgrapes:org.jgrapes.webconsole.rbac:[1.4.0,2)'
|
||||||
implementation 'org.jgrapes:org.jgrapes.webconlet.oidclogin:[1.7.0,2)'
|
implementation 'org.jgrapes:org.jgrapes.webconlet.oidclogin:[1.7.0,2)'
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ data:
|
||||||
# The template to use. Resolved relative to /usr/share/vmrunner/templates.
|
# The template to use. Resolved relative to /usr/share/vmrunner/templates.
|
||||||
# template: "Standard-VM-latest.ftl.yaml"
|
# template: "Standard-VM-latest.ftl.yaml"
|
||||||
<#if spec.runnerTemplate?? && spec.runnerTemplate.source?? >
|
<#if spec.runnerTemplate?? && spec.runnerTemplate.source?? >
|
||||||
template: ${ spec.runnerTemplate.source }
|
template: ${ cm.spec().runnerTemplate.source }
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
# The template is copied to the data diretory when the VM starts for
|
# The template is copied to the data diretory when the VM starts for
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ import org.jdrupes.vmoperator.manager.events.VmPoolChanged;
|
||||||
import org.jdrupes.vmoperator.manager.events.VmResourceChanged;
|
import org.jdrupes.vmoperator.manager.events.VmResourceChanged;
|
||||||
import org.jgrapes.core.Channel;
|
import org.jgrapes.core.Channel;
|
||||||
import org.jgrapes.core.Component;
|
import org.jgrapes.core.Component;
|
||||||
import org.jgrapes.core.EventPipeline;
|
|
||||||
import org.jgrapes.core.annotation.Handler;
|
import org.jgrapes.core.annotation.Handler;
|
||||||
import org.jgrapes.core.events.HandlingError;
|
import org.jgrapes.core.events.HandlingError;
|
||||||
import org.jgrapes.core.events.Start;
|
import org.jgrapes.core.events.Start;
|
||||||
|
|
@ -95,7 +94,7 @@ import org.jgrapes.util.events.ConfigurationUpdate;
|
||||||
public class Controller extends Component {
|
public class Controller extends Component {
|
||||||
|
|
||||||
private String namespace;
|
private String namespace;
|
||||||
private final ChannelManager<String, VmChannel, EventPipeline> chanMgr;
|
private final ChannelManager<String, VmChannel, ?> chanMgr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ import org.jose4j.base64url.Base64;
|
||||||
* * `passwordValidity`: the validity of the random password in seconds.
|
* * `passwordValidity`: the validity of the random password in seconds.
|
||||||
* Used to calculate the password expiry time in the generated secret.
|
* Used to calculate the password expiry time in the generated secret.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.TooManyStaticImports" })
|
||||||
public class DisplaySecretReconciler extends Component {
|
public class DisplaySecretReconciler extends Component {
|
||||||
|
|
||||||
protected final Logger logger = Logger.getLogger(getClass().getName());
|
protected final Logger logger = Logger.getLogger(getClass().getName());
|
||||||
|
|
@ -103,15 +104,12 @@ public class DisplaySecretReconciler extends Component {
|
||||||
return oldConfig;
|
return oldConfig;
|
||||||
}).ifPresent(c -> {
|
}).ifPresent(c -> {
|
||||||
try {
|
try {
|
||||||
Optional.ofNullable(c.get("passwordValidity"))
|
if (c.containsKey("passwordValidity")) {
|
||||||
.map(p -> p instanceof Integer ? (Integer) p
|
passwordValidity = Integer
|
||||||
: Integer.valueOf((String) p))
|
.parseInt((String) c.get("passwordValidity"));
|
||||||
.ifPresent(p -> {
|
}
|
||||||
passwordValidity = p;
|
} catch (ClassCastException e) {
|
||||||
});
|
logger.config("Malformed configuration: " + e.getMessage());
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
logger.warning(
|
|
||||||
() -> "Malformed configuration: " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -192,6 +190,7 @@ public class DisplaySecretReconciler extends Component {
|
||||||
* @throws ApiException the api exception
|
* @throws ApiException the api exception
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
|
@SuppressWarnings("PMD.StringInstantiation")
|
||||||
public void onGetDisplaySecret(GetDisplaySecret event, VmChannel channel)
|
public void onGetDisplaySecret(GetDisplaySecret event, VmChannel channel)
|
||||||
throws ApiException {
|
throws ApiException {
|
||||||
// Get VM definition and check if running
|
// Get VM definition and check if running
|
||||||
|
|
@ -320,6 +319,7 @@ public class DisplaySecretReconciler extends Component {
|
||||||
/**
|
/**
|
||||||
* The Class PendingGet.
|
* The Class PendingGet.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.DataClass")
|
||||||
private static class PendingRequest {
|
private static class PendingRequest {
|
||||||
public final GetDisplaySecret event;
|
public final GetDisplaySecret event;
|
||||||
public final long expectedSerial;
|
public final long expectedSerial;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import com.google.gson.JsonObject;
|
||||||
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
||||||
import io.kubernetes.client.custom.V1Patch;
|
import io.kubernetes.client.custom.V1Patch;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||||
import io.kubernetes.client.util.Watch;
|
import io.kubernetes.client.util.Watch;
|
||||||
import io.kubernetes.client.util.generic.options.ListOptions;
|
import io.kubernetes.client.util.generic.options.ListOptions;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -31,6 +32,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.jdrupes.vmoperator.common.Constants.Crd;
|
import org.jdrupes.vmoperator.common.Constants.Crd;
|
||||||
import org.jdrupes.vmoperator.common.Constants.Status;
|
import org.jdrupes.vmoperator.common.Constants.Status;
|
||||||
|
|
@ -55,28 +57,16 @@ import org.jdrupes.vmoperator.manager.events.VmResourceChanged;
|
||||||
import org.jdrupes.vmoperator.util.GsonPtr;
|
import org.jdrupes.vmoperator.util.GsonPtr;
|
||||||
import org.jgrapes.core.Channel;
|
import org.jgrapes.core.Channel;
|
||||||
import org.jgrapes.core.Event;
|
import org.jgrapes.core.Event;
|
||||||
import org.jgrapes.core.EventPipeline;
|
|
||||||
import org.jgrapes.core.annotation.Handler;
|
import org.jgrapes.core.annotation.Handler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watches for changes of VM definitions. When a VM definition (CR)
|
* Watches for changes of VM definitions.
|
||||||
* becomes known, is is registered with a {@link ChannelManager} and thus
|
|
||||||
* gets an associated {@link VmChannel} and an associated
|
|
||||||
* {@link EventPipeline}.
|
|
||||||
*
|
|
||||||
* The {@link EventPipeline} is used for submitting an action that processes
|
|
||||||
* the change data from kubernetes, eventually transforming it to a
|
|
||||||
* {@link VmResourceChanged} event that is handled by another
|
|
||||||
* {@link EventPipeline} associated with the {@link VmChannel}. This
|
|
||||||
* event pipeline should be used for all events related to changes of
|
|
||||||
* a particular VM.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" })
|
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" })
|
||||||
public class VmMonitor extends
|
public class VmMonitor extends
|
||||||
AbstractMonitor<VmDefinition, VmDefinitions, VmChannel> {
|
AbstractMonitor<VmDefinition, VmDefinitions, VmChannel> {
|
||||||
|
|
||||||
private final ChannelManager<String, VmChannel,
|
private final ChannelManager<String, VmChannel, ?> channelManager;
|
||||||
EventPipeline> channelManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new VM definition watcher.
|
* Instantiates a new VM definition watcher.
|
||||||
|
|
@ -85,7 +75,7 @@ public class VmMonitor extends
|
||||||
* @param channelManager the channel manager
|
* @param channelManager the channel manager
|
||||||
*/
|
*/
|
||||||
public VmMonitor(Channel componentChannel,
|
public VmMonitor(Channel componentChannel,
|
||||||
ChannelManager<String, VmChannel, EventPipeline> channelManager) {
|
ChannelManager<String, VmChannel, ?> channelManager) {
|
||||||
super(componentChannel, VmDefinition.class,
|
super(componentChannel, VmDefinition.class,
|
||||||
VmDefinitions.class);
|
VmDefinitions.class);
|
||||||
this.channelManager = channelManager;
|
this.channelManager = channelManager;
|
||||||
|
|
@ -132,18 +122,14 @@ public class VmMonitor extends
|
||||||
@Override
|
@Override
|
||||||
protected void handleChange(K8sClient client,
|
protected void handleChange(K8sClient client,
|
||||||
Watch.Response<VmDefinition> response) {
|
Watch.Response<VmDefinition> response) {
|
||||||
var name = response.object.getMetadata().getName();
|
V1ObjectMeta metadata = response.object.getMetadata();
|
||||||
|
AtomicBoolean toBeAdded = new AtomicBoolean(false);
|
||||||
|
VmChannel channel = channelManager.channel(metadata.getName())
|
||||||
|
.orElseGet(() -> {
|
||||||
|
toBeAdded.set(true);
|
||||||
|
return channelManager.createChannel(metadata.getName());
|
||||||
|
});
|
||||||
|
|
||||||
// Process the response data on a VM specific pipeline to
|
|
||||||
// increase concurrency when e.g. starting many VMs.
|
|
||||||
var preparing = channelManager.associated(name)
|
|
||||||
.orElseGet(() -> newEventPipeline());
|
|
||||||
preparing.submit("VmChange[" + name + "]",
|
|
||||||
() -> processChange(client, response, preparing));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processChange(K8sClient client,
|
|
||||||
Watch.Response<VmDefinition> response, EventPipeline preparing) {
|
|
||||||
// Get full definition and associate with channel as backup
|
// Get full definition and associate with channel as backup
|
||||||
var vmDef = response.object;
|
var vmDef = response.object;
|
||||||
if (vmDef.data() == null) {
|
if (vmDef.data() == null) {
|
||||||
|
|
@ -151,9 +137,6 @@ public class VmMonitor extends
|
||||||
// https://github.com/kubernetes-client/java/issues/3215
|
// https://github.com/kubernetes-client/java/issues/3215
|
||||||
vmDef = getModel(client, vmDef);
|
vmDef = getModel(client, vmDef);
|
||||||
}
|
}
|
||||||
var name = response.object.getMetadata().getName();
|
|
||||||
var channel = channelManager.channel(name)
|
|
||||||
.orElseGet(() -> channelManager.createChannel(name));
|
|
||||||
if (vmDef.data() != null) {
|
if (vmDef.data() != null) {
|
||||||
// New data, augment and save
|
// New data, augment and save
|
||||||
addExtraData(vmDef, channel.vmDefinition());
|
addExtraData(vmDef, channel.vmDefinition());
|
||||||
|
|
@ -167,7 +150,9 @@ public class VmMonitor extends
|
||||||
+ response.object.getMetadata());
|
+ response.object.getMetadata());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
channelManager.put(name, channel, preparing);
|
if (toBeAdded.get()) {
|
||||||
|
channelManager.put(vmDef.name(), channel);
|
||||||
|
}
|
||||||
|
|
||||||
// Create and fire changed event. Remove channel from channel
|
// Create and fire changed event. Remove channel from channel
|
||||||
// manager on completion.
|
// manager on completion.
|
||||||
|
|
@ -214,16 +199,9 @@ public class VmMonitor extends
|
||||||
@Handler
|
@Handler
|
||||||
public void onPodChanged(PodChanged event, VmChannel channel) {
|
public void onPodChanged(PodChanged event, VmChannel channel) {
|
||||||
var vmDef = channel.vmDefinition();
|
var vmDef = channel.vmDefinition();
|
||||||
|
updateNodeInfo(event, vmDef);
|
||||||
// Make sure that this is properly sync'd with VM CR changes.
|
channel
|
||||||
channelManager.associated(vmDef.name())
|
.fire(new VmResourceChanged(ResponseType.MODIFIED, vmDef, false, true));
|
||||||
.orElseGet(() -> activeEventPipeline())
|
|
||||||
.submit("NodeInfo[" + vmDef.name() + "]",
|
|
||||||
() -> {
|
|
||||||
updateNodeInfo(event, vmDef);
|
|
||||||
channel.fire(new VmResourceChanged(ResponseType.MODIFIED,
|
|
||||||
vmDef, false, true));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNodeInfo(PodChanged event, VmDefinition vmDef) {
|
private void updateNodeInfo(PodChanged event, VmDefinition vmDef) {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<template v-for="(entry, rowIndex) in filteredData" :key="entry.name">
|
<template v-for="(entry, rowIndex) in filteredData">
|
||||||
<tr :class="[(rowIndex % 2) ? 'odd' : 'even']"
|
<tr :class="[(rowIndex % 2) ? 'odd' : 'even']"
|
||||||
:aria-expanded="(entry.name in detailsByName) ? 'true' : 'false'">
|
:aria-expanded="(entry.name in detailsByName) ? 'true' : 'false'">
|
||||||
<td v-for="key in controller.keys"
|
<td v-for="key in controller.keys"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue