Skip to content

Commit a6bd527

Browse files
authored
Documentation related to Instance lease feature (#492)
* Documentation related to Instance lease feature * add note for disabling feature and cancellation of lease * Add behaviour and considerations for instance lease * Add lease events in the doc * incoporate suggestions * update config key names and handle review comments * minor change * Add note for editing lease for compute offering and lowest possible value for scheduler interval * max allowed lease is for 100 years * fix typos
1 parent b6491a8 commit a6bd527

File tree

6 files changed

+175
-0
lines changed

6 files changed

+175
-0
lines changed
Loading
Loading
Loading
47.2 KB
Loading

source/adminguide/service_offerings.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,34 @@ To create a new compute offering:
405405
- **Disk Offering Strictness**: This flag defines the strictness of the disk offering association
406406
with the compute offering. When set to true, overriding of disk offering is not allowed on deploy instance
407407
and change disk offering is not allowed for the ROOT disk
408+
409+
- **Enable Lease**: When this flag is enabled, Compute Offering is created with 'Instance Lease' enabled.
410+
In CloudStack, a lease for an instance sets a specific time duration (in days) after which a chosen lease action, such as stopping or destroying the instance, will take place.
411+
These lease settings are defined in the Compute Offering and are automatically applied to any Instance created using it.
412+
413+
.. note:: The global configuration ``instance.lease.enabled`` should be configured as true to create compute offering with lease.
414+
415+
.. note:: Lease duration or expiryaction can't be updated for compute offering.
416+
417+
``instance.lease.enabled``: Indicates whether Instance Lease feature is enabled or not. Default is **false**
418+
For more information, see `“Setting Global Configuration Parameters”
419+
<../installguide/configuration.html#setting-global-configuration-parameters>`_.
420+
421+
When the flag is enabled
422+
423+
- **Lease Duration (in days)**: Sets the lease duration. An instance created using this compute offering will inherit the lease duration by default. Supported values are in range 1 <= N <= 36500.
424+
425+
- **Lease expiry action**: Lease expiry action: Denotes lease expiry action, which gets executed upon lease expiry for instances created using this compute offering.
426+
Supported values for lease expiry action are as follows:
427+
428+
- STOP
429+
- DESTROY
430+
431+
.. image:: /_static/images/compute_offering_dailog_with_lease.png
432+
:width: 400px
433+
:align: center
434+
:alt: Compute offering dialog box
435+
408436

409437
#. Click Add.
410438

source/adminguide/virtual_machines.rst

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,153 @@ restoreVirtualMachine call. In this case, the Instance's root disk is
973973
destroyed and recreated, but from the same Template or ISO that was
974974
already in use by the Instance.
975975

976+
Instance Lease
977+
--------------
978+
979+
CloudStack offers the option to create Instances with a Lease. A Lease defines a set time period after which a selected action,
980+
such as stopping or destroying the instance, will be automatically performed. This helps optimize cloud resource usage by automatically
981+
freeing up resources that are no longer in use.
982+
983+
If a user needs an instance only for a limited time, this option can be very helpful.
984+
When deploying an instance, users can either choose a Compute Offering that includes Instance Lease support or enable it specifically for that instance,
985+
setting the number of days after which the instance should be stopped or destroyed once their task is complete.
986+
987+
988+
**Configuring Instance Lease feature**
989+
990+
The cloud administrator can use global configuration variables to control the behavior of Instance Lease.
991+
To set these variables, API or CloudStack UI can be used:
992+
993+
======================================= ========================
994+
Configuration Description
995+
======================================= ========================
996+
instance.lease.enabled Indicates whether to enable the Instance Lease feature, will be applicable only on instances created after lease is enabled. **Default: false**
997+
instance.lease.scheduler.interval Background task interval in seconds that executes Lease expiry action on eligible expired instances. Default: 3600.
998+
instance.lease.eventscheduler.interval Background task interval in seconds that executes Lease event executor for instances about to be expired in next N days. Default: 86400
999+
instance.lease.expiryevent.daysbefore Denotes number of days (N) in advance expiry events are generated for instance about to expire. Default: 7 days
1000+
======================================= ========================
1001+
1002+
.. note:: it is recommended to configure the lowest possible value (in secs) for **instance.lease.scheduler.interval**, so that lease expiry action is taken as soon as lease is expired.
1003+
1004+
1005+
**Lease Parameters**
1006+
1007+
1008+
**leaseduration**: Lease duration is specified in days. This can take Natural numbers (>=1) and -1 to disable the lease. Max supported value is 36500 (100 years).
1009+
1010+
User can disable Lease for instance in two ways:
1011+
1012+
- Disable the Instance Lease during instance deployment by unchecking the 'Enable Lease' option when using a Compute Offering that supports it.
1013+
- For existing instances with a lease already enabled, it can be removed by editing the instance and unchecking the 'Enable Lease' option.
1014+
1015+
**leaseexpiryaction**: There are two expiry action supported:
1016+
1017+
- STOP: The instance is stopped, and it will be out of lease. The user can restart the instance manually.
1018+
- DESTROY: The instance is destroyed when the lease expires.
1019+
1020+
.. note:: Expiry action is executed at most once on the instance, e.g. STOP action will bring instance in Stopped state on expiry and instance will be out of lease. User may choose to start it again.
1021+
1022+
1023+
**Using Instance Lease**
1024+
1025+
Lease information is associated to an Instance and following parameters are used to enable lease for it:
1026+
1027+
#. leaseduration
1028+
#. leaseexpiryaction
1029+
1030+
Instance remains active for specified leaseduration (in days). Upon lease expiry, configured expiryaction is executed on the instance and
1031+
lease is removed from the instance for any further action.
1032+
1033+
**Notes:**
1034+
1035+
#. Lease Assignment: A lease can only be assigned to an instance during deployment.
1036+
#. Lease Acquisition: Instances without a lease cannot acquire one by switching to a different Compute Offering or by editing the instance.
1037+
#. Lease Inheritance: Instances inherit the lease from a Compute Offering with 'Instance Lease' feature enabled. This lease can be overridden or disabled in the “Advanced Settings”.
1038+
#. Lease Persistence: A lease is always tied to the instance. Modifications to the Compute Offering do not affect the instance's lease.
1039+
#. Non-Lease Compute Offering: Instances can have a lease by enabling it in the "Advanced Settings" for non-lease based Compute Offering too.
1040+
#. Lease Duration Management: The lease duration can be extended or reduced for instances before expiry. However, once the lease is disabled, it cannot be re-enabled for that instance.
1041+
#. Lease Expiry: Once the lease expires and the associated action is completed, the lease is annulled and cannot be reattached or extended.
1042+
#. Feature Disablement: If the lease feature is disabled, the lease associated with instances is canceled. Re-enabling the feature will not automatically reapply the lease to previously grandfathered instances.
1043+
#. Delete Protection: The DESTROY lease expiry action is skipped for instances with delete protection enabled.
1044+
1045+
**Deployment of Instance with lease**
1046+
1047+
There are 2 ways to deploy instance with lease from UI:
1048+
1049+
1. Use Compute Offering which has 'Instance Lease' feature enabled.
1050+
1051+
.. image:: /_static/images/deploy_instance_lease_offering.png
1052+
:width: 400px
1053+
:align: center
1054+
:alt: Deploy Instance with lease compute offering dialog box
1055+
1056+
2. Enable lease under Advance settings during instance Deployment
1057+
1058+
.. image:: /_static/images/deploy_instance_advanced_lease.png
1059+
:width: 400px
1060+
:align: center
1061+
:alt: Deploy Instance with lease using advance settings
1062+
1063+
1064+
**Using API**
1065+
1066+
Pass lease parameters in the command to enable lease during instance deployment:
1067+
1068+
.. code:: bash
1069+
1070+
cmk deploy virtualmachine name=..... leaseduration=... leaseexpiryaction=...
1071+
1072+
- Use Compute Offering with lease
1073+
1074+
.. code:: bash
1075+
1076+
cmk deploy virtualmachine name=..... serviceofferingid=lease-compute-offering
1077+
1078+
1079+
**Editing Instance Lease**
1080+
1081+
The lease duration for an instance can be extended, reduced, or disabled for instances that already have an active lease.
1082+
However, it is not possible to enable the lease on an instance after it has already been deployed.
1083+
1084+
From UI:
1085+
1086+
.. image:: /_static/images/edit_instance_lease.png
1087+
:width: 400px
1088+
:align: center
1089+
:alt: Edit Instance Lease dialog
1090+
1091+
1092+
Using API:
1093+
1094+
.. code:: bash
1095+
1096+
cmk update virtualmachine id=fa970d19-8340-455c-a9fb-569205954fdc leaseduration=20 leaseexpiryaction=DESTROY
1097+
1098+
To disable lease using API:
1099+
1100+
.. code:: bash
1101+
1102+
cmk update virtualmachine id=fa970d19-8340-455c-a9fb-569205954fdc leaseduration=-1
1103+
1104+
.. note:: DESTROY action will ignore instance if deleteprotection is enabled for it.
1105+
1106+
.. note:: When the feature is disabled, the lease associated with instances is cancelled. Re-enabling the feature will not automatically reapply the lease to previously grandfathered instances.
1107+
1108+
.. note:: Lease duration is considered as total lease for instance.
1109+
1110+
**Instance Lease Events**
1111+
1112+
Lease feature generates various events to help in auditing and monitoring:
1113+
1114+
=================== ========================
1115+
Event Type Description
1116+
=================== ========================
1117+
VM.LEASE.EXPIRED Event is generated at lease expiry
1118+
VM.LEASE.DISABLED Denotes if lease is disabled by user/admin
1119+
VM.LEASE.CANCELLED When lease is cancelled (feature gets disabled)
1120+
VM.LEASE.EXPIRING Expiry intimation event for instance
1121+
=================== ========================
1122+
9761123

9771124
Advanced Instance Settings
9781125
--------------------------

0 commit comments

Comments
 (0)