Chapter 41. Service Retirement

We saw in Chapter 40 how individual virtual machines or instances can be retired from their Lifecycle menu button, and we can also retire services in the same way. The service retirement process follows a similar workflow to the VM retirement process, but we have the flexibility to specify per-service retirement state machines if we wish.

Defining a Service Retirement Entry Point

When we create a service catalog item, we can optionally specify a retirement entry point (see Figure 41-1).

mcla 4101
Figure 41-1. Setting a service retirement entry point state machine

If we specify our own retirement entry point, then this state machine will be used to retire any services created from this catalog item. If we do not specify our own entry point here, then then the Default retirement state machine will be used.

Initiating Retirement

Service retirement is initiated from the Lifecycle menu on the service details frame (see Figure 41-2).

mcla 4102
Figure 41-2. Service retirement menu

Clicking on Retire this Service raises a request_service_retire event that begins a chain of relationships through the datastore:

  • request_service_retire

    • /System/Event/MiqEvent/POLICY/request_service_retire

    • /Service/Retirement/StateMachines/Methods/GetRetirementEntrypoint

GetRetirementEntrypoint runs a method called get_retirement_entry_point that returns the retirement entry point state machine defined when the service catalog item was created (see Figure 41-3). If this is empty, then /Service/Retirement/StateMachines/ServiceRetirement/Default is returned.

Retirement-Related Attributes and Methods

A service object has a number of retirement-related methods:

$evm.root['service'].automate_retirement_entrypoint
$evm.root['service'].finish_retirement
$evm.root['service'].retire_now
$evm.root['service'].retire_service_resources
$evm.root['service'].retired?
$evm.root['service'].retirement_state=
$evm.root['service'].retirement_warn=
$evm.root['service'].retires_on=
$evm.root['service'].start_retirement

and attributes:

$evm.root['service'].retired = nil
$evm.root['service'].retirement_last_warn = nil
$evm.root['service'].retirement_requester = nil
$evm.root['service'].retirement_state = nil
$evm.root['service'].retirement_warn = nil
$evm.root['service'].retires_on = nil

Service Retirement State Machine

The Default service retirement state machine is simpler than its VM counterpart (see Figure 41-3).

mcla 4103
Figure 41-3. Default service retirement state machine

StartRetirement

The StartRetirement instance calls the start_retirement state machine method, which checks whether the service is already in the retired or retiring state, and if so it aborts. If the service is in neither of these states, it calls the service’s start_retirement method, which sets the retirement_state attribute to retiring.

RetireService/CheckServiceRetired

The RetireService instance calls the retire_service state machine method, which in turn calls the service object’s retire_service_resources method. This method calls the retire_now method of every VM comprising the service, to initiate their retirement. CheckServiceRetired retries the stage until all VMs are retired or deleted.

FinishRetirement

The FinishRetirement stage sets the following service object attributes:

:retires_on       => Date.today
:retired          => true
:retirement_state => "retired"

It also raises a service_retired event that can be caught by an Automate action or control policy.

DeleteServiceFromVMDB

The DeleteServiceFromVMDB instance calls the delete_service_from_vmdb state machine method, which removes the service record from the VMDB.

Summary

We have seen in this chapter how the process of retiring a service will also trigger the retirement of its virtual machines. If we are using service hierarchies, however, or services to manage cloud-style workloads as single entities, this might not be our desired behavior.

Fortunately, the service retirement mechanism is flexible enough that we can create per-service retirement state machines that we can customize to suit our individual use cases and workloads.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.27.171