Foreman failed to download metadata for repo 'AppStream': cannot download repomd.xml

Problem: After upgrading katello 4.0 to 4.1.3 kickstart installations of CentOS8 is not working and fails with the same error message as the headline

Expected outcome: A working kickstart installation of CentOS8

Foreman and Proxy versions: 2.5.3

Foreman and Proxy plugin versions: 2.5.3

Distribution and version: CentOS7.9+ latest patches

Other relevant data: I think that the problem is because .treeinfo file from BaseOS point out the AppStream repo relative from BaseOS repo. e.g: “repository = AppStream”
This looks similar to my case but based on pulp2: Cannot kickstart CentOS 8

Coincidentally I had a chat on Matrix with @zhenech and he asked @lzap to chime in. This is the chatlog:

thulium-drake
o/ folks, anyone currecntly deploying foreman 2.5.3/katello 4.1.3 and doing it all with Rocky8? :-)
--
Zhenech
no? but if you have questions… ;)
--
thulium-drake
Well, I'm running into an interesting issue. I have freshly installed Foreman/Katello and synced up all the Rocky repos (I configure the whole thing with Ansible). But when kickstarting a host it tries to get it's appstream repo at 

http://<foreman base url>/MyOrg/MyLCE/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/Appstream

Instead of 

http://<foreman base url>/MyOrg/MyLCE/COV_Rocky8-Base/custom/Rocky8/Rocky8-Appstream
I think I've seen this in the past too, but I don't know for sure
(COV = composite content view btw)
--
Zhenech
yeah, I think we have a patch or two to fix that
and it might not be detecting Rocky correctly
gimme a sec
--
thulium-drake
cool, thanks!
--
Zhenech
https://github.com/theforeman/foreman/blob/45c7dd75bf6d14bc341a5f774d13becf9d702954/app/views/unattended/provisioning_templates/provision/kickstart_default.erb#L87
I think this need to check for rocky/alma too
--
thulium-drake
Well, funny thing... ;-) I was looking there earlier and changed 'centos' to 'rocky'. This is a diff of the 2 kickstart files:

## < # renamed from "http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-AppStream/" for CentOS Anaconda to work

< repo --name AppStream --baseurl http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-AppStream/
> repo --name Rocky8-AppStream --baseurl http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-AppStream/
oh crap, formatting oO
And these URLs work in my environment, but anaconda doesn't agree 
--
Zhenech
I don't think the repo *name* should change
--
thulium-drake
Agreed, when looking in /tmp/packaging.log on the kickstarted system (I'm typing this) I see the following:

Treeinfo points base repo at http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS
Then it gathers some release info, and prints

Adding new treeinfo repository Appstream enabled: true
added repo: 'AppStream' http://<foreman base url>/MyOrg/MyLCE/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/Appstream
is there a means of getting SSH access to a kickstarted box so I can retrieve the full logs? :)
--
Zhenech
no
--
thulium-drake
Well, I found a way :p 

cat EOF > /etc/ssh/sshd_config
PermitRootLogin yes
PermitEmptyPasswords yes
EOF

/usr/sbin/sshd -D

seems to work just fine :)

08:52:08,332 INF packaging: Trying to download '.treeinfo'
08:52:08,378 DBG packaging: Retrieved '.treeinfo' from http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/
08:52:08,383 DBG packaging: getting release version from tree at http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/ (8)
08:52:08,383 DBG packaging: using treeinfo release version of 8
08:52:08,383 DBG packaging: Treeinfo points base repository to http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/.
08:52:08,384 DBG packaging: releasever from http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/ is 8
08:52:08,384 DBG packaging: Adding new treeinfo repository: AppStream enabled: True
08:52:08,385 INF packaging: added repo: 'AppStream' - http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/AppStream
08:52:08,396 DBG dnf: repo: downloading from remote: AppStream
08:52:08,427 DBG dnf: error: Status code: 404 for http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/AppStream/repodata/repomd.xml (IP: 192.168.255.15) (http://foreman.lbhr.htm.lan/pulp/content
/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/AppStream/repodata/repomd.xml).

that's the actual log snippet
--
Zhenech
can you paste the actual generated kickstart please
--
thulium-drake
ks (6.29 KB)
I only removed the password and the SSH keys
The rest is just lab stuff, so not too important :-)
--
Zhenech
why aren't there any comments, stupid anaconda
but yeah, I am kinda sure the repo *needs* to be called AppStream
or anaconda will try to *guess* the url and fail
--
thulium-drake
right, I'll put that change back in and upload a new file and log 
ks (6.43 KB)
New KS file with the fix in place 
packaging.log (12.37 KB)
DNF/Packaging log
Same issue AFAICS
--
Zhenech
interesting
lzap, I remember you played with that (on CentOS)

The files mentioned are:

kickstart as it was: ks-nopatch.log (6.3 KB)
kickstart after patching the template: ks-patch.log (6.4 KB)
subsequent packaging log from installer live image: packaging-patch.log (12.4 KB)

cc @evgeni

Thank you for this @Thulium-Drake. So if I understand the solution correctly it is to name the appstream repo --name AppStream. In Katello 4.0 it worked for me with --name centos-8-appstream-x86_64. Since I already rolled back to 4.0 I don’t know when I have the opportunity to test this.

1 Like

Well not exactly, the fix I tried actually generates a repo for anaconda to use that is actually named AppStream. But the issue is that it tries to retrieve AppStream as a subdirectory of my BaseOS repo, where AppStream does not exist.

I think the actual fix is something along the lines where Pulp sees the request coming in and redirects it to the proper AppStream repository.

And it did work for CentOS8 earlier (Katello 4.0 IIRC), but I’m running on Rocky8 as our client decided to no longer use CentOS8. So we’re exploring issues there, and this is the only one I found so far :slight_smile:

Well, it seems you are right, I just updated my repo name from Rocky8-AppStream to AppStream. Afterwards I published a new version of the affected CVs, rebooted a client to install and presto!

1 Like

@lzap @evgeni I just reinstalled my Foreman server to verify the above, but it didn’t work this time around…

So I made the following changes:

  • Repo name is AppStream
  • Provisioning template Kickstart default changed line that matches only CentOS:
<% if rhel_compatible && os_major >= 8 && medium[:url] && medium[:url].include?("AppStream") -%>
<% appstream_present = true -%>
# renamed from "<%= medium[:url] %>" for EL8 Anaconda to work
repo --name AppStream --baseurl <%= medium[:url] %>
<% else -%>
repo --name <%= medium[:name] %> --baseurl <%= medium[:url] %> <%= medium[:install] ? ' --install' : '' %><%= proxy_string %>
<% end -%>
<% end -%>
<% if rhel_compatible && os_major >= 8 && medium_uri && medium_uri.to_s.include?("BaseOS") && !appstream_present -%>
# repository added using BaseOS to AppStream string replacement
repo --name AppStream --baseurl <%= medium_uri.to_s.gsub("BaseOS", "AppStream") %>
<% end -%>

The resulting KS file looks like this:

url --url http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/
repo --name Rocky8-BaseOS --baseurl http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/Rocky8-BaseOS/ 
# renamed from "http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/AppStream/" for EL8 Anaconda to work
repo --name AppStream --baseurl http://foreman.lbhr.htm.lan/pulp/content/HTM/Beheer/COV_Rocky8-Base/custom/Rocky8/AppStream/

Any clue what’s going on? And how to fix this? :slight_smile:packaging.log (12.4 KB)

Well, I did another attempt, this time, I changed the template (as mentioned above). But the repo name (in Foreman) was Rocky8-AppStream

Worked like a charm. How can I make a PR on the template? :slight_smile:

1 Like

What was the bug then?

Sure, file a PR. I am surprised you don’t know but all our templates are here:

Thanks.

From what I was able to figure out, the bug was already fixed for CentOS by adding this block:

<% if rhel_compatible && @host.operatingsystem.name.downcase.include?("centos") && os_major >= 8 && medium[:url] && medium[:url].include?("AppStream") -%>
<% appstream_present = true -%>
# renamed from "<%= medium[:url] %>" for CentOS Anaconda to work
repo --name AppStream --baseurl <%= medium[:url] %>
<% else -%>
repo --name <%= medium[:name] %> --baseurl <%= medium[:url] %> <%= medium[:install] ? ' --install' : '' %><%= proxy_string %>
<% end -%>
<% end -%>
<% if rhel_compatible && @host.operatingsystem.name.downcase.include?("centos") && os_major >= 8 && medium_uri && medium_uri.to_s.include?("BaseOS") && !appstream_present -%>
# repository added using BaseOS to AppStream string replacement
repo --name AppStream --baseurl <%= medium_uri.to_s.gsub("BaseOS", "AppStream") %>
<% end -%>

But it only matches CentOS and not the derivatives that use the same repo structure. But as how the rhel_compatible variable already sorts out which derivatives are using the same repo structure, I removed matching CentOS specifically here:

<% if rhel_compatible && os_major >= 8 && medium[:url] && medium[:url].include?("AppStream") -%>
<% appstream_present = true -%>
# renamed from "<%= medium[:url] %>" for CentOS Anaconda to work
repo --name AppStream --baseurl <%= medium[:url] %>
<% else -%>
repo --name <%= medium[:name] %> --baseurl <%= medium[:url] %> <%= medium[:install] ? ' --install' : '' %><%= proxy_string %>
<% end -%>
<% end -%>
<% if rhel_compatible && os_major >= 8 && medium_uri && medium_uri.to_s.include?("BaseOS") && !appstream_present -%>
# repository added using BaseOS to AppStream string replacement
repo --name AppStream --baseurl <%= medium_uri.to_s.gsub("BaseOS", "AppStream") %>
<% end -%>

And that did fix the kickstarting issues in my environment :slight_smile:

2 Likes

Great please file a PR many thanks! Yeah this is a difference between Anaconda in RHEL and in CentOS and clones. Let’s talk in the PR how to properly solve this because this would probably break RHEL installations.

Hi I tried again with the upgrade and with the same result. It seems my issue is related to how pulp generates the .treeinfo file for BaseOS. It points to AppStream as relative to BaseOS.

[variant-AppStream]
id = AppStream
name = AppStream
packages = AppStream/Packages
repository = AppStream
type = variant
uid = AppStream

It should instead point to: ../AppStream since the repository is located there and not under BaseOS repo.

Can anyone help me with a workaround or fix. For example is it possible to edit the .treeinfo file and put the correct info into the file?

AH, this is what I am seeing as well. I just noticed that pulp3 is generating its OWN incorrect .treeinfo different from the one in the actual upstream repo servers .treeinfo file.

Which has:


[variant-AppStream]
id = AppStream
name = AppStream
type = variant
uid = AppStream
packages = ../../../AppStream/x86_64/os/Packages
repository = ../../../AppStream/x86_64/os/

Why is pulp3 generating its own .treeinfo?

I managed to work around this issue with the following. Change ‘CentOS8/BaseOS’ to whatever product/reponame you are using.

sed -i "s#repository = AppStream#repository = ../AppStream#" $(sudo -u postgres /bin/psql pulpcore -t -c "select file from core_artifact where pulp_id=(select artifact_id from core_contentartifact where pulp_id = (select content_artifact_id from core_publishedartifact where publication_id=(select publication_id from core_distribution where base_path like '%CentOS8/BaseOS') and relative_path like '.treeinfo'))" 2>/dev/null | xargs | sed -e "s#^ *#/var/lib/pulp/media/#")

It would be really nice to get a proper fix for this though. Anyone knows who to poke?

I wrote the fix in my previous post. Updating the database will probably break your installation in the long run. If you update the provisioning template as mentioned, it will fix Kickstart for now :slight_smile:

1 Like

Hey everyone, please do not try any hacks or database changes. This seems to be working fine in the newer releases of pulp_rpm (such as 3.14.z), so the proper fix would be either upgrading or backporting the patch to the version used by this older version of Katello.

See @lzap 's answer here: Unable to kickstart Rocky Linux 8 due to .treeinfo - #17 by lzap

1 Like

I have also verified myself that it works correctly using the most recent version of upstream Pulp. The fix just needs to trickle down into Katello.

(pulp) [vagrant@pulp3-source-fedora34 devel]$ http GET :24816/pulp/content/test/
HTTP/1.1 200 OK
Content-Length: 645
Content-Type: text/html
Date: Fri, 01 Oct 2021 14:26:06 GMT
Server: Python/3.9 aiohttp/3.7.4.post0
X-PULP-CACHE: MISS

        <!DOCTYPE html>
        <html>
            <body>
                <ul>
                
                    <li><a href=".treeinfo">.treeinfo</a></li>
                
                    <li><a href="AppStream/">AppStream/</a></li>
                
                    <li><a href="Packages/">Packages/</a></li>
                
                    <li><a href="config.repo">config.repo</a></li>
                
                    <li><a href="images/">images/</a></li>
                
                    <li><a href="repodata/">repodata/</a></li>
                
                </ul>
            </body>
        </html>
        


(pulp) [vagrant@pulp3-source-fedora34 devel]$ http GET :24816/pulp/content/test/AppStream/
HTTP/1.1 200 OK
Content-Length: 323
Content-Type: text/html
Date: Fri, 01 Oct 2021 14:26:14 GMT
Server: Python/3.9 aiohttp/3.7.4.post0
X-PULP-CACHE: MISS

        <!DOCTYPE html>
        <html>
            <body>
                <ul>
                
                    <li><a href="Packages/">Packages/</a></li>
                
                    <li><a href="repodata/">repodata/</a></li>
                
                </ul>
            </body>
        </html>
        

(pulp) [vagrant@pulp3-source-fedora34 devel]$ http GET :24816/pulp/content/test/.treeinfo
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 1578
Content-Type: application/octet-stream
Date: Fri, 01 Oct 2021 14:26:31 GMT
Last-Modified: Fri, 01 Oct 2021 14:20:48 GMT
Server: Python/3.9 aiohttp/3.7.4.post0
X-PULP-CACHE: MISS                                                                                                                                                                                                                            
                                                                                                                                                                                                                                              
[checksums]           
images/boot.iso = sha256:f3af29ce6ca3c6a4b101b7109e8fe5e88d128cf446054a9467889f1eb302ea48                              
images/efiboot.img = sha256:669f24aa0ede41fb1bf5911ead6c4cca757ca4fd1e33f3639ba444dea145c05c                           
images/install.img = sha256:5eedee547bc239cd1c0e1d0afb60ecf63c7fb93eb3aa73553c86d93cae6f9752                           
images/pxeboot/initrd.img = sha256:89d2297c6c65a720194a96a07b7c77c7985c4fdf2105ab848a7c3fbb5aac2268                    
images/pxeboot/vmlinuz = sha256:d7bae03c324722e87530a50c4b351d6685b235ee22471fffc6b9d291b26105fd                       
                                                           
[general]          
; WARNING.0 = This section provides compatibility with pre-productmd treeinfos.                                        
; WARNING.1 = Read productmd documentation for details about new format.                                               
arch = x86_64
family = CentOS Stream                                     
name = CentOS Stream 8                                     
packagedir = Packages                                      
platforms = x86_64,xen                        
repository = .
timestamp = 1632776897
variant = BaseOS
variants = AppStream,BaseOS
version = 8

[header]
type = productmd.treeinfo
version = 1.2

[images-x86_64]
boot.iso = images/boot.iso
efiboot.img = images/efiboot.img
initrd = images/pxeboot/initrd.img
kernel = images/pxeboot/vmlinuz

[images-xen]
initrd = images/pxeboot/initrd.img
kernel = images/pxeboot/vmlinuz

[release]
name = CentOS Stream
short = CentOS-Stream
version = 8

[stage2]                                                   
mainimage = images/install.img                
                                                           
[tree]                
arch = x86_64   
build_timestamp = 1632776897
platforms = x86_64,xen
variants = AppStream,BaseOS
                                                           
[variant-AppStream]      
id = AppStream
name = AppStream
packages = AppStream/Packages
repository = AppStream    
type = variant                  
uid = AppStream                   
                                                           
[variant-BaseOS]
id = BaseOS 
name = BaseOS                     
packages = Packages            
repository = .
type = variant
uid = BaseOS        

1 Like

I am in conversation with Pulp engineers and management about this. It looks like only Pulp 3 was fixed, I am trying to get to an agreement to fix Pulp 2 using some workaround if possible.