Windows Update Offload: "Fetch Windows Updates" task is killed after 72h and never restarts until reboot

オープン
#887 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

@LordHepipud がすでに取り組んでいます。

2026年10月28日 から。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
powershell

調査の方向性

The task is registered in lib/provider/updates/Register-IcingaWindowsScheduledTaskWindowsUpdates.psm1, where New-ScheduledTaskSettingsSet has no execution time limit and the only trigger is -AtStartup. The loop it starts lives in jobs\FetchWindowsUpdates.ps1. Done means the registered task has no 72-hour limit and a recurring trigger, which you can confirm with Get-ScheduledTask on a Windows host. Testing needs a Windows machine and a wait or a time-shifted check.

索引モデルが issue の本文から書いたものです。

説明

Bug Investigation

Description

When Windows Update Offload is enabled (Enable-IcingaWindowsUpdateOffload), the scheduled task
\Icinga\Icinga for Windows\Fetch Windows Updates is registered without an explicit
ExecutionTimeLimit, so Windows applies its default limit of 72 hours.

jobs\FetchWindowsUpdates.ps1 is designed to run forever (endless loop that refreshes the cache
every 10 minutes). After 72 hours the Task Scheduler terminates the process, and since the task
only has an At startup trigger, it is never started again until the next reboot.

From then on the cache file is no longer refreshed and Invoke-IcingaCheckUpdates goes
WARNING/CRITICAL on every host, e.g.:

Last Update Check: Value 5.98h is greater than threshold 30m

In our environment this happened on all Windows hosts at the same time.

Steps to reproduce

  1. Run Enable-IcingaWindowsUpdateOffload
  2. Wait more than 72 hours without rebooting the host
  3. The task is in state Ready (not Running) and the Last Update Check of
    Invoke-IcingaCheckUpdates exceeds the 20m/30m thresholds

Evidence

PS> $t = Get-ScheduledTask -TaskName 'Fetch Windows Updates' -TaskPath '\Icinga\Icinga for Windows\'
PS> $t.Settings.ExecutionTimeLimit
PT72H
PS> $t.Triggers | Select-Object CimClass
Root/Microsoft/Windows/TaskScheduler:MSFT_TaskBootTrigger

Starting the task manually (Start-ScheduledTask) fixes the check until the next 72h limit is hit.

Cause

In lib/provider/updates/Register-IcingaWindowsScheduledTaskWindowsUpdates.psm1:

$TaskSettings = New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries -StartWhenAvailable;

No -ExecutionTimeLimit is passed, so the Windows default (PT72H) is used, and the only trigger is
New-ScheduledTaskTrigger -AtStartup.

Suggested fix

Disable the execution time limit and add a recurring trigger, so the job is restarted if it ever
stops for any reason (IgnoreNew prevents parallel instances while it is running):

$TaskSettings = New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries -StartWhenAvailable `
    -ExecutionTimeLimit (New-TimeSpan -Seconds 0) -MultipleInstances IgnoreNew;

$TaskTrigger = @(
    (New-ScheduledTaskTrigger -AtStartup),
    (New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval (New-TimeSpan -Minutes 30) -RepetitionDuration (New-TimeSpan -Days 3650))
);

Workaround

Patch the existing task (we enforce this via Puppet):

$t = Get-ScheduledTask -TaskName 'Fetch Windows Updates' -TaskPath '\Icinga\Icinga for Windows\'
Set-ScheduledTask -TaskName $t.TaskName -TaskPath $t.TaskPath `
    -Settings (New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Seconds 0) -MultipleInstances IgnoreNew) `
    -Trigger @((New-ScheduledTaskTrigger -AtStartup), (New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval (New-TimeSpan -Minutes 30) -RepetitionDuration (New-TimeSpan -Days 3650)))
Start-ScheduledTask -TaskName $t.TaskName -TaskPath $t.TaskPath

Environment

  • Icinga PowerShell Framework: 1.16.0
  • Icinga PowerShell Plugins: 1.16.1
  • Icinga 2 agent: 2.14.10
  • OS: [p. ex. Windows Server 2022]
  • Icinga 2 service user: NT AUTHORITY\NetworkService (reason for using the offload feature)
主要言語
PowerShell
スター
86
フォーク
34
平均マージ
14分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Icinga/icinga-powershell-framework のほかの issue

Icinga/icinga-powershell-framework の issue をすべて見る

似ている issue

DevOps の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。