Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exclusion periods #123

Open
saturnreturn opened this issue Dec 18, 2017 · 2 comments
Open

Add support for exclusion periods #123

saturnreturn opened this issue Dec 18, 2017 · 2 comments
Assignees

Comments

@saturnreturn
Copy link

Enhancement request:

It could be useful to support the ability to schedule periods during which no run profiles should be allowed to start. E.g. to allow server auto-patching to take place, which may involve the machine rebooting.

This could re-use the existing functionality to "stop all controllers" and "start all controllers" at the specified times.

For regular windows, some of the functionality from the Triggers GUI could maybe be reused to set up the intervals.

@ryannewington
Copy link
Member

Hi @saturnreturn

What about doing this from PowerShell? Stop the autosync service, use the miis powershell to wait for all MAs to finish (wait-managementagent) then perform your mainteance tasks and do things like reboot the server?

Alternatively, a scheduled task that stops the autosync service at a certain time, and restarts it later?

I'm not against building something into AutoSync, but would just want to make sure the complexity of doing this adds value that couldn't be achieved otherwise.

@saturnreturn
Copy link
Author

saturnreturn commented Jan 23, 2018

I have made use of the Execution Controller Script feature to do a last minute check to see if the current time is in a patching window, and bail out of running the MA if so. Not sure how bullet proof it is, but it will hopefully do the trick.

# This function is called by the MA executor before a run profile is executed. Return $false to prevent the run profile from being executed
# Returning $true or nothing will allow the run profile to execute
function ShouldExecute
{
	param([string]$runProfileName)

    # Patching Day
    $patchingDay = "Tuesday"
    
    # Patching window start time
    $patchingStartTime = "12:30"

    # Patching window end time
    $patchingEndTime = "14:30"
    

    # Current date/time
    $now = Get-Date

    #if it is patching day, and it is patching time, don't run this MA
    if ($patchingDay -eq $now.DayOfWeek)
    {
        if ($now -ge (Get-Date $patchingStartTime) -and $now -lt (Get-Date $patchingEndTime))
        {
            # Current time is withing patching window, do not start this run profile
            return $false
        }
    }

	return $true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants