Skip to content

Commit

Permalink
Merge pull request #50 from gyptazy/release/v1.0.2
Browse files Browse the repository at this point in the history
release: Prepare release v1.0.2
  • Loading branch information
gyptazy authored Aug 13, 2024
2 parents 101855b + c865829 commit 143135f
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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]
File renamed without changes.
2 changes: 2 additions & 0 deletions .changelogs/1.0.2/49_fix_cmake_debian_packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fixed:
- Fix CMake packaging for Debian package to avoid overwriting the config file. [#49]
1 change: 1 addition & 0 deletions .changelogs/1.0.2/release_meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
date: 2024-08-13
1 change: 0 additions & 1 deletion .changelogs/1.1.0/release_meta.yml

This file was deleted.

16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 |

Expand Down
7 changes: 3 additions & 4 deletions packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
10 changes: 10 additions & 0 deletions packaging/changelog_debian
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> Tue, 13 Aug 2024 17:28:14 +0200

proxlb (1.0.0) unstable; urgency=low

* Initial release of ProxLB.
Expand Down
6 changes: 6 additions & 0 deletions packaging/changelog_redhat
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* Tue Aug 13 2024 Florian Paul Azim Hoberg <[email protected]>
- 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 <[email protected]>
- Initial release of ProxLB.

Expand Down
1 change: 1 addition & 0 deletions packaging/conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/proxlb/proxlb.conf
47 changes: 33 additions & 14 deletions proxlb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import urllib3

# Constants
__appname__ = "ProxLB"
__version__ = "1.1.0b"
__version__ = "1.0.2"
__author__ = "Florian Paul Azim Hoberg <[email protected]> @gyptazy"
__errors__ = False

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down Expand Up @@ -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}')
Expand All @@ -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}')
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 143135f

Please sign in to comment.