Skip to content

Commit

Permalink
Fix node/allocate-ports regression (#747)
Browse files Browse the repository at this point in the history
* Fix node/allocate-ports regression

The core cannot allocate the additional TCP port for Rsync during NS7
migration.

* Bypass port allocation check with cluster agent
  • Loading branch information
DavidePrincipi authored Nov 7, 2024
1 parent f380522 commit dbdb519
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ if module_env != "" and module_env != f"module/{request['module_id']}":
# Connect to Redis without privileged access
rdb = agent.redis_connect(privileged=False)

# Get the current node ID and the module's node ID
current_node_id = os.getenv("NODE_ID")
module_node_id = rdb.hget('cluster/module_node', request['module_id'])

# Verify that the module exists
agent.assert_exp(module_node_id not in [None, ''], f"Error: Module {request['module_id']} does not exist.")

# Verify that the module is present on the current node
agent.assert_exp(module_node_id == current_node_id, f"Error: Module {request['module_id']} is not located on the current node {current_node_id}.")

# Get the ports demand based on the protocol
if request['protocol'] == 'tcp':
ports_demand = int(rdb.hget('cluster/tcp_ports_demand', request["module_id"]) or "0")
Expand All @@ -53,7 +43,7 @@ else:
ports_used = 0 + request['ports']

# Check if the total required ports exceed the allowed number of ports
if ports_used > ports_demand:
if module_env != "" and ports_used > ports_demand:
print(agent.SD_ERR + f"Cannot allocate {ports_used} {request['protocol']} ports to {request['module_id']}. Max allowed is {ports_demand}.", file=sys.stderr)
agent.set_status('validation-failed')
json.dump([{'field':'ports', 'parameter':'ports', 'value': request['ports'], 'error':'max_ports_exceeded'}], fp=sys.stdout)
Expand Down

0 comments on commit dbdb519

Please sign in to comment.