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

tdnf does not set a user agent when doing http requests #451

Closed
chrischdi opened this issue Sep 11, 2023 · 5 comments
Closed

tdnf does not set a user agent when doing http requests #451

chrischdi opened this issue Sep 11, 2023 · 5 comments
Labels

Comments

@chrischdi
Copy link
Member

chrischdi commented Sep 11, 2023

Describe the bug

The kubernetes-sigs project image-builder tries to switch the used repositories to the new upstream repository at pkgs.k8s.io (via this PR: kubernetes-sigs/image-builder#1280 ).

However, the installation or to be more precise tdnf makecache fails when using that repository with a 403 http error.

It turns out that tdnf does not set any user agent in its requests.

Note: I was also not able to find a possibility to configure the user agent for tdnf.

Reproduction steps

  1. Run photon in a container docker run -ti --rm photon:latest

  2. Create the repo entry:

    cat << EOF > /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=kubernetes
    description=the kubernetes yum repo
    baseurl=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/
    gpgcheck=True
    gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
    enabled=1
    
    EOF
    
  3. Try to update the caches: tdnf install kubelet-1.26.7 --nogpgcheck -y

Output:

Refreshing metadata for: 'kubernetes'
kubernetes                                 919 100%
Error: 403 when downloading https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml
. Please check repo url or refresh metadata with 'tdnf makecache'.
Error(1622) : Invalid argument
Error: Failed to synchronize cache for repo 'kubernetes'
Error(1622) : Invalid argument

Expected behavior

tdnf makecache to succeed.

Additional context

According to slack, this happens at the repository because they use AWS AWF, which blocks requests which have an empty/not set user agent.

After analysing the request using mitmdump I was able to see that tdnf does not set any request, when requesting: https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml

It is reproducible using curl:

curl -L -H 'User-Agent:' https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml

xref: kubernetes-sigs/image-builder#1280 (comment)

Slack thread with the maintainers of the repository: https://kubernetes.slack.com/archives/C03U7N0VCGK/p1694194051373989

@chrischdi
Copy link
Member Author

Note: they changed the pkgs.k8s.io infrastructure to now allow empty user agents.

However, I think this would be still a valuable feature to implement.

@oliverkurth
Copy link
Contributor

Interesting. If just setting an empty User-Agent header is enough to make kubernetes-sigs happy then that sounds like an issue with the latter - it doesn't get any information from it. I am glad they fixed it.

But I don't see any issue with adding that header to tdnf.

@chrischdi
Copy link
Member Author

Yeah, it is a default settings to get blocked if you are hosting behind AWS WAF https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html

And I think at least having the option to configure it is good.

@oliverkurth
Copy link
Contributor

The header can be anything, right? So I think if we add it, then with something useful - like mentioning the version of tdnf, and maybe the OS and version. I don't think it needs to be configurable.

@oliverkurth
Copy link
Contributor

This has been fixed a while ago with #453 . I forgot to close this.

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

No branches or pull requests

2 participants