8000 Skip wrong/inconsistent collections instead of crashing by meaksh · Pull Request #3313 · cobbler/cobbler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Skip wrong/inconsistent collections instead of crashing #3313

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

Merged
merged 1 commit into from
Feb 4, 2023

Conversation

meaksh
Copy link
Member
@meaksh meaksh commented Jan 5, 2023

Description

Fixes #532

This PR makes Cobbler service more tolerant to any unexpected issue when loading collections.

Instead of making Cobbler to crash, this PR makes it to skip collections that cannot be loaded and keep the service running.

This way, we are not blocking other collections and particularly the entire Cobbler service to work in case of a problem with a particular collection.

Old:

New:

Category

This is related to a:

  • Bugfix
  • Feature
  • Packaging
  • Docs
  • Code Quality
  • Refactoring
  • Miscellaneous

Tests

  • Unit-Tests were created
  • System-Tests were created
  • Code is already covered by Unit-Tests
  • Code is already covered by System-Tests
  • No tests required

This commit makes Cobbler service more tolerant to any unexpected
issue when loading collections. Instead of making Cobbler to crash,
this commit make it to skip collections that cannot be loaded and keep
the service running.

This way, we are not blocking other collections and particularly the
entire Cobbler service to work in case of a problem with a particular
collection.
@codecov
Copy link
codecov bot commented Jan 5, 2023

Codecov Report

Base: 65.43% // Head: 65.41% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (22dc2c8) compared to base (40110c5).
Patch coverage: 62.50% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3313      +/-   ##
==========================================
- Coverage   65.43%   65.41%   -0.02%     
==========================================
  Files         113      113              
  Lines       15155    15164       +9     
