chriseldredge / Klondike

Ember front-end that builds on NuGet.Lucene for private package hosting
Apache License 2.0
299 stars 74 forks source link

Klondike mirroring another Klondike mirroring Nuget.org doesn't work #155

Open llehn opened 8 years ago

llehn commented 8 years ago

I have a setup where I have Klodike which is solely a mirror of another Klondike which mirrors nuget and has some other packages pushed to it.

It doesn't work at all.

This is nuget output:

GET http://nuget.***.com:8080/api/odata/FindPackagesById()?$filter=IsLatestVersion&$orderby=Version desc&$top=1&id='Endzone.CQRS'
GET http://nuget.***.com:8080/api/odata/Packages(Id='Endzone.CQRS',Version='1.0')
GET http://nuget.***.com:8080/api/odata/Packages(Id='Endzone.CQRS',Version='1.0.0')
GET http://nuget.***.com:8080/api/odata/Packages(Id='Endzone.CQRS',Version='1.0.0.0')
System.InvalidOperationException: Unable to find version '1.0' of package 'Endzone.CQRS'.
   bei NuGet.PackageRepositoryHelper.ResolvePackage(IPackageRepository sourceRepository, IPackageRepository localRepository, IPackageConstraintProvider constraintProvider, String p
ackageId, SemanticVersion version, Boolean allowPrereleaseVersions)
   bei NuGet.PackageManager.InstallPackage(String packageId, SemanticVersion version, Boolean ignoreDependencies, Boolean allowPrereleaseVersions)
   bei NuGet.Commands.InstallCommand.InstallPackage(IFileSystem fileSystem, String packageId, SemanticVersion version)
   bei NuGet.Commands.InstallCommand.ExecuteCommand()
   bei NuGet.Commands.Command.Execute()
   bei NuGet.Program.Main(String[] args)

This is the logfile of the first Klondike (which is contacted by nuget)

2016-06-08 13:01:56,072 INFO   1 KlondikeService OnStart Using ServerFactory Nowin
2016-06-08 13:01:56,449 INFO   1 LucenePackageRepository UpdatePackageCount Refreshing index. Package count: 0
2016-06-08 13:01:58,112 INFO   Threadpool worker LucenePackageRepository SynchronizeWithFileSystem Synchronizing packages with filesystem.
2016-06-08 13:01:58,157 INFO   1 KlondikeService OnStart Listening for HTTP requests on address(es): http://*:8080/
2016-06-08 13:03:14,018 INFO   Threadpool worker MirroringPackageRepository FindPackagesByIdInOrigin Found package Endzone.CQRS at http://***:8080/api/odata/

This is the logfile of the second Klondike, which talks to nuget.org

2016-06-08 13:02:04,168 INFO   1 KlondikeService OnStart Using ServerFactory Nowin
2016-06-08 13:02:04,596 INFO   1 LucenePackageRepository UpdatePackageCount Refreshing index. Package count: 2
2016-06-08 13:02:06,562 INFO   Threadpool worker LucenePackageRepository SynchronizeWithFileSystem Synchronizing packages with filesystem.
2016-06-08 13:02:06,620 INFO   1 KlondikeService OnStart Listening for HTTP requests on address(es): http://*:8080/
2016-06-08 13:03:36,515 INFO   Threadpool worker MirroringPackageRepository FindPackagesByIdInOrigin Found package Endzone.CQRS at http://www.nuget.org/api/v2/

Is this "by design"? Or can we make it work somehow?

chriseldredge commented 8 years ago

What version of the NuGet.exe client are you using?

The protocol for how NuGet client interacts with a NuGet server over http is constantly "evolving", meaning it often breaks.

Does using the client directly on the second Klondike mirror a package correctly? if so, the issue is likely in Klondike.

llehn commented 8 years ago

I was using nuget 2.8. It worked when using directly the 2nd server. Today I tried with nuget 3.4.4. Here nothing works at all :(

llehn commented 8 years ago

The cause of the problem was something else, in case of one server.

I have an apache as reverse proxy with SSL, and my settings did not translate the http:// url in the odata api into https. Now I fixed that nuget instal works when going to second server.

The server-chain would probably work if someone implemented the proxy feature mentions in another issue.

llehn commented 7 years ago

I think we need to reopen this. So the scenario is still the same, klondike mirroring klondike

A is mirroing B: on A:

GET https://nuget.kardex.com/api/odata/FindPackagesById()?id=%27My.Package%27

gives this response:

{  "message": "Not authenticated."
}HTTP/1.1 200 OK
Content-Length: 1087
Server: Nowin
Date: Tue, 30 Aug 2016 08:28:32 GMT
Cache-Control: must-revalidate, max-age=0, private
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization, Accept, Origin, X-NuGet-ApiKey
Content-Type: application/json; charset=utf-8
DataServiceVersion: 3.0

{
  "odata.metadata":"https://nuget.kardex.com/api/odata/$metadata#Packages","value":[
    {
      "odata.mediaReadLink":"https://nuget.kardex.com/api/packages/My.Package/1.0.7/content","odata.mediaContentType":"application/zip","Id":"My.Package","Version":"1.0.7","NormalizedVersion":"1.0.7","Title":null,"DisplayTitle":"My.Package","Authors":"Kardex INternal","Owners":"Kardex INternal","IconUrl":null,"LicenseUrl":null,"ProjectUrl":null,"DownloadCount":1,"RequireLicenseAcceptance":false,"Description":"Infragistics binaries for PPG, Kardex internal","Summary":null,"ReleaseNotes":null,"Language":null,"Created":"0001-01-01T00:00:00","Published":"2016-08-29T20:32:37Z","LastUpdated":"2016-08-29T20:32:37Z","Dependencies":"","PackageHash":"kKWGMVtuj5w8PYhs/QQrkeWhl5qctw8d6jQKL4egX8w=","PackageHashAlgorithm":"SHA256","PackageSize":"0","Copyright":null,"Tags":null,"IsAbsoluteLatestVersion":true,"IsLatestVersion":true,"IsPrerelease":false,"Listed":true,"DevelopmentDependency":false,"VersionDownloadCount":0,"Score":0
    }
  ]

which is correct. At this point A does not have a local copy of My.Package.

But when we do GET to the odata.mediaReadLink from the response like this:

GET https://nuget.kardex.com/api/packages/My.Package/1.0.7/content

instead of pulling the package from B and presenting it to the client what I get is this:

Message
Package My.Package version 1.0.7 not found.

This very mechanism works as intended, when B is not klondike, but the nuget.org gallery