Skip to content

Commit

Permalink
Set up juju HA when number of machines is odd and > 2
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattrees committed Jul 3, 2024
1 parent 785405c commit 49c011e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion anvil-python/anvil/provider/local/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import asyncio
import logging
from pathlib import Path
from typing import List
Expand Down Expand Up @@ -44,6 +44,7 @@
RegisterJujuUserStep,
RemoveJujuMachineStep,
SaveJujuUserLocallyStep,
ScaleJujuStep,
)
from sunbeam.jobs.checks import (
JujuSnapCheck,
Expand Down Expand Up @@ -448,6 +449,19 @@ def join(
)

run_plan(plan2, console)
machines = asyncio.run(
jhelper.get_machines(deployment.infrastructure_model)
)
n_machines = len(machines)
LOG.debug(f"Juju machines: {machines}")
if n_machines > 2 and n_machines % 2 == 1:
plan2.append(
ScaleJujuStep(
controller,
n_machines,
["--to", ",".join([str(x) for x in n_machines.keys()])],
)
)

click.echo(f"Node joined cluster with roles: {pretty_roles}")

Expand Down

0 comments on commit 49c011e

Please sign in to comment.