From c865829a2e5d3cf66d88b5d24674ce0771e4c496 Mon Sep 17 00:00:00 2001 From: Florian Paul Azim Hoberg Date: Tue, 13 Aug 2024 16:37:30 +0200 Subject: [PATCH] release: Prepare release v1.0.2 --- ...ion_to_run_only_on_cluster_master_node.yml | 2 +- ...n_run_migration_parallel_or_sequential.yml | 0 .../{1.1.0 => 1.0.2}/45_fix_daemon_timer.yml | 0 .../1.0.2/49_fix_cmake_debian_packaging.yml | 2 + .changelogs/1.0.2/release_meta.yml | 1 + .changelogs/1.1.0/release_meta.yml | 1 - CHANGELOG.md | 16 ++++++- README.md | 5 +- packaging/CMakeLists.txt | 7 ++- packaging/changelog_debian | 10 ++++ packaging/changelog_redhat | 6 +++ packaging/conffiles | 1 + proxlb | 47 +++++++++++++------ 13 files changed, 75 insertions(+), 23 deletions(-) rename .changelogs/{1.1.0 => 1.0.2}/40_add_option_to_run_only_on_cluster_master_node.yml (64%) rename .changelogs/{1.1.0 => 1.0.2}/41_add_option_run_migration_parallel_or_sequential.yml (100%) rename .changelogs/{1.1.0 => 1.0.2}/45_fix_daemon_timer.yml (100%) create mode 100644 .changelogs/1.0.2/49_fix_cmake_debian_packaging.yml create mode 100644 .changelogs/1.0.2/release_meta.yml delete mode 100644 .changelogs/1.1.0/release_meta.yml create mode 100644 packaging/conffiles diff --git a/.changelogs/1.1.0/40_add_option_to_run_only_on_cluster_master_node.yml b/.changelogs/1.0.2/40_add_option_to_run_only_on_cluster_master_node.yml similarity index 64% rename from .changelogs/1.1.0/40_add_option_to_run_only_on_cluster_master_node.yml rename to .changelogs/1.0.2/40_add_option_to_run_only_on_cluster_master_node.yml index 4320350..e232c26 100644 --- a/.changelogs/1.1.0/40_add_option_to_run_only_on_cluster_master_node.yml +++ b/.changelogs/1.0.2/40_add_option_to_run_only_on_cluster_master_node.yml @@ -1,2 +1,2 @@ added: - - Add option to run ProxLB only on the Proxmox's master node in the cluster. [40] + - Add option to run ProxLB only on the Proxmox's master node in the cluster (reg. HA feature). [#40] diff --git a/.changelogs/1.1.0/41_add_option_run_migration_parallel_or_sequential.yml b/.changelogs/1.0.2/41_add_option_run_migration_parallel_or_sequential.yml similarity index 100% rename from .changelogs/1.1.0/41_add_option_run_migration_parallel_or_sequential.yml rename to .changelogs/1.0.2/41_add_option_run_migration_parallel_or_sequential.yml diff --git a/.changelogs/1.1.0/45_fix_daemon_timer.yml b/.changelogs/1.0.2/45_fix_daemon_timer.yml similarity index 100% rename from .changelogs/1.1.0/45_fix_daemon_timer.yml rename to .changelogs/1.0.2/45_fix_daemon_timer.yml diff --git a/.changelogs/1.0.2/49_fix_cmake_debian_packaging.yml b/.changelogs/1.0.2/49_fix_cmake_debian_packaging.yml new file mode 100644 index 0000000..658a7c0 --- /dev/null +++ b/.changelogs/1.0.2/49_fix_cmake_debian_packaging.yml @@ -0,0 +1,2 @@ +fixed: + - Fix CMake packaging for Debian package to avoid overwriting the config file. [#49] diff --git a/.changelogs/1.0.2/release_meta.yml b/.changelogs/1.0.2/release_meta.yml new file mode 100644 index 0000000..da358bc --- /dev/null +++ b/.changelogs/1.0.2/release_meta.yml @@ -0,0 +1 @@ +date: 2024-08-13 diff --git a/.changelogs/1.1.0/release_meta.yml b/.changelogs/1.1.0/release_meta.yml deleted file mode 100644 index c19765d..0000000 --- a/.changelogs/1.1.0/release_meta.yml +++ /dev/null @@ -1 +0,0 @@ -date: TBD diff --git a/CHANGELOG.md b/CHANGELOG.md index ea31878..015ab0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.2] - 2024-08-13 + +### Added + +- Add option to run migration in parallel or sequentially. [#41] +- Add option to run ProxLB only on the Proxmox's master node in the cluster (reg. HA feature). [#40] + +### Changed + +- Fix daemon timer to use hours instead of minutes. [#45] +- Fix CMake packaging for Debian package to avoid overwriting the config file. [#49] +- Fix wonkey code style. + + ## [1.0.0] - 2024-08-01 ### Added @@ -37,4 +51,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Development release of ProxLB. \ No newline at end of file +- Development release of ProxLB. diff --git a/README.md b/README.md index 0dbf341..c04da48 100644 --- a/README.md +++ b/README.md @@ -210,8 +210,8 @@ The executable must be able to read the config file, if no dedicated config file The easiest way to get started is by using the ready-to-use packages that I provide on my CDN and to run it on a Linux Debian based system. This can also be one of the Proxmox nodes itself. ``` -wget https://cdn.gyptazy.ch/files/amd64/debian/proxlb/proxlb_1.0.0_amd64.deb -dpkg -i proxlb_1.0.0_amd64.deb +wget https://cdn.gyptazy.ch/files/amd64/debian/proxlb/proxlb_1.0.2_amd64.deb +dpkg -i proxlb_1.0.2_amd64.deb # Adjust your config vi /etc/proxlb/proxlb.conf systemctl restart proxlb @@ -303,6 +303,7 @@ Container Images for Podman, Docker etc., can be found at: | Version | Image | |------|:------:| | latest | cr.gyptazy.ch/proxlb/proxlb:latest | +| v1.0.2 | cr.gyptazy.ch/proxlb/proxlb:v1.0.2 | | v1.0.0 | cr.gyptazy.ch/proxlb/proxlb:v1.0.0 | | v0.9.9 | cr.gyptazy.ch/proxlb/proxlb:v0.9.9 | diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 6376ebb..95d47fc 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(proxmox-rebalancing-service VERSION 1.0.0) +project(proxmox-rebalancing-service VERSION 1.0.2) install(PROGRAMS ../proxlb DESTINATION /bin) install(FILES ../proxlb.conf DESTINATION /etc/proxlb) @@ -30,12 +30,11 @@ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") set(CPACK_DEBIAN_PACKAGE_SUMMARY "ProxLB - Rebalance VM workloads across nodes in Proxmox clusters.") set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "ProxLB - Rebalance VM workloads across nodes in Proxmox clusters.") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/changelog_debian") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3, python3-proxmoxer") set(CPACK_DEBIAN_PACKAGE_LICENSE "GPL 3.0") - # Install set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst") +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst;${CMAKE_CURRENT_SOURCE_DIR}/conffiles") set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/postinst") include(CPack) diff --git a/packaging/changelog_debian b/packaging/changelog_debian index 84a77fe..d0d9406 100644 --- a/packaging/changelog_debian +++ b/packaging/changelog_debian @@ -1,3 +1,13 @@ +proxlb (1.0.2) unstable; urgency=low + + * Add option to run migration in parallel or sequentially. + * Add option to run ProxLB only on a Proxmox cluster master (req. HA feature). + * Fix daemon timer to use hours instead of minutes. + * Fix CMake packaging for Debian package to avoid overwriting the config file. + * Fix some wonkey code styles. + + -- Florian Paul Azim Hoberg Tue, 13 Aug 2024 17:28:14 +0200 + proxlb (1.0.0) unstable; urgency=low * Initial release of ProxLB. diff --git a/packaging/changelog_redhat b/packaging/changelog_redhat index 76444c2..550ff60 100644 --- a/packaging/changelog_redhat +++ b/packaging/changelog_redhat @@ -1,3 +1,9 @@ +* Tue Aug 13 2024 Florian Paul Azim Hoberg +- Add option to run migration in parallel or sequentially. +- Add option to run ProxLB only on a Proxmox cluster master (req. HA feature). +- Fixed daemon timer to use hours instead of minutes. +- Fixed some wonkey code styles. + * Thu Aug 01 2024 Florian Paul Azim Hoberg - Initial release of ProxLB. diff --git a/packaging/conffiles b/packaging/conffiles new file mode 100644 index 0000000..800e6dc --- /dev/null +++ b/packaging/conffiles @@ -0,0 +1 @@ +/etc/proxlb/proxlb.conf diff --git a/proxlb b/proxlb index fb92547..85a1fad 100755 --- a/proxlb +++ b/proxlb @@ -41,7 +41,7 @@ import urllib3 # Constants __appname__ = "ProxLB" -__version__ = "1.1.0b" +__version__ = "1.0.2" __author__ = "Florian Paul Azim Hoberg @gyptazy" __errors__ = False @@ -146,7 +146,7 @@ def __validate_config_file(config_path): def initialize_args(): """ Initialize given arguments for ProxLB. """ argparser = argparse.ArgumentParser(description='ProxLB') - argparser.add_argument('-c', '--config', type=str, help='Path to config file.', required=True) + argparser.add_argument('-c', '--config', type=str, help='Path to config file.', required=False) argparser.add_argument('-d', '--dry-run', help='Perform a dry-run without doing any actions.', action='store_true', required=False) argparser.add_argument('-j', '--json', help='Return a JSON of the VM movement.', action='store_true', required=False) return argparser.parse_args() @@ -234,15 +234,29 @@ def api_connect(proxmox_api_host, proxmox_api_user, proxmox_api_pass, proxmox_ap return api_object +def execute_rebalancing_only_by_master(api_object, master_only): + """ Validate if balancing should only be done by the cluster master. Afterwards, validate if this node is the cluster master. """ + info_prefix = 'Info: [only-on-master-executor]:' + master_only = bool(int(master_only)) + + if bool(int(master_only)): + logging.info(f'{info_prefix} Master only rebalancing is defined. Starting validation.') + cluster_master_node = get_cluster_master(api_object) + cluster_master = validate_cluster_master(cluster_master_node) + return cluster_master, master_only + else: + logging.info(f'{info_prefix} No master only rebalancing is defined. Skipping validation.') + return False, master_only + + def get_cluster_master(api_object): """ Get the current master of the Proxmox cluster. """ error_prefix = 'Error: [cluster-master-getter]:' info_prefix = 'Info: [cluster-master-getter]:' - logging.info(f'{info_prefix} Getting master node from cluster.') try: ha_status_object = api_object.cluster().ha().status().manager_status().get() - logging.info(f'{info_prefix} Master node: {ha_status_object["manager_status"]["master_node"]}') + logging.info(f'{info_prefix} Master node: {ha_status_object.get("manager_status", None).get("master_node", None)}') except urllib3.exceptions.NameResolutionError: logging.critical(f'{error_prefix} Could not resolve the API.') sys.exit(2) @@ -253,7 +267,13 @@ def get_cluster_master(api_object): logging.critical(f'{error_prefix} SSL certificate verification failed for API.') sys.exit(2) - return ha_status_object['manager_status']['master_node'] + cluster_master = ha_status_object.get("manager_status", None).get("master_node", None) + + if cluster_master: + return cluster_master + else: + logging.critical(f'{error_prefix} Could not obtain cluster master. Please check your configuration - stopping.') + sys.exit(2) def validate_cluster_master(cluster_master): @@ -522,7 +542,7 @@ def balancing_calculations(balancing_method, balancing_mode, balancing_mode_opti def __validate_balancing_method(balancing_method): """ Validate for valid and supported balancing method. """ error_prefix = 'Error: [balancing-method-validation]:' - info_prefix = 'Info: [balancing-method-validation]]:' + info_prefix = 'Info: [balancing-method-validation]:' if balancing_method not in ['memory', 'disk', 'cpu']: logging.error(f'{error_prefix} Invalid balancing method: {balancing_method}') @@ -534,7 +554,7 @@ def __validate_balancing_method(balancing_method): def __validate_balancing_mode(balancing_mode): """ Validate for valid and supported balancing mode. """ error_prefix = 'Error: [balancing-mode-validation]:' - info_prefix = 'Info: [balancing-mode-validation]]:' + info_prefix = 'Info: [balancing-mode-validation]:' if balancing_mode not in ['used', 'assigned']: logging.error(f'{error_prefix} Invalid balancing method: {balancing_mode}') @@ -883,13 +903,12 @@ def main(): # Get master node of cluster and ensure that ProxLB is only performed on the # cluster master node to avoid ongoing rebalancing. - if bool(int(master_only)): - cluster_master_node = get_cluster_master(api_object) - cluster_master = validate_cluster_master(cluster_master_node) - # Validate daemon service and skip following tasks when not being the cluster master. - if not cluster_master: - validate_daemon(daemon, schedule) - continue + cluster_master, master_only = execute_rebalancing_only_by_master(api_object, master_only) + + # Validate daemon service and skip following tasks when not being the cluster master. + if not cluster_master and master_only: + validate_daemon(daemon, schedule) + continue # Get metric & statistics for vms and nodes. node_statistics = get_node_statistics(api_object, ignore_nodes)