Skip to content

Commit

Permalink
Merge branch 'master' into feat-support-cos
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchiu authored Apr 3, 2024
2 parents 650fded + fefc991 commit d522f7e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion e2e/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ directio==1.3
flake8
kubernetes==27.2.0
requests==2.31.0
boto3==1.34.71
boto3==1.34.73
pyyaml==6.0.1
4 changes: 4 additions & 0 deletions manager/integration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@

HOST_PROC_DIR = "/host/proc"

BACKUP_TARGET_MESSAGE_EMPTY_URL = "backup target URL is empty"
BACKUP_TARGET_MESSAGES_INVALID = ["failed to init backup target clients",
"failed to list backup volumes in"]

# customize the timeout for HDD
disktype = os.environ.get('LONGHORN_DISK_TYPE')
if disktype == "hdd":
Expand Down
15 changes: 15 additions & 0 deletions manager/integration/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
from common import get_custom_object_api_client
from common import RETRY_COUNTS_SHORT
from common import scale_up_engine_image_daemonset
from common import BACKUP_TARGET_MESSAGE_EMPTY_URL
from common import BACKUP_TARGET_MESSAGES_INVALID

from backupstore import backupstore_delete_volume_cfg_file
from backupstore import backupstore_cleanup
Expand Down Expand Up @@ -5666,6 +5668,7 @@ def test_backuptarget_invalid(apps_api, # NOQA
Then
- Backup will be failed and the backup state is Error.
- Backup target will be unavailable with an explanatory condition.
"""
volume = create_and_check_volume(client, volume_name)
pvc_name = volume_name + "-pvc"
Expand Down Expand Up @@ -5698,6 +5701,18 @@ def test_backuptarget_invalid(apps_api, # NOQA
assert backups["items"][0]["spec"]["snapshotName"] == snap.name
assert backups["items"][0]["status"]["state"] == "Error"

# In https://github.com/longhorn/longhorn/issues/8210, the backup target
# could not properly reconcile when the URL or secret were "broken", and
# the condition/message was not updated. Verify the condition/message is
# correct under these conditions.
backup_targets = client.list_backup_target()
assert not backup_targets[0]["available"]
# If the condition/message was not updated, it is likely still this one.
assert backup_targets[0]["message"] != BACKUP_TARGET_MESSAGE_EMPTY_URL
# Depending on the exact nature of the failure, we expect one of these
# strings to be in the condition/message.
assert any(message in backup_targets[0]["message"] for message in
BACKUP_TARGET_MESSAGES_INVALID)

@pytest.mark.volume_backup_restore # NOQA
def test_volume_backup_and_restore_with_lz4_compression_method(client, set_random_backupstore, volume_name): # NOQA
Expand Down
11 changes: 7 additions & 4 deletions pipelines/utilities/longhorn_rancher_chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ install_rancher() {


get_rancher_api_key() {
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
while [[ -z "${TOKEN}" ]]; do
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
sleep 3s
done
}


Expand Down
11 changes: 7 additions & 4 deletions test_framework/scripts/longhorn-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ install_rancher() {


get_rancher_api_key() {
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
while [[ -z "${TOKEN}" ]]; do
TOKEN=$(curl -X POST -s -k "https://${RANCHER_HOSTNAME}/v3-public/localproviders/local?action=login" -H 'Content-Type: application/json' -d "{\"username\":\"admin\", \"password\":\"${RANCHER_BOOTSTRAP_PASSWORD}\", \"responseType\": \"json\"}" | jq -r '.token' | tr -d '"')
ARR=(${TOKEN//:/ })
RANCHER_ACCESS_KEY=${ARR[0]}
RANCHER_SECRET_KEY=${ARR[1]}
sleep 3s
done
}


Expand Down

0 comments on commit d522f7e

Please sign in to comment.