-
Notifications
You must be signed in to change notification settings - Fork 907
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
Сhoco search returns different results for GHC package #2271
Comments
@miketimofeev I haven't dug into this, so I don't have any answers for you yet, but can I ask what the process you follow for installation is? Why the need to first search for all versions? Aren't you pinning to the installation of a specific version as part of the build of the image? |
@gep13 sorry, I should have mentioned that we need to provide the 3 latest GHC versions to customers: |
Would the following via OData help? $ODataQuery = '$filter=(Title eq ''ghc'') and (IsPrerelease eq false)'
$Url = "https://community.chocolatey.org/api/v2/Packages()?$ODataQuery"
Invoke-RestMethod -Uri ($Url + '&$top=3') |
Select-Object -Property @( @{ Name = 'Id' ; Expression = { $_.title.innertext } }
@{ Name = 'Version' ; Expression = { $_.properties.Version }}) That returns the following:
|
To be fair, that's more or less what is happening under the covers with |
@steviecoaster thanks for the answer! For me it returns the following:
However, choco search returns the following in case there are no issues
|
That looks like a sorting issue in the OData query. If we modify the OData query to include an
this is using the following code: $ODataQuery = '$filter=(Title eq ''ghc'') and (IsPrerelease eq false)&$orderby=Version desc&$top=3'
$Url = "https://community.chocolatey.org/api/v2/Packages()?$ODataQuery"
Invoke-RestMethod -Uri $Url |
Select-Object -Property @(
@{ Name = 'Id'; Expression = { $_.title.innertext } }
@{ Name = 'Version'; Expression = { $_.properties.Version } }
) I'd be interested to know if y'all are getting bad results from that query occasionally similar to how you're getting intermittently bad results from |
@vexx32 Sorry, I forgot to mention that we need not the 3 latest versions, but 3 latest major.minor versions like 9.0.1, 8.10.4, 8.8.4.1 — that's why we use the additional filtration using Powershell. I'm not sure it can be done using ODataQuery. |
Ah, that's on me, sorry about that, I must have edited that without thinking. The parameter is case sensitive and should be |
I have verified, that when choco search --allversions did not return version 9.0.1 the odata query did. PS C:\> Write-Host ('Result from odata query ({0})' -f (Get-Date))
$ODataQuery = '$filter=(Title eq ''ghc'') and (IsPrerelease eq false)&$orderby=Version desc&$top=3'
$Url = "https://community.chocolatey.org/api/v2/Packages()?$ODataQuery"
Invoke-RestMethod -Uri $Url |
Select-Object -Property @(
@{ Name = 'Id'; Expression = { $_.title.innertext } }
@{ Name = 'Version'; Expression = { [Version]$_.properties.Version } }
)
Result from odata query (25.05.2021 11:49:07)
Id Version
-- -------
ghc 9.0.1
ghc 8.8.4.1
ghc 8.8.4
---------------------------------------------------------------
PS C:\> Write-Host ('Result from choco search ({0})' -f (Get-Date))
& choco search ghc --allversions --source=https://community.chocolatey.org/api/v2/ | Where-Object { $_.StartsWith('ghc ') -and $_ -match 'Approved' } | ForEach-Object { [regex]::matches($_, '\d+(\.\d+){2,}').value } | Sort-Object | Select-Object -Last 3
Result from choco search (25.05.2021 11:50:00)
8.8.3.1
8.8.4
8.8.4.1 therefore i sugested a modification (see comment on actions/runner-images#3434 (comment) |
We haven't seen the issue since switching to use OData instead of choco search so it seems that something goes wrong with the search command itself 🤔 |
What You Are Seeing?
We use choco during GitHub hosted images generation in https://github.com/actions/virtual-environments repository.
We have been observing an intermittent issue since GHC 9.0.1 was released in March — sometimes
choco search ghc --allversions
returns 9.0.1 and sometimes doesn't. As a result, different ghc versions are available on the final VM image, which is confusing.What is Expected?
choco search ghc --allversions
returns version 9.0.1 among the othersHow Did You Get This To Happen? (Steps to Reproduce)
Just run
choco search ghc --allversions
and check the results. It happens pretty irregularly, maybe 1 or 2 times a week.Output Log
The log from
choco search ghc --allversions --verbose --trace
in one of such cases is more than the allowed comment size so I uploaded it to the repo:https://github.com/miketimofeev/Choco-search-log/blob/main/Log.log
The text was updated successfully, but these errors were encountered: