mattmcspirit / azurestack

Azure Stack Resources
80 stars 41 forks source link

DownloadWinUpdates should search for up-to-date OS version #133

Closed mattcowen closed 3 years ago

mattcowen commented 3 years ago

Describe the issue DownloadWinUpdates.ps1 fails on line 162 and again on 181 because $feed is null. This is because there is no longer an entry in the feed with title "1607" or "Security Update for Adobe Flash Player" respectively. I tried changing this to search for 1809 and checking $feed is not null for the Flash update search. This appears to have worked.

I can submit a PR if wanted

Hardware VM in Azure

Send the logs You get the following in WindowsUpdates log Getting info for latest Adobe Flash Security Update Azure Stack POC Configurator Stage: WindowsUpdates failed. Updating AzSPoC Progress database You cannot call a method on a null-valued expression..Exception.Message

yellowpanda commented 3 years ago

I get the same error message.

mattmcspirit commented 3 years ago

Hey both - @mattcowen, @yellowpanda - does your fix require the user to use a newer evaluation of Windows Server 2016 (1607)?

yellowpanda commented 3 years ago

I think the change can be limited to only handle the case when https://support.microsoft.com/app/content/api/content/feeds/sap/en-us/6ae59d69-36fc-8e4d-23dd-631d98bf74a9/rss does not contain any "Security Update for Adobe Flash Player" patches. But I'm testing.

mattmcspirit commented 3 years ago

It's been a while since i looked at this, but i know with the recent fixes, @rfsonders and @SqlTechMike have had things working. We may need to re-validate a few things. Windows Server 2016 is build 1607, and 1809 is 2019. App Service (for example), still requires WS 2016 and will apply the CU's:

2020-10 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4580346) 2020-09 Servicing Stack Update for Windows Server 2016 for x64-based Systems (KB4576750)

If it doesn't detect them in the image. This takes a long time, especially in nested configs, and may cause a failure - that's why i update the base image to start with, but something must be going wrong with the update detection logic that I'll need time to troubleshoot.

As for documentation, it does mention here: https://github.com/mattmcspirit/azurestack#step-3---run-the-azspocps1-script that you should use the WS 2016 Eval, and says that you would have downloaded this with the ASDK bits. If you're running this in the Azure VM, you won't have downloaded the ASDK bits as this was done for you - sorry about the confusion there.

yellowpanda commented 3 years ago

I think this bug originates from the following piece of code from deployment/powershell/DownloadWinUpdates.ps1:

$rss = "https://support.microsoft.com/app/content/api/content/feeds/sap/en-us/6ae59d69-36fc-8e4d-23dd-631d98bf74a9/rss"
#...
Write-Host "Getting info for latest Adobe Flash Security Update"
$rssFeed = [xml](New-Object System.Net.WebClient).DownloadString($rss)
$feed = $rssFeed.rss.channel.item | Where-Object { $_.title -like "*Security Update for Adobe Flash Player*" }
$feed = ($feed | Select-Object -Property Link | Sort-Object link -Descending) | Select-Object -First 1
$flashKB = "KB" + ($feed.link).Split('/')[4] # <--- Exception: "You cannot call a method on a null-valued expression."
$KBs += $flashKB 

If you open the rss url in a browser and search for "Security Update for Adobe Flash Player" it will not find anything. $feed will therefor be null and the code except.

You can, as suggested above, make an if (@feed) around the last 3 lines, but I guess the intention with this code is to install a patch of some kind.

mattmcspirit commented 3 years ago

This should now be fixed in the latest release.