Class Controller

java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jdrupes.vmoperator.manager.Controller
All Implemented Interfaces:
Iterable<org.jgrapes.core.ComponentType>, org.jgrapes.core.Channel, org.jgrapes.core.ComponentType, org.jgrapes.core.Eligible, org.jgrapes.core.Manager

public class Controller extends org.jgrapes.core.Component
Implements a controller as defined in the Operator Whitepaper.

The implementation splits the controller in two components. The VmMonitor and the Reconciler. The former watches the VM definitions (CRs) and generates VmResourceChanged events when they change. The latter handles the changes and reconciles the resources in the cluster.

The controller itself supports a single configuration property:

"/Manager":
  "/Controller":
    namespace: vmop-dev

This may only be set when running the Manager (and thus the Controller) outside a container during development.

Controller components

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.jgrapes.core.Channel

    org.jgrapes.core.Channel.Default
  • Field Summary

    Fields inherited from class org.jgrapes.core.Component

    logger

    Fields inherited from interface org.jgrapes.core.Channel

    BROADCAST, SELF
  • Constructor Summary

    Constructors
    Constructor
    Description
    Controller(org.jgrapes.core.Channel componentChannel)
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Assign a VM if not already assigned.
    void
    onConfigurationUpdate(org.jgrapes.util.events.ConfigurationUpdate event)
    Configure the component.
    void
    Returns the VM data.
    void
    onHandlingError(org.jgrapes.core.events.HandlingError event)
    Special handling of ApiException thrown by handlers.
    void
    onPodChange(PodChanged event, VmChannel channel)
    Remove runner version from status when pod is deleted
    void
    When s pool is deleted, remove all related assignments.
    void
    onStart(org.jgrapes.core.events.Start event)
    Handle the start event.

    Methods inherited from class org.jgrapes.core.Component

    channel, component, defaultCriterion, isEligibleFor, setName

    Methods inherited from class org.jgrapes.core.internal.ComponentVertex

    activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface org.jgrapes.core.Manager

    stream
  • Constructor Details

    • Controller

      public Controller(org.jgrapes.core.Channel componentChannel)
      Creates a new instance.
  • Method Details

    • onHandlingError

      @Handler(channels=org.jgrapes.core.Channel.class) public void onHandlingError(org.jgrapes.core.events.HandlingError event)
      Special handling of ApiException thrown by handlers.
      Parameters:
      event - the event
    • onConfigurationUpdate

      @Handler public void onConfigurationUpdate(org.jgrapes.util.events.ConfigurationUpdate event)
      Configure the component.
      Parameters:
      event - the event
    • onStart

      @Handler(priority=100) public void onStart(org.jgrapes.core.events.Start event) throws IOException, io.kubernetes.client.openapi.ApiException
      Handle the start event.

      Has higher priority because it configures the default Kubernetes client.

      Parameters:
      event - the event
      Throws:
      IOException
      io.kubernetes.client.openapi.ApiException
    • onGetVms

      @Handler public void onGetVms(GetVms event)
      Returns the VM data.
      Parameters:
      event - the event
    • onAssignVm

      @Handler public void onAssignVm(AssignVm event) throws io.kubernetes.client.openapi.ApiException, InterruptedException
      Assign a VM if not already assigned.
      Parameters:
      event - the event
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
      InterruptedException
    • onPoolChanged

      @Handler public void onPoolChanged(VmPoolChanged event) throws InterruptedException
      When s pool is deleted, remove all related assignments.
      Parameters:
      event - the event
      Throws:
      InterruptedException
    • onPodChange

      @Handler public void onPodChange(PodChanged event, VmChannel channel) throws io.kubernetes.client.openapi.ApiException
      Remove runner version from status when pod is deleted
      Parameters:
      event - the event
      channel - the channel
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception