mirror of
https://github.com/gyptazy/ProxLB.git
synced 2026-04-06 04:41:58 +02:00
Compare commits
2 Commits
feature/39
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
143135f1d8 | ||
|
|
c865829a2e |
@@ -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]
|
||||
2
.changelogs/1.0.2/49_fix_cmake_debian_packaging.yml
Normal file
2
.changelogs/1.0.2/49_fix_cmake_debian_packaging.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix CMake packaging for Debian package to avoid overwriting the config file. [#49]
|
||||
1
.changelogs/1.0.2/release_meta.yml
Normal file
1
.changelogs/1.0.2/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: 2024-08-13
|
||||
@@ -1 +0,0 @@
|
||||
date: TBD
|
||||
16
CHANGELOG.md
16
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.
|
||||
- Development release of ProxLB.
|
||||
|
||||
@@ -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 |
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 <gyptazy@gyptazy.ch> Tue, 13 Aug 2024 17:28:14 +0200
|
||||
|
||||
proxlb (1.0.0) unstable; urgency=low
|
||||
|
||||
* Initial release of ProxLB.
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
* Tue Aug 13 2024 Florian Paul Azim Hoberg <gyptazy@gyptazy.ch>
|
||||
- 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 <gyptazy@gyptazy.ch>
|
||||
- Initial release of ProxLB.
|
||||
|
||||
|
||||
1
packaging/conffiles
Normal file
1
packaging/conffiles
Normal file
@@ -0,0 +1 @@
|
||||
/etc/proxlb/proxlb.conf
|
||||
47
proxlb
47
proxlb
@@ -41,7 +41,7 @@ import urllib3
|
||||
|
||||
# Constants
|
||||
__appname__ = "ProxLB"
|
||||
__version__ = "1.1.0b"
|
||||
__version__ = "1.0.2"
|
||||
__author__ = "Florian Paul Azim Hoberg <gyptazy@gyptazy.ch> @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)
|
||||
|
||||
Reference in New Issue
Block a user