8000 Sync fails during writing PXE file · Issue #2680 · cobbler/cobbler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Sync fails during writing PXE file #2680

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

Closed
heroin-moose opened this issue Jun 22, 2021 · 13 comments · Fixed by #2684
Closed

Sync fails during writing PXE file #2680

heroin-moose opened this issue Jun 22, 2021 · 13 comments · Fixed by #2684
Labels
Bug Report Reporting a bug main Not a release but referring to the Git main branch
Milestone

Comments

@heroin-moose
Copy link
Contributor

Describe the bug

cobbler sync fails with the following error if some of my systems have
bootloaders set to "pxe":

$ cobbler sync
...
Exception occurred: <class 'AttributeError'>
Exception value: 'NoneType' object has no attribute 'to_dict'
Exception Info:
!!! TASK FAILED !!!

Steps to reproduce

  1. Create a x86_64 distro with bootloader "pxe"
  2. Create a profile with bootloader "pxe"
  3. Create an OS with bootloader "pxe"
  4. Run cobbler sync

Expected behavior

The command should not fail.

Cobbler version

Cobbler 3.2.1
  source: ?, ?
  build time: Tue Jun 22 15:41:34 2021

Operating system

CentOS 8.

Cobbler log

[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['distro']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['profile']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['system']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['repo']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['image']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['mgmtclass']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['package']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['file']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | find_items; ['menu']
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | Exception occurred: <class 'AttributeError'>
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | Exception value: 'NoneType' object has no attribute 'to_dict'
[2021-06-22_212727_sync] 2021-06-22T21:27:28 - INFO | Exception Info:
  File "/usr/lib/python3.6/site-packages/cobbler/remote.py", line 96, in run
    rc = self._run(self)

  File "/usr/lib/python3.6/site-packages/cobbler/remote.py", line 212, in runner
    self.remote.api.sync(self.options.get("verbose", False), what=what)

  File "/usr/lib/python3.6/site-packages/cobbler/api.py", line 1379, in sync
    sync_obj.run()

  File "/usr/lib/python3.6/site-packages/cobbler/actions/sync.py", line 144, in run
    self.tftpd.sync(self.verbose)

  File "/usr/lib/python3.6/site-packages/cobbler/modules/managers/in_tftpd.py", line 177, in sync
    menu_items = self.tftpgen.get_menu_items()

  File "/usr/lib/python3.6/site-packages/cobbler/tftpgen.py", line 367, in get_menu_items
    return self.get_menu_level(None, arch)

  File "/usr/lib/python3.6/site-packages/cobbler/tftpgen.py", line 549, in get_menu_level
    self.get_profiles_menu(menu, metadata, arch)

  File "/usr/lib/python3.6/site-packages/cobbler/tftpgen.py", line 449, in get_profiles_menu
    image=None, format=boot_loader)

  File "/usr/lib/python3.6/site-packages/cobbler/tftpgen.py", line 673, in write_pxe_file
    self.build_kernel(metadata, system, profile, distro, image, format)

  File "/usr/lib/python3.6/site-packages/cobbler/tftpgen.py", line 755, in build_kernel
    blended = utils.blender(self.api, True, profile)

  File "/usr/lib/python3.6/site-packages/cobbler/utils.py", line 612, in blender
    results["children"][key] = api_handle.find_items("", name=key, return_list=False).to_dict()

[2021-06-22_212727_sync] 2021-06-22T21:27:28 - ERROR | ### TASK FAILED ###
@heroin-moose heroin-moose added the Bug Report Reporting a bug label Jun 22, 2021
Copy link
Contributor Author

I suspect that this may relate to #2681, but I am not sure yet.

@SchoolGuy SchoolGuy added this to the v3.3.0 milestone Jun 23, 2021
@SchoolGuy
Copy link
Member

Arghhh I tested that case and it is still bugged. I believe I needs to debug that deeper...

@SchoolGuy
Copy link
Member

