Skip to content

Commit

Permalink
fix: attach volumes to eliminate duplicated replicas
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 8573

Signed-off-by: Jack Lin <jack.lin@suse.com>
  • Loading branch information
ChanYiLin committed Sep 19, 2024
1 parent 22d28e6 commit dc15f56
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ esac
echo "Building for ${ARCH}"
# update base image to get latest changes
BASE_IMAGE=`grep FROM package/Dockerfile | awk '{print $2}'`
docker pull ${BASE_IMAGE}
sudo docker pull ${BASE_IMAGE}

docker build --build-arg TARGETPLATFORM="linux/${ARCH}" -t ${image} -f manager/integration/Dockerfile .
sudo docker build --build-arg TARGETPLATFORM="linux/${ARCH}" -t ${image} -f manager/integration/Dockerfile .
mkdir -p bin
echo ${image} > bin/latest_image
echo Built image ${image}
11 changes: 11 additions & 0 deletions manager/integration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6494,3 +6494,14 @@ def check_backing_image_eviction_failed(name): # NOQA
time.sleep(RETRY_INTERVAL)

assert check


def wait_for_replica_count(client, volume_name, replica_count):
for i in range(RETRY_COUNTS):
volume = client.by_id_volume(volume_name)
if len(volume.replicas) == replica_count:
break
time.sleep(RETRY_INTERVAL)

volume = client.by_id_volume(volume_name)
assert volume.replicaCount == replica_count
25 changes: 20 additions & 5 deletions manager/integration/tests/test_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
from common import wait_scheduling_failure
from common import set_tags_for_node_and_its_disks
from common import wait_for_tainted_node_engine_image_undeployed
from common import wait_for_replica_count

from backupstore import set_random_backupstore # NOQA
from backupstore import backupstore_cleanup
Expand Down Expand Up @@ -2877,11 +2878,13 @@ def test_engine_image_not_fully_deployed_perform_auto_upgrade_engine(client, cor
tainted node and not fully deployed engine.
1. Create 2 volumes vol-1 and vol-2 with 2 replicas
2. Deploy a new engine image, new-ei
3. Upgrade vol-1 and vol-2 to the new-ei
4. Attach vol-2 to current-node
5. Set `Concurrent Automatic Engine Upgrade Per Node Limit` setting to 3
6. In a 2-min retry, verify that Longhorn upgrades the engine image of
2. Attach both volumes to make sure they are healthy and have 2 replicas
4. Detach both volumes
5. Deploy a new engine image, new-ei
6. Upgrade vol-1 and vol-2 to the new-ei
7. Attach vol-2 to current-node
8. Set `Concurrent Automatic Engine Upgrade Per Node Limit` setting to 3
9. In a 2-min retry, verify that Longhorn upgrades the engine image of
vol-1 and vol-2.
"""
tainted_node_id = \
Expand All @@ -2895,6 +2898,18 @@ def test_engine_image_not_fully_deployed_perform_auto_upgrade_engine(client, cor
num_of_replicas=2,
size=str(3 * Gi))

volume1.attach(hostId=get_self_host_id())
volume2.attach(hostId=get_self_host_id())
volume1 = wait_for_volume_healthy(client, volume1.name)
volume2 = wait_for_volume_healthy(client, volume2.name)
wait_for_replica_count(client, volume1.name, 2)
wait_for_replica_count(client, volume2.name, 2)

volume1.detach()
volume2.detach()
volume1 = wait_for_volume_detached(client, volume1.name)
volume2 = wait_for_volume_detached(client, volume2.name)

default_img = common.get_default_engine_image(client)
# engine reference =
# (1 volume + 1 engine + number of replicas) * volume count
Expand Down

0 comments on commit dc15f56

Please sign in to comment.