Introduction to Citrix Natural Reboots

In CVAD version 2103 the new feature NaturalReboot was released. The release notes say:

Another restart duration option is available when using PowerShell to create a machine restart schedule. The UseNaturalReboot option restarts all machines after draining all sessions. When the restart time is reached, machines are put into the drain state and are restarted when all sessions are logged off. See Restart after drain.


So the idea behind this is to reboot without actively logging off the users (as it would be otherwise) but to wait until the server has no more user connections.

What are the requirements for the feature to work?

  • The machines must be power managed
  • The Delivery Controller version must be 2103 or higher
  • The feature must be configured through PowerShell

We start with a classical restart schedule:

Reboot Schedule

The general conditions are:

  • Restart frequency: Daily
  • Begin restart at: 01:00 (am)
  • Restart duration: Restart all machines within 1 hour
  • Send notification to users: Do not send a notification

All functionalities discussed here may not be generally valid but apply only to the above configuration.

How can we enable the NaturalReboot feature on the above discussed restart schedule?

There are several ways to achieve that, I use the following way:

> Get-BrokerRebootScheduleV2 -DesktopGroupName "DG Server 2022"

Active                : False
Day                   :
DayInMonth            :
Description           :
DesktopGroupName      : DG Server 2022
DesktopGroupUid       : 2
Enabled               : True
Frequency             : Daily
FrequencyFactor       : 1
IgnoreMaintenanceMode : False
MaxOvertimeStartMins  : 0
MetadataKeys          : {}
MetadataMap           : {}
Name                  : Daily Reboot
RebootDuration        : 60
RestrictToTag         :
StartDate             :
StartTime             : 01:00:00
Uid                   : 1
UseNaturalReboot      : False
WarningDuration       : 0
WarningMessage        :
WarningRepeatInterval : 0
WarningTitle          :
WeekInMonth           :

The -DesktopGroupName parameter is used to specify the delivery group that will return all restart schedules. In our case, we have only one - so we can leave the Get- query as it is.

Get-BrokerRebootScheduleV2 -DesktopGroupName "DG Server 2022" | Set-BrokerRebootScheduleV2 -UseNaturalReboot $true

No error message is a good sign.

> Get-BrokerRebootScheduleV2 -DesktopGroupName "DG Server 2022"

Active                : False
Day                   :
DayInMonth            :
Description           :
DesktopGroupName      : DG Server 2022
DesktopGroupUid       : 2
Enabled               : True
Frequency             : Daily
FrequencyFactor       : 1
IgnoreMaintenanceMode : False
MaxOvertimeStartMins  : 0
MetadataKeys          : {}
MetadataMap           : {}
Name                  : Daily Reboot
RebootDuration        : 60
RestrictToTag         :
StartDate             :
StartTime             : 01:00:00
Uid                   : 1
UseNaturalReboot      : True
WarningDuration       : 0
WarningMessage        :
WarningRepeatInterval : 0
WarningTitle          :
WeekInMonth           :

That’s all. It’s very easy to enable (and hopefully will become a checkbox in the studio in the future).

At the beginning I had some problems to understand exactly how it (should) work. The publicly available documentation is unfortunately not very comprehensive. Thanks to Citrix Support at this point, who supported me and explained several things.

Okay, let’s start …

There are three scenarios I can think of:

  1. 0 sessions on both VDAs when the reboot schedule starts
  2. 0 sessions on one VDA and 1 session on the other VDA when the reboot schedule starts. The one session logs off within the reboot duration time
  3. 0 sessions on one VDA and 1 session on the other VDA when the reboot schedule starts. The one session logs off after the reboot duration time
Zero sessions on both VDAs

In the above picture are at least two interesting things:

  1. Drain mode
  2. Reboot simultaneity

The Citrix article Reboot Schedule Internals has a few words about the drain mode:

Firstly, all VDAs in the phase are put into drain mode; this prevents new sessions being launched but allows existing sessions to be reconnected.

This “Citrix drain mode” has nothing to do with the “Microsoft drain mode”.The drain mode isn’t really important in the first scenario, since the system is rebooted directly anyway. But it will be important.

If you compare the above shown behavior to the -UseNaturalReboot $false scenario, then you will see that during the NaturalReboot the machines restart simultaneously. That means that the delivery group is unavailable for a few minutes (depending on how long the machines need to be registered again). I would like the reboots to be distributed, but you can work around the problem by using tags and creating two reboot schedules. But in our scenario (1 restart plan for all machines) the behavior is as shown above. After all, we want to use NaturalReboot because users are often still logged in. Therefore, it could very well be that this is practically not a problem at all.

logoff session within reboot duration

Now let’s consider a more advanced scenario. We trigger the reboot schedule at 1 am, but a user is still connected to one of our VDAs. Our goal is that we don’t interrupt the connection and now NaturalReboot become really handy.
VDA 1 process like we saw it in Scenario 1.
VDA 2 goes into a Citrix drain state and waits until the user logs off. Whenever the user logs off (within the defined reboot duration time), the VDA will reboot after that (almost immediately).

Let’s talk about availability.
Apparently when VDA 1 is restarted and registered again, a new user session connects to VDA 1. Why? Because of the drain mode the VDA 2 is lined up at the back. But what happens when a user tries to connect at 1:05am and let’s say VDA 1 is still unregistered? The user will connect to the VDA 2. So in this scenario, a user session can always be established.
The small “disadvantage” is that now two users would have to log off for the VDA 2 to restart.

logoff session beyond reboot duration

The last scenario is when the logoff happens after the reboot duration time. In my tests, however, it behaves as in scenario 2. The machine is simply restarted after the user sessions are at 0.

In my tests it didn’t matter if this is within the reboot duration time.

Tip
In Citrix Studio you can view the status of the machines to know if they need to be rebooted or not. Show the column “Scheduled Reboot” in the respective delivery group. If the status is “None”, the machine has been successfully rebooted since the last time. If the status is “Natural”, this machine should still be rebooted.

I think NaturalReboot is a cool feature and I could imagine if there was integration into the Studio more Citrix admins would give it a try. A few things may not be super intuitive (it doesn’t make a difference in reboot duration time) which may be why they haven’t been integrated into the studio yet.