Skip to content

Commit 03e92fa

Browse files
authored
migrate from longhorn to openebs, then upgrade k8s past 1.24 (#4729)
* migrate from longhorn to openebs, then upgrade k8s past 1.24 * report this independently * timing * podstatus? * all tests
1 parent 2603b87 commit 03e92fa

File tree

3 files changed

+114
-14
lines changed

3 files changed

+114
-14
lines changed

addons/openebs/3.7.0/install.sh

+15-5
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,21 @@ function openebs_prompt_migrate_from_longhorn() {
410410

411411
semverParse "$KUBERNETES_VERSION"
412412
if [ "$minor" -gt 24 ] ; then
413-
logFail " It appears that the Kubernetes version you are attempting to install ($KUBERNETES_VERSION) is incompatible with the version of Longhorn currently installed"
414-
logFail " on your cluster. As a result, it is not possible to migrate data from Longhorn to OpenEBS. To successfully migrate data, please choose a Kubernetes"
415-
logFail " version that is compatible with the version of Longhorn running on your cluster (note: Longhorn is compatible with Kubernetes versions up to and"
416-
logFail " including 1.24)."
417-
bail "Not migrating"
413+
logWarn ""
414+
logWarn " It appears that the Kubernetes version you are attempting to install ($KUBERNETES_VERSION) is incompatible with the version of Longhorn currently installed"
415+
logWarn " on your cluster. Because of this, we will install OpenEBS and migrate your data from Longhorn before upgrading Kubernetes."
416+
417+
log "Would you like to continue? "
418+
if ! confirmN; then
419+
bail "Not migrating"
420+
fi
421+
422+
longhorn_prepare_for_migration
423+
report_addon_start "openebs-preinstall" "$OPENEBS_VERSION"
424+
addon_install "openebs" "$OPENEBS_VERSION"
425+
report_addon_success "openebs-preinstall" "$OPENEBS_VERSION"
426+
maybe_cleanup_longhorn
427+
return
418428
fi
419429

420430
log "Would you like to continue? "

addons/openebs/template/base/install.sh

+15-5
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,21 @@ function openebs_prompt_migrate_from_longhorn() {
410410

411411
semverParse "$KUBERNETES_VERSION"
412412
if [ "$minor" -gt 24 ] ; then
413-
logFail " It appears that the Kubernetes version you are attempting to install ($KUBERNETES_VERSION) is incompatible with the version of Longhorn currently installed"
414-
logFail " on your cluster. As a result, it is not possible to migrate data from Longhorn to OpenEBS. To successfully migrate data, please choose a Kubernetes"
415-
logFail " version that is compatible with the version of Longhorn running on your cluster (note: Longhorn is compatible with Kubernetes versions up to and"
416-
logFail " including 1.24)."
417-
bail "Not migrating"
413+
logWarn ""
414+
logWarn " It appears that the Kubernetes version you are attempting to install ($KUBERNETES_VERSION) is incompatible with the version of Longhorn currently installed"
415+
logWarn " on your cluster. Because of this, we will install OpenEBS and migrate your data from Longhorn before upgrading Kubernetes."
416+
417+
log "Would you like to continue? "
418+
if ! confirmN; then
419+
bail "Not migrating"
420+
fi
421+
422+
longhorn_prepare_for_migration
423+
report_addon_start "openebs-preinstall" "$OPENEBS_VERSION"
424+
addon_install "openebs" "$OPENEBS_VERSION"
425+
report_addon_success "openebs-preinstall" "$OPENEBS_VERSION"
426+
maybe_cleanup_longhorn
427+
return
418428
fi
419429

420430
log "Would you like to continue? "

addons/openebs/template/testgrid/k8s-docker-localpv.yaml

+84-4
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
echo "Verify if rook-ceph namespace was removed after upgrade"
179179
if kubectl get namespace/rook-ceph ; then
180180
echo "Namespace rook-ceph was not removed"
181-
exit 1
181+
exit 1
182182
else
183183
echo "Namespace rook-ceph was removed"
184184
fi
@@ -187,7 +187,7 @@
187187
flags: "yes"
188188
installerSpec:
189189
kubernetes:
190-
version: "1.24.x"
190+
version: "1.24.x"
191191
flannel:
192192
version: latest
193193
containerd:
@@ -223,11 +223,11 @@
223223
source /opt/kurl-testgrid/testhelpers.sh
224224
minio_object_store_info
225225
validate_testfile rwtest testfile.txt
226-
validate_read_write_object_store postupgrade upgradefile.txt
226+
validate_read_write_object_store postupgrade upgradefile.txt
227227
echo "Verify if rook-ceph namespace was removed after upgrade"
228228
if kubectl get namespace/rook-ceph ; then
229229
echo "Namespace rook-ceph was not removed"
230-
exit 1
230+
exit 1
231231
else
232232
echo "Namespace rook-ceph was removed"
233233
fi
@@ -291,6 +291,12 @@
291291
# pulls the image we pushed before the migration.
292292
test_pull_image_from_registry
293293
294+
# ensure that longhorn has been removed
295+
if kubectl get ns | grep -q longhorn-system; then
296+
echo "longhorn-system namespace still exists"
297+
exit 1
298+
fi
299+
294300
- name: localpv upgrade from latest
295301
flags: "yes"
296302
installerSpec:
@@ -333,3 +339,77 @@
333339
minio_object_store_info
334340
validate_testfile rwtest testfile.txt
335341
validate_read_write_object_store postupgrade upgradefile.txt
342+
343+
344+
- name: localpv migrate from longhorn with kubernetes upgrade
345+
flags: "yes"
346+
installerSpec:
347+
kubernetes:
348+
version: "1.24.9"
349+
flannel:
350+
version: "latest"
351+
containerd:
352+
version: "latest"
353+
ekco:
354+
version: "latest"
355+
prometheus:
356+
version: "0.60.1-41.7.3"
357+
minio:
358+
version: "latest"
359+
registry:
360+
version: "2.8.1"
361+
longhorn:
362+
version: "1.3.1"
363+
upgradeSpec:
364+
kubernetes:
365+
version: "1.25.x"
366+
flannel:
367+
version: "latest"
368+
containerd:
369+
version: "latest"
370+
ekco:
371+
version: "latest"
372+
prometheus:
373+
version: "0.60.1-41.7.3"
374+
minio:
375+
version: "latest"
376+
registry:
377+
version: "2.8.1"
378+
openebs:
379+
isLocalPVEnabled: true
380+
localPVStorageClassName: openebs
381+
namespace: openebs
382+
version: "__testver__"
383+
s3Override: "__testdist__"
384+
postInstallScript: |
385+
source /opt/kurl-testgrid/testhelpers.sh
386+
# create a deployment using the longhorn storage class ("default" namespace).
387+
create_deployment_with_mounted_volume "migration-test" "default" "/data"
388+
# generate a random file and copies it to the pod deployed by the previously created deployment.
389+
create_random_file_and_upload_to_deployment "migration-test" "default" "./test.data" "/data/test.data"
390+
# pushes an image to the internal registry.
391+
test_push_image_to_registry
392+
393+
sleep 60
394+
kubectl get pods -A
395+
kubectl get pod -n kurl -o jsonpath='{.status.reason}'
396+
postUpgradeScript: |
397+
source /opt/kurl-testgrid/testhelpers.sh
398+
# sleep for a while to guarantee that the pod has been scaled up.
399+
sleep 120
400+
# downloads the previously stored file and compares, expecting to see the same content.
401+
download_file_from_deployment_and_compare "migration-test" "default" "./test.data" "/data/test.data"
402+
# makes sure that the new pvc is being provisioned by openebs.
403+
pvc_uses_provisioner "migration-test" "default" "openebs"
404+
# pulls the image we pushed before the migration.
405+
test_pull_image_from_registry
406+
407+
# ensure that kubernetes has upgraded
408+
k8sVersion=$(kubectl get nodes -o jsonpath='{.items[0].status.nodeInfo.kubeletVersion}')
409+
echo $k8sVersion | grep 1.25
410+
411+
# ensure that longhorn has been removed
412+
if kubectl get ns | grep -q longhorn-system; then
413+
echo "longhorn-system namespace still exists"
414+
exit 1
415+
fi

0 commit comments

Comments
 (0)