-
-
Notifications
You must be signed in to change notification settings - Fork 650
[RFC] Allow sync only work on specified systems #2601
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
Conversation
This is exactly what we need to circumvent our current performance bottleneck. So yes please go forward with this PR. If you can't finish it, I will take over. If you need help, ping me! Thanks for tackling this! |
thanks, i will make sure everything get tracked and test through out |
Codecov Report
@@ Coverage Diff @@
## master #2601 +/- ##
==========================================
+ Coverage 28.10% 28.25% +0.15%
==========================================
Files 84 84
Lines 11690 11752 +62
==========================================
+ Hits 3285 3321 +36
- Misses 8405 8431 +26
Continue to review full report at Codecov.
|
@watologo1 You definitely want to help out here please! Test it at least since this will spare us of a lot of time for Orthos 2! |
@SchoolGuy (venv) [root@centos-s-1vcpu-1gb-sfo3-01 cobbler]# python3 bin/cobbler sync
task started: 2021-03-18_191855_sync
task started (id=Sync, time=Thu Mar 18 19:18:55 2021)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS7.4-x86_64
removing: /var/www/cobbler/images/testdistroedit
removing: /var/lib/tftpboot/pxelinux.cfg/01-7b-ee-9d-b2-5e-d5
removing: /var/lib/tftpboot/pxelinux.cfg/01-7b-ee-9d-b2-5e-d6
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/grub.cfg
removing: /var/lib/tftpboot/grub/local_efi.cfg
removing: /var/lib/tftpboot/grub/local_legacy.cfg
removing: /var/lib/tftpboot/grub/local_powerpc-ieee1275.cfg
removing: /var/lib/tftpboot/grub/x86_64_menu_items.cfg
removing: /var/lib/tftpboot/images/CentOS7.4-x86_64
removing: /var/lib/tftpboot/images/testdistroedit
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout:
received on stderr:
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout:
received on stderr:
copying distros to tftpboot
copying files for distro: CentOS7.4-x86_64
trying hardlink /var/www/cobbler/distro_mirror/CentOS7.4-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS7.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/CentOS7.4-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS7.4-x86_64/initrd.img
copying files for distro: testdistroedit
running: /usr/bin/sha1sum /var/log/cobbler/cobbler.log
received on stdout: 54bf36f727db6a6efac3b8c2dd85b4cbc0688eb2 /var/log/cobbler/cobbler.log
received on stderr:
trying to create cache file /var/lib/tftpboot/images/.link_cache/54bf36f727db6a6efac3b8c2dd85b4cbc0688eb2
copying: /var/log/cobbler/cobbler.log -> /var/lib/tftpboot/images/.link_cache/54bf36f727db6a6efac3b8c2dd85b4cbc0688eb2
trying cachelink /var/log/cobbler/cobbler.log -> /var/lib/tftpboot/images/.link_cache/54bf36f727db6a6efac3b8c2dd85b4cbc0688eb2 -> /var/lib/tftpboot/images/testdistroedit/cobbler.log
trying cachelink /var/log/cobbler/cobbler.log -> /var/lib/tftpboot/images/.link_cache/54bf36f727db6a6efac3b8c2dd85b4cbc0688eb2 -> /var/lib/tftpboot/images/testdistroedit/cobbler.log
copying: /var/log/cobbler/cobbler.log -> /var/lib/tftpboot/images/testdistroedit/cobbler.log
copying images
generating PXE configuration files
generating: /var/lib/tftpboot/pxelinux.cfg/01-7b-ee-9d-b2-5e-d5
generating: /var/lib/tftpboot/grub/system/7b:ee:9d:b2:5e:d5
generating: /var/lib/tftpboot/pxelinux.cfg/01-7b-ee-9d-b2-5e-d6
generating: /var/lib/tftpboot/grub/system/7b:ee:9d:b2:5e:d6
generating PXE menu structure
copying files for distro: CentOS7.4-x86_64
trying hardlink /var/www/cobbler/distro_mirror/CentOS7.4-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS7.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/CentOS7.4-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS7.4-x86_64/initrd.img
Writing template files for CentOS7.4-x86_64
copying files for distro: testdistroedit
trying symlink /var/log/cobbler/cobbler.log -> /var/www/cobbler/images/testdistroedit/cobbler.log
removing: /var/www/cobbler/images/testdistroedit/cobbler.log
trying symlink /var/log/cobbler/cobbler.log -> /var/www/cobbler/images/testdistroedit/cobbler.log
Writing template files for testdistroedit
processing boot_files for distro: CentOS7.4-x86_64
processing boot_files for distro: testdistroedit
cleaning link caches
running: find /var/lib/tftpboot/images/.link_cache -maxdepth 1 -type f -links 1 -exec rm -f '{}' ';'
received on stdout:
received on stderr:
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE *** A systems sync would like this (only one systems actually exists a.b.com and c.d.com does not exist)
i m seeing some more unit test can be added, but not super familiar with how you guys does the unit test here.
please let me know if you need more case in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly touched some spelling and consistency issues.
I haven't tested this myself and can't judge the code in a professional way.
8000
summary>
thanks for checking my grammar. same as the case i use i am happy to change them if its necessary, but i suggest we keep them the same, cause they are already like a standard there? |
So although not being a formal review of your PR, I so far like what I see. Codacy complaints we will need to solve on a different PR, so yes you may ignore that. Regarding the tests... I believe that this will be trick
8000
y. Either you do it like me and dig into @watologo1 maybe you could do some manual testing for this PR in case you have the time please? I don't have that time currently, since it is the final weeks of my apprenticeship as you know... |
@cxfcxf Let's discuss what the best way is to get this all together... |
totally, in my (company) daily use case, we have the cobbler manage all the bits of dns/dhcp/tftp there was actually another way (make write on file multithreading) open ton of file handles and write all of them in the same time, this is another choice, but requires more code to handle threading.(prob not a good route thus not picked) wondering if you agree on above logic? if we agree, we can have all of them (i can rebase my change on top of yours with some modification of code)
|
@cxfcxf We will rebase this for you and write tests for you. Thank you for your efforts! This will circumvent the performance issues greatly! |
This will refactor cobbler sync by moving everything from litesync.py into sync.py. Furthermore `make_tftpboot()` was made private and renamed to `__create_tftpboot_dirs()` since it does only create the required directories. This is a preliminary work for cobbler#2601.
This will 6D40 refactor cobbler sync by moving everything from litesync.py into sync.py. Furthermore `make_tftpboot()` was made private and renamed to `__create_tftpboot_dirs()` since it does only create the required directories. This is a preliminary work for cobbler#2601.
Rebase done. Still todo before merging:
|
I did some testing: $ cobbler version
Cobbler 3.2.1
source: 87d60a6d, Mon May 3 11:11:42 2021 +0200
build time: Mon May 3 09:25:23 2021
$ cobbler system list
dom_test
dom_test2
$ tree -L 3 .
.
├── boot
├── etc
├── grub
│ ├── images -> ../images
│ ├── system
│ ├── system_link
│ └── x86_64_menu_items.cfg
├── images
│ └── CentOS-Stream-x86_64
│ ├── initrd.img
│ └── vmlinuz
├── images2
├── ppc
├── pxelinux.cfg
│ └── default
└── s390x
12 directories, 4 files
$ cobbler system edit --name=dom_test --mac-address=random
$ tree -L 3 .
.
├── boot
├── etc
├── grub
│ ├── images -> ../images
│ ├── system
│ │ └── 00:16:3e:0e:ec:13
│ ├── system_link
│ │ └── dom_test -> ../system/00:16:3e:0e:ec:13
│ └── x86_64_menu_items.cfg
├── images
│ └── CentOS-Stream-x86_64
│ ├── initrd.img
│ └── vmlinuz
├── images2
├── ppc
├── pxelinux.cfg
│ ├── 01-00-16-3e-0e-ec-13
│ └── default
└── s390x
12 directories, 7 files
$ cobbler system report
Name : dom_test
(...)
Profile : CentOS-Stream:x86_64
(...)
MAC Address : 00:16:3e:0e:ec:13
(...) After generati
9E88
ng a random MAC address, I manually changed a file and did a $ cat pxelinux.cfg/01-00-16-3e-0e-ec-13
default linux
prompt 0
timeout 1
label linux
kernel /images/CentOS-Stream-x86_64/vmlinuz
ipappend 2
append initrd=/images/CentOS-Stream-x86_64/initrd.img kssendmac inst.ks=http://127.0.0.1/cblr/svc/op/autoinstall/system/dom_test
$ sudo vi pxelinux.cfg/01-00-16-3e-0e-ec-13
$ cat pxelinux.cfg/01-00-16-3e-0e-ec-13
default linux_dom_test
prompt 0
timeout 4
label linux_dom_test
kernel /images/CentOS-Stream-x86_64/vmlinuz
ipappend 2
append initrd=/images/CentOS-Stream-x86_64/initrd.img kssendmac inst.ks=http://127.0.0.1/cblr/svc/op/autoinstall/system/dom_test $ cobbler sync --systems=dom_test
task started: 2021-05-03_114354_syncsystems
task started (id=Syncsystems, time=Mon May 3 11:43:54 2021)
running python triggers from /var/lib/cobbler/triggers/task/syncsystems/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/syncsystems/pre/*
shell triggers finished successfully
sync_systems
running pre-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/sync/pre/*
shell triggers finished successfully
generating PXE configuration files
generating: /srv/tftpboot/pxelinux.cfg/01-00-16-3e-0e-ec-13
generating: /srv/tftpboot/grub/system/00:16:3e:0e:ec:13
removing: /srv/tftpboot/grub/system_link/dom_test
generating PXE menu structure
mkdir: /srv/tftpboot/pxelinux.cfg
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***
$ cat pxelinux.cfg/01-00-16-3e-0e-ec-13
default linux
prompt 0
timeout 1
label linux
kernel /images/CentOS-Stream-x86_64/vmlinuz
ipappend 2
append initrd=/images/CentOS-Stream-x86_64/initrd.img kssendmac inst.ks=http://127.0.0.1/cblr/svc/op/autoinstall/system/dom_test My changes got sucesssfully overwritten. $ rm -rf /srv/tftpboot
cobbler sync --systems=dom_test
task started: 2021-05-03_114549_syncsystems
task started (id=Syncsystems, time=Mon May 3 11:45:49 2021)
running python triggers from /var/lib/cobbler/triggers/task/syncsystems/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/syncsystems/pre/*
shell triggers finished successfully
sync_systems
mkdir: /srv/tftpboot/pxelinux.cfg
mkdir: /srv/tftpboot/grub
mkdir: /srv/tftpboot/images
mkdir: /srv/tftpboot/ppc
mkdir: /srv/tftpboot/etc
running pre-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/sync/pre/*
shell triggers finished successfully
generating PXE configuration files
generating: /srv/tftpboot/pxelinux.cfg/01-00-16-3e-0e-ec-13
generating: /srv/tftpboot/grub/system/00:16:3e:0e:ec:13
Got "[Errno 2] No such file or directory: '/srv/tftpboot/grub/system/00:16:3e:0e:ec:13'" while trying to write /srv/tftpboot/grub/system/00:16:3e:0e:ec:13
Trying to write /srv/tftpboot/grub/system/00:16:3e:0e:ec:13 again after some delay.
Exception occurred: <class 'FileNotFoundError'>
Exception value: [Errno 2] No such file or directory: '/srv/tftpboot/grub/system/00:16:3e:0e:ec:13'
Exception Info:
!!! TASK FAILED !!!
$ tree -L 4 tftpboot/
tftpboot/
├── etc
├── grub
│ └── images -> ../images
├── images
├── ppc
└── pxelinux.cfg
└── 01-00-16-3e-0e-ec-13
6 directories, 1 file
The systems sync worked correctly because in this case a full sync has to be done beforehand. After doing a full sync the systems sync works correctly. $ cobbler sync
task started: 2021-05-03_114639_sync
task started (id=Sync, time=Mon May 3 11:46:39 2021)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
syncing all
running pre-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/sync/pre/*
shell triggers finished successfully
cleaning trees
removing: /srv/www/cobbler/images/CentOS-Stream-x86_64
removing: /srv/tftpboot/pxelinux.cfg/01-00-16-3e-0e-ec-13
removing: /srv/tftpboot/grub/images
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/srv/tftpboot']
received on stdout:
received on stderr:
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/srv/tftpboot']
received on stdout:
received on stderr:
copying distros to tftpboot
copying files for distro: CentOS-Stream-x86_64
mkdir: /srv/tftpboot/images/CentOS-Stream-x86_64
trying hardlink /srv/www/cobbler/distro_mirror/CentOS-Stream/images/pxeboot/vmlinuz -> /srv/tftpboot/images/CentOS-Stream-x86_64/vmlinuz
trying hardlink /srv/www/cobbler/distro_mirror/CentOS-Stream/images/pxeboot/initrd.img -> /srv/tftpboot/images/CentOS-Stream-x86_64/initrd.img
copying images
generating PXE configuration files
generating: /srv/tftpboot/pxelinux.cfg/01-00-16-3e-0e-ec-13
generating: /srv/tftpboot/grub/system/00:16:3e:0e:ec:13
generating PXE menu structure
mkdir: /srv/tftpboot/pxelinux.cfg
copying files for distro: CentOS-Stream-x86_64
mkdir: /srv/www/cobbler/images/CentOS-Stream-x86_64
trying hardlink /srv/www/cobbler/distro_mirror/CentOS-Stream/images/pxeboot/vmlinuz -> /srv/www/cobbler/images/CentOS-Stream-x86_64/vmlinuz
trying hardlink /srv/www/cobbler/distro_mirror/CentOS-Stream/images/pxeboot/initrd.img -> /srv/www/cobbler/images/CentOS-Stream-x86_64/initrd.img
Writing template files for CentOS-Stream-x86_64
mkdir: /srv/tftpboot/pxelinux.cfg
processing boot_files for distro: CentOS-Stream-x86_64
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***
$ tree -L 4 tftpboot/
tftpboot/
├── etc
├── grub
│ ├── grub.cfg
│ ├── images -> ../images
│ ├── local_efi.cfg
│ ├── local_legacy.cfg
│ ├── local_powerpc-ieee1275.cfg
│ ├── system
│ │ └── 00:16:3e:0e:ec:13
│ ├── system_link
│ │ └── dom_test -> ../system/00:16:3e:0e:ec:13
│ └── x86_64_menu_items.cfg
├── grub.cfg
├── images
│ └── CentOS-Stream-x86_64
│ ├── initrd.img
│ └── vmlinuz
├── ppc
└── pxelinux.cfg
├── 01-00-16-3e-0e-ec-13
└── default
9 directories, 12 files
$ cobbler sync --systems=dom_test
task started: 2021-05-03_114704_syncsystems
task started (id=Syncsystems, time=Mon May 3 11:47:04 2021)
running python triggers from /var/lib/cobbler/triggers/task/syncsystems/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/syncsystems/pre/*
shell triggers finished successfully
sync_systems
running pre-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/sync/pre/*
shell triggers finished successfully
generating PXE configuration files
generating: /srv/tftpboot/pxelinux.cfg/01-00-16-3e-0e-ec-13
generating: /srv/tftpboot/grub/system/00:16:3e:0e:ec:13
removing: /srv/tftpboot/grub/system_link/dom_test
generating PXE menu structure
mkdir: /srv/tftpboot/pxelinux.cfg
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE *** @cxfcxf Would it be possible for you to to some real life testing with the newly introduced changes? Otherwise I think we are good to go for this PR to be merged. The rest of the unit tests, especially for methods which get called by your introduced changes, will be done in the future in another PR. |
There are two things left to get this merged:
|
@cxfcxf From @SchoolGuy and my perspective this PR should be fine for merging now but we still want to wait for some feedback from you. |
One last thing I will do is a rebase to clean up the git history. |
If managing a vast amount of systems via a single Cobbler instance the amount of time a `cobbler sync` call needs to synchronize everything is quite a lot. @cxfcxf observed that writing PXE configuration files for every system to the tftpboot location takes up to 90% of the time of a `cobbler sync`. So he introduced the option to synchronize only specified systems with `cobbler sync --systems=system1,system2`. This also adds some basic unit tests and unit test skeletons which has to be completet in the future.
PR looks good to me, thanks for point out the additional deserialize() and writing to all the test cases |
i can do as much as you, we are running on cobbler 2.8, i did some test on our test lab, with only the code change i put up here writing in python 2.7 since in production we are still running on python2.7, we would like to upgrade python to 3.x and upgrade cobbler as well, thus the PR, |
Your welcome and thank you very much for your contribution and this PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Waiting for your feedback @SchoolGuy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Problem: if number of systems a single cobbler instance manage gets over couple of thousands, the cobbler sync will take very long time to finish (we usually see a sync takes over 10 mins)
Observation: the process of writing pxe config files for every systems to /tftpboot take 90% of the sync time
Solution: in here, i am trying to introduce an option after regular
cobbler sync
ascobbler sync --systems a.b.c,a.x.c
and API will result a call assync_systems(systems)
, if no--systems
get passed aftercobbler sync
, it will default to run regularcobbler sync
the function/command name can be changed, or we can make it a standalone command with options
please be note that i haven't test PR code
this is just a preliminary idea and code change, if we can agree on this change, i can make up all the piece including unit test