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

Problem with proxy and mirroring some package repositories #204

Closed
rbouma opened this issue Dec 15, 2023 · 7 comments · Fixed by #220
Closed

Problem with proxy and mirroring some package repositories #204

rbouma opened this issue Dec 15, 2023 · 7 comments · Fixed by #220

Comments

@rbouma
Copy link

rbouma commented Dec 15, 2023

Description

We have get this error while updating proxy mirror:

An unexpected failure occurred
Service "amasty" not found: the container inside "Symfony\Component\DependencyInjection\Argument\ServiceLocator" is a smaller service locator that is empty...

config file:
config/packages/amasty.yaml

packeton:
    mirrors:
        amasty:
            url: https://composer.amasty.com/community/
            http_basic:
              username: 918a8%REDACTED%faa76
              password: 59f92a%REDACTED%05f9
            logo: 'https://commercemarketplace.adobe.com/media/customer/MAG000001054/6523c8eb9134c.png'

tried in docker and local system with manual install

Can you reproduce the bug on the Packeton demo site?

Not applicable

Database

MySQL

Screenshots

No response

How are you running Packeton?

Tried with docker:
docker run -d --name packeton
--mount type=volume,src=packeton-data,dst=/data
-p 8080:80
packeton/packeton:latest

And local manually install on Ubuntu 22.04 server with Mysql 8 and Nginx.

@vtsykun
Copy link
Owner

vtsykun commented Dec 15, 2023

Seems problem in the docker configuration or cache. I can not reproduce on demo https://demo.packeton.org/proxies/amasty

It may happens if background worker and php-fpm uses different configuration or background worker was not restarted after updating the cache. Please make sure that config/packages/amasty.yaml available for container where packagist:run-workers is running

A similar issue was fixed in version 2.4.0 here. aa3ce9b

@rbouma
Copy link
Author

rbouma commented Dec 17, 2023

@vtsykun Apparently it was a problem with the repository from Amasty itself at the time of creating this issue. Its indeed working as intended.

@rbouma rbouma closed this as completed Dec 17, 2023
@rbouma
Copy link
Author

rbouma commented Jan 15, 2024

@vtsykun Again we have same problem I can't get it to work with same amasty repository.

See the file: https://packages.epartment.nl/mirror/hapsastyepa/packages.json

CleanShot 2024-01-15 at 15 38 38
CleanShot 2024-01-15 at 15 37 50
CleanShot 2024-01-15 at 15 38 08

I want to work. What did I wrong?

@rbouma rbouma reopened this Jan 15, 2024
@vtsykun
Copy link
Owner

vtsykun commented Jan 15, 2024

Hi @rbouma

Can you provide an example of the original metadata format from here?
https://composer.amasty.com/community/packages.json

Or made composer install test with amasty repository.

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://composer.amasty.com/community"
        }
    ],
    "require": {
        "amasty/base": "*"
    }
}

Seems uid is empty in the original metadata

  [ErrorException]      
  Undefined index: uid 
  1. About the first error "Service hapsastyepa not found"

Can you login into paketon worker docker container/instance and check the cache?

docker exec -it packeton_worker_name  bash
grep 'hapsastyepa' -r var/cache/prod/

Maybe cache haven't been cleared after a configuration change php bin/console cache:clear. php bin/console cache:clear --env=prod

@rbouma
Copy link
Author

rbouma commented Jan 22, 2024

Installed amasty/base via the official repo:

❯ cat composer.lock
{
    "_readme": [
        "This file locks the dependencies of your project to a known state",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
        "This file is @generated automatically"
    ],
    "content-hash": "de3fc19d39017ecea7a9de890a45a632",
    "packages": [
        {
            "name": "amasty/base",
            "version": "1.14.7",
            "dist": {
                "type": "zip",
                "url": "https://composer.amasty.com/community/packages/amasty/base-1.14.7.zip"
            },
            "require": {
                "ext-dom": "*",
                "php": ">=7.3"
            },
            "type": "magento2-module",
            "autoload": {
                "files": [
                    "registration.php"
                ],
                "psr-4": {
                    "Amasty\\Base\\": ""
                }
            },
            "license": [
                "proprietary"
            ],
            "description": "Amasty Base"
        }
    ],
    "packages-dev": [],
    "aliases": [],
    "minimum-stability": "stable",
    "stability-flags": [],
    "prefer-stable": false,
    "prefer-lowest": false,
    "platform": [],
    "platform-dev": [],
    "plugin-api-version": "2.6.0"
}

See: https://raw.githubusercontent.com/rbouma/amasty-packages/main/packages.json For the full package metadata from amasty repo

For the second issue we run packeton on the server itself instead of running inside docker. But now I don't have this issue any more. Changed the name in the mirror config and refreshed the configs and seems to be working now.

But the mirroring still don't work due to uid.

probably the same error but when I add a package manually it has been found and added. But when I click on the package it gives an error.

See the screenshare:

CleanShot.2024-01-22.at.12.41.44.mp4

Stacktrace:

ErrorException:
Warning: Undefined array key "version_normalized"

  at src/Composer/MetadataMinifier.php:28
  at Packeton\Composer\MetadataMinifier->Packeton\Composer\{closure}()
  at usort()
     (src/Composer/MetadataMinifier.php:28)
  at Packeton\Composer\MetadataMinifier->minify()
     (src/Controller/ProxiesController.php:111)
  at Packeton\Controller\ProxiesController->metadata()
     (vendor/symfony/http-kernel/HttpKernel.php:181)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:197)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:29)
  at require_once('/home/packeton/domains/packages.epartment.nl/public_html/vendor/autoload_runtime.php')
     (public/index.php:5)          

@rbouma rbouma changed the title Problem with proxy Problem with proxy and mirroring Amasty package repository Jan 22, 2024
@rbouma rbouma changed the title Problem with proxy and mirroring Amasty package repository Problem with proxy and mirroring some package repositories Jan 22, 2024
@rbouma
Copy link
Author

rbouma commented Jan 23, 2024

Found out this is due its in lazy:true on both api v1 and api v2 mode
or lazy:false and api v2

In https://github.com/composer/composer/blob/4e5be9ee7d924d8efc58d676439b0c7bd18a9ce4/src/Composer/Repository/ComposerRepository.php#L1225-L1240

$this->lazyProvidersUrl is filled if v2 api is used then it used 'metadata-url' or in v1 with lazy is will use 'providers-lazy-url'

Then $hasProviders will return true on https://github.com/composer/composer/blob/4e5be9ee7d924d8efc58d676439b0c7bd18a9ce4/src/Composer/Repository/ComposerRepository.php#L484

Then it will not execute https://github.com/composer/composer/blob/4e5be9ee7d924d8efc58d676439b0c7bd18a9ce4/src/Composer/Repository/ComposerRepository.php#L486-L488 and continue with the code

Then it comes to this line:
https://github.com/composer/composer/blob/4e5be9ee7d924d8efc58d676439b0c7bd18a9ce4/src/Composer/Repository/ComposerRepository.php#L503

Which will execute a lot of code but in this case with uid fail this line is important:
https://github.com/composer/composer/blob/main/src/Composer/Repository/ComposerRepository.php#L932

The only thing i can find is https://github.com/rande/pkgmirror/blob/452f8747413a/mirror/composer/composer_structs.go#L35 where for package there is a definition that per package there needs to be a sort of unique identifier in lazy or v2 mode in combination with mirroring.

I have this now with Amasty and Swissup repositories for mirroring both doesn't have an uid.


solution?
disable lazy mode and use v1 api then it works.

@vtsykun
Copy link
Owner

vtsykun commented Jan 24, 2024

The error has been fixed, you can try now.

For the second issue we run packeton on the server itself instead of running inside docker. But now I don't have this issue any more. Changed the name in the mirror config and refreshed the configs and seems to be working now.

Probably after update configs need to clear cache with command php bin/console cache:clear php bin/console cache:clear --env=prod and restart worker

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

Successfully merging a pull request may close this issue.

2 participants