==========================================
+ Hits         9916     9920       +4     
- Misses       5239     5244       +5     
Impacted Files Coverage Δ
cobbler/utils/__init__.py 66.83% <0.00%> (-0.12%) ⬇️
cobbler/cobbler_collections/collection.py 72.32% <60.00%> (-0.53%) ⬇️
cobbler/modules/serializers/file.py 89.04% <77.77%> (-2.14%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@SchoolGuy SchoolGuy added this to the v3.4.0 milestone Jan 7, 2023
@SchoolGuy
Copy link
Member

Interesting take on the startup problems however, you need to solve the inheritance chain, so that depending collections are not being loaded as well.

@meaksh
Copy link
Member Author
meaksh commented Jan 10, 2023

@SchoolGuy from the tests I did, I think the inheritance chain is somehow also skipped.

Let say I have a distro and profile for this distro, properly loaded on Cobbler:

# cobbler distro list
    Leap_154_wrong:1:admin

# cobbler profile list
    test-wrong-distro-profile

Then I explicitely corrupt the distro collection file by placing some unexpected attributed.

Once I restart Cobbler, having this distro collection which is wrong now, I see Cobbler skipping the distro and the profile during the startup and make them unavalable:

# tail /var/log/cobbler/cobbler.log
...
[Daemon] 2023-01-10T11:58:12 - ERROR | Error while loading a collection: "The following keys supplied could not be set: ['foobar_attribute_corrupt']". Skipping this collection!
[Daemon] 2023-01-10T11:58:12 - ERROR | Error while loading a collection: distribution "Leap_154_wrong:1:admin" not found. Skipping this collection!
[Daemon] 2023-01-10T11:58:12 - INFO | Cobbler startup completed  in 3.4226715564727783 seconds

# cobbler distro list

# cobbler profile list

@SchoolGuy
Copy link
Member

@meaksh Okay this PR is looking good. I wasn't expecting that this is already handled. Is this working equally with MongoDB?

@meaksh
Copy link
Member Author
meaksh commented Jan 10, 2023

I haven't tested this on a deployment using MongoDB - will need to give it a try

@meaksh
Copy link
Member Author
meaksh commented Feb 3, 2023

@SchoolGuy I've tested this PR using mongodb as serializer module for collections, and it looks fine:

  1. With no collections stored in my filesystem:
# find /var/lib/cobbler/collections/
/var/lib/cobbler/collections/
/var/lib/cobbler/collections/distros
/var/lib/cobbler/collections/files
/var/lib/cobbler/collections/images
/var/lib/cobbler/collections/menus
/var/lib/cobbler/collections/mgmtclasses
/var/lib/cobbler/collections/packages
/var/lib/cobbler/collections/profiles
/var/lib/cobbler/collections/repos
/var/lib/cobbler/collections/systems
  1. Having my configured MongoDB instance with 3 stored distros, where I made 2 of them invalid by removing the configured initrd and kernel files for test-distro-gke and test-distro3. So these two distros are invalid collections now and only test-distro2 should be valid now:
cobbler> db.distro.find()
[
  {
    _id: ObjectId("63dcdefa645b24ac92262f1c"),
    parent: '',
    depth: 0,
    children: [],
    ctime: 1675419386.7625694,
    mtime: 1675419386.7625694,
    uid: '0ca6b61ef04e40a99a1c55975981857d',
    name: 'test-distro-gke',
    comment: '',
    kernel_options: {},
    kernel_options_post: {},
    autoinstall_meta: {},
    fetchable_files: {},
    boot_files: {},
    template_files: {},
    owners: '<<inherit>>',
    mgmt_classes: [],
    mgmt_parameters: {},
    is_subobject: false,
    tree_build_time: 0,
    arch: 'x86_64',
    boot_loaders: '<<inherit>>',
    breed: '',
    initrd: '/initrd',
    kernel: '/linux',
    os_version: '',
    redhat_management_key: '<<inherit>>',
    source_repos: [],
    remote_boot_kernel: '',
    remote_boot_initrd: ''
  },
  {
    _id: ObjectId("63dce1524b3a428134d1a7c2"),
    parent: '',
    depth: 0,
    children: [],
    ctime: 1675419986.7887084,
    mtime: 1675423149.2387583,
    uid: 'c6f211cece014878a7bc96b67626fa6b',
    name: 'test-distro2',
    comment: 'hola',
    kernel_options: {},
    kernel_options_post: {},
    autoinstall_meta: {},
    fetchable_files: {},
    boot_files: {},
    template_files: {},
    owners: '<<inherit>>',
    mgmt_classes: [],
    mgmt_parameters: {},
    is_subobject: false,
    tree_build_time: 0,
    arch: 'x86_64',
    boot_loaders: '<<inherit>>',
    breed: '',
    initrd: '/initrd2',
    kernel: '/linux2',
    os_version: '',
    redhat_management_key: '<<inherit>>',
    source_repos: [],
    remote_boot_kernel: '',
    remote_boot_initrd: ''
  },
  {
    _id: ObjectId("63dce6c90bdaa2953a2a6f13"),
    parent: '',
    depth: 0,
    children: [],
    ctime: 1675421385.942577,
    mtime: 1675421385.942577,
    uid: '8c56ecdd206f4d63860f6c4960cdbcf6',
    name: 'test-distro3',
    comment: '',
    kernel_options: {},
    kernel_options_post: {},
    autoinstall_meta: {},
    fetchable_files: {},
    boot_files: {},
    template_files: {},
    owners: '<<inherit>>',
    mgmt_classes: [],
    mgmt_parameters: {},
    is_subobject: false,
    tree_build_time: 0,
    arch: 'x86_64',
    boot_loaders: '<<inherit>>',
    breed: '',
    initrd: '/initrd',
    kernel: '/linux',
    os_version: '',
    redhat_management_key: '<<inherit>>',
    source_repos: [],
    remote_boot_kernel: '',
    remote_boot_initrd: ''
  }
]
  1. After starting cobblerd, I get the expected new error messages about skipping wrong collections and the cobblerd service keeps alive after startup, with the only one consistent distro loaded:
# cobblerd
INFO | Automigration NOT executed
INFO | python3-hivex not found. If you need Automatic Windows Installation support, please install.
INFO | 11 breeds and 131 OS versions read from the signature file
ERROR | Error while loading a collection: initrd not found. Skipping this collection!
ERROR | Error while loading a collection: initrd not found. Skipping this collection!
INFO | cobblerd started

# cobbler distro list
   test-distro2

BTW, during these tests I found some bugs on the mongodb serializer that I'm fixing in an upcoming PR I'll create in a moment.

@meaksh meaksh marked this pull request as ready for review February 3, 2023 11:29
@meaksh meaksh requested a review from SchoolGuy February 3, 2023 11:29
Copy link
Member
@SchoolGuy SchoolGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@SchoolGuy SchoolGuy merged commit 025d4b2 into main Feb 4, 2023
@SchoolGuy SchoolGuy deleted the main-skip-wrong-collections-instead-crashing branch February 4, 2023 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Log when a config object is ignored because a dependency is missing
2 participants
0