GoogleCloudPlatform / artifact-registry-yum-plugin

Apache License 2.0
6 stars 13 forks source link

Authentication broken due to PR #29 #30

Closed rbelnap closed 1 year ago

rbelnap commented 1 year ago

https://github.com/GoogleCloudPlatform/artifact-registry-yum-plugin/pull/29#issuecomment-1460333601 has the details, but putting in an issue as well for better visibility.

This issue breaks authentication for all our internal repos, and I'd be surprised if we are the only ones. Although I'd be happy to be an outlier in this case, I think this is likely pretty common.

thenger commented 1 year ago

I'm adding some info for this problem to be found by users of artifact-registry (as I didn't find this right away)

Problem:

# yum --disablerepo=* --enablerepo=boop-yum makecache
boop-yum                                                                                                                234  B/s | 181  B     00:00
Errors during downloading metadata for repository 'boop-yum':
  - Status code: 403 for https://europe-west9-yum.pkg.dev/projects/boopproject/boop-yum/repodata/repomd.xml (IP: 199.36.153.5)
Error: Failed to download metadata for repo 'boop-yum': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

Please note that testing with curl without proper Headers won't be relevant because dnf plugin add them to the request.

One liner used to apply the fix proposed by @rbelnap:

sed -ri 's,in (repo.baseurl),in str(\1),g' /usr/lib/python3.6/site-packages/dnf-plugins/artifact-registry.py

ymmv for the python version of course (and for the file location maybe) (also yes still python 3.6 :c )

hth

infinyhost commented 1 year ago

Yes, repo.baseurl doesn't seem to be a string and code always fails to run. Casting it inline to a string works like a charm.

derrickqin commented 1 year ago

We also encountered this issue. For anyone who found this post, the temporary fix is:

  1. Run sudo find / -name artifact-registry.py to find the source code. In my case, it is here: /usr/lib/python3.6/site-packages/dnf-plugins/artifact-registry.py

  2. Run sudo vim /usr/lib/python3.6/site-packages/dnf-plugins/artifact-registry.py, then add the old version of the code in:

    def config(self):
    """ Setup http headers to repos with baseurl option containing pkg.dev. """
    for repo in self.base.repos.iter_enabled():
      opts = dict(repo.cfg.items(repo.id))
      if 'pkg.dev' in opts.get('baseurl', '') and not self.error:
    
      #if not hasattr(repo, 'baseurl'):
      #  continue
      #if 'pkg.dev' in repo.baseurl and not self.error:
        self._add_headers(repo)

    After that, dnf makecache didn't report any issues.

derrickqin commented 1 year ago

Hi all,

I can see that there is a code commit fixing this issue and a new release available.

You can run dnf makecache then sudo dnf upgrade dnf-plugin-artifact-registry to install the updated version.

It is a bit disappointing that nobody acknowledge this issue on the Github issue and they just silently released a fix. But at least it works now.

lindsayismith commented 1 year ago

Hi, sorry we didn't make a comment here. I raised this internally, we discussed and had someone work on a fix but that conversation didn't make it out here. I'll try and encourage better external updates as well. Thanks for confirming the fix is good.

dorileo commented 1 year ago

Closing this one given the @lindsayismith confirmation.