That is happening due to the fact that I rewrote how children and parents are resolved. This means at this point we need to look a child up and now we do this with a not exisiting one which means the children dict is not consistent or I havn't added a correct skip condition (e.g. when there are no children for an object).

@SchoolGuy SchoolGuy added the main Not a release but referring to the Git main branch label Jun 23, 2021
@SchoolGuy
Copy link
Member

Okay the code in question is

cobbler/cobbler/utils.py

Lines 608 to 612 in 8000 998e3f5

if "children" in results:
child_names = results["children"]
results["children"] = {}
for key in child_names:
results["children"][key] = api_handle.find_items("", name=key, return_list=False).to_dict()

To my understanding the child should never be None since we get the list of children from the item directly. Thus I believe the root cause is that a child is wrongfully in another part of the code.

@SchoolGuy
Copy link
Member

I believe to find the root cause we need to check the following things:

  • Items: Does the children Setter and Getter work as intended.
  • Collections: Does adding a child object (e.g. profile) work in relation to if it gets added to the parent item.
  • If above gives no result:
    • API: Do we have side effects when editing an object?
    • Remote: Do we have side effects from xapi object edit for example maybe?

@SchoolGuy
Copy link
Member
SchoolGuy commented Jun 23, 2021

Okay I found a possible candidate: In the file collection.py is the child added but it never gets removed in the specific other collections.

EDIT: To be more precise: That means that you have dead children entries in your item because children don't get popped on removal.

@SchoolGuy
Copy link
Member
SchoolGuy commented Jun 27, 2021

I can't reproduce this at all but even worse I don't get any config files for any bootloader configs at all... My steps were the following (taken from bash history):

  • docker run -it --rm --name cobbler-dev -v $PWD:/code -v /mnt:/mnt cobbler-dev
  • ./docker/develop/scripts/setup-supervisor.sh
  • cobbler import --name=opensuse153 --arch=x86_64 --path=/mnt
  • cobbler system add --name=test --profile=opensuse153-x86_64 --mac=01:02:03:04:05:06
  • cobbler sync --systems=test

Result:

12bdd2eeb0c4:/code # ls -alh /srv/tftpboot/grub/system
total 8.0K
drwxr-xr-x 2 root root 4.0K Jun 27 08:26 .
drwxr-xr-x 4 root root 4.0K Jun 27 08:26 ..

This of course is then not a PXE based distro/profile but a Grub based but I still don't get any results. I tried to set the bootloader to PXE after the import but also the pxelinux.cfg directory stays empty...

@heroin-moose
Copy link
Contributor Author

You have to enable netboot for the system.

@SchoolGuy
Copy link
Member

Okay when not setting a bootloader on the system it gets not inherited by the distro. This needs to be fixed aswell.

@SchoolGuy
Copy link
Member

Okay now with --netboot-enabled=1 and manually set bootloaders, I am able to reproduce this.

@heroin-moose
Copy link
Contributor Author

You do? I can't anymore xD

@SchoolGuy
Copy link
Member

Okay so I can't reproduce above original stacktrace. My comment was referring to the stacktrace in the Gitter Chat

exception on server: 'Error with system "" - not all boot_loaders are supported (given: "[\'ipxe\', \'pxe\', \'grub\']"; supported:"[]")'

This is actually not a bug but a behavior change. If you do a

cobbler system edit --name=test --boot-loaders="<<inherit>>"

for example the inheritance to the profile is working again. I believe that this will be a usability problem in many other places, so I think we need to improve this situation before the release because most people won't read the docs to actually understand this. What also doesn't help is the misleading error message.

@SchoolGuy
Copy link
Member
SchoolGuy commented Jun 27, 2021

I will close this issue because noone is able to reproduce it anymore, the discussion about the improvements we can do in the related PR (#2684) or in another issue.

SchoolGuy added a commit that referenced this issue Jul 15, 2021
nodeg added a commit that referenced this issue Jul 26, 2021
Remove child reference on parent on collection.remove()
@SchoolGuy SchoolGuy mentioned this issue Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Reporting a bug main Not a release but referring to the Git main branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0