Skip to content

Commit

Permalink
Fix deployment with ipv6 management network
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansnell committed Jan 9, 2025
1 parent c6bc2f7 commit 1a31af5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sunbeam-python/sunbeam/provider/local/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import ipaddress
import logging

import petname # type: ignore [import-untyped]
Expand Down Expand Up @@ -154,6 +155,8 @@ def get_management_cidr(self) -> str:
def get_clusterd_http_address(self) -> str:
"""Return the address of the clusterd server."""
local_ip = utils.get_local_ip_by_cidr(self.get_management_cidr())
if ipaddress.ip_address(local_ip).version == 6:
local_ip = f"[{local_ip}]"
address = f"https://{local_ip}:{CLUSTERD_PORT}"
return address

Expand Down
10 changes: 10 additions & 0 deletions sunbeam-python/tests/unit/sunbeam/test_clusterd.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ def test_init_step(self, cclient, mocker):
assert result.result_type == ResultType.COMPLETED
init_step.client.cluster.bootstrap.assert_called_once()

def test_init_step_ipv6(self, cclient, mocker):
role = "control"
init_step = ClusterInitStep(cclient, [role], 0, "fd00::/108")
init_step.client = MagicMock()
init_step.fqdn = "node1"
mocker.patch("sunbeam.utils.get_local_ip_by_cidr", return_value="fd00::2")
result = init_step.run()
assert result.result_type == ResultType.COMPLETED
init_step.client.cluster.bootstrap.assert_called_once()

def test_add_node_step(self, cclient):
add_node_step = ClusterAddNodeStep(cclient, name="node-1")
add_node_step.client = MagicMock()
Expand Down

0 comments on commit 1a31af5

Please sign in to comment.