Skip to content

[patch] Delete and recreate config-pvc when storage class changes on upgrade - #468

Merged
whitfiea merged 12 commits into
stablefrom
mascore-15959
Aug 21, 2026
Merged

whitfiea merged 12 commits into
stablefrom
mascore-15959

Conversation

@Jeel-Oza

Copy link
Copy Markdown
Contributor

Problem

When mas upgrade runs and a config-pvc already exists in the pipelines namespace (created during a previous installation) with a different storageClassName than what the upgrade detects, preparePipelinesNamespace()
called applyResource() which attempted to patch the existing PVC with the new storage class. Kubernetes rejects this with a 422 Unprocessable Entity error because storageClassName is an immutable field on a PVC — it cannot be changed after creation. This caused the upgrade pipeline to never launch.

Root Cause

In python-devops/src/mas/devops/tekton.py, preparePipelinesNamespace() blindly called applyResource() without first checking whether the existing config-pvc had a different storage class. When the storage class differed, the patch hit the Kubernetes immutability constraint and failed hard, blocking the entire upgrade.

Solution

Before calling applyResource() to create the config-pvc, the storage class of any existing PVC is now compared against the detected storage class:

  • Same storage class → PVC is already correct, skip delete and recreate entirely
  • Different storage class → force-delete the PVC and recreate with the correct one

The force-delete handles the PVC regardless of its current state (Bound, Lost, or Terminating) by applying all unblocking steps each iteration:

  1. Clear PV claimRef — sets all claimRef fields to empty strings (not nullnull is ignored when the PVC already has a deletionTimestamp). This moves the PVC from BoundLost, causing PVCProtectionController to drop the pvc-protection finalizer voluntarily.
  2. Clear PV finalizers — unblocks the PV if it is itself stuck Terminating.
  3. Clear PVC finalizer and issue delete — safe once the PVC is no longer Bound.

The loop retries up to 30 times until the PVC is confirmed gone. The orphaned PV is also deleted afterwards to prevent accumulation across upgrades.

Files Changed

Repo File Change
python-devops src/mas/devops/tekton.py Storage class check + force-delete logic before PVC recreate

Testing

Verified on a fyre cluster upgrading MAS 9.0.x9.1.x with config-pvc bound to ocs-storagecluster-cephfs and upgrade detecting nfs-client as the default storage class. Pipeline previously failed at Preparing namespace with a 422 error. With this fix, config-pvc was deleted and recreated with the correct storage class and the upgrade pipeline launched successfully.

Acceptance Criteria

  • mas upgrade launches the pipeline without error when config-pvc exists with a different storage class than the detected default
  • config-pvc is not deleted when the storage class already matches
  • config-pvc is recreated with the correct storage class when it differs
  • Orphaned PV is cleaned up after deletion
  • No regression on first-time installs where config-pvc does not yet exist
Screenshot 2026-08-20 at 11 11 31 AM Screenshot 2026-08-18 at 4 52 55 PM Screenshot 2026-08-20 at 1 38 06 PM Screenshot 2026-08-20 at 1 38 28 PM Screenshot 2026-08-20 at 5 48 00 PM Screenshot 2026-08-20 at 11 57 38 AM

@Jeel-Oza
Jeel-Oza requested a review from a team as a code owner August 20, 2026 13:42
@Jeel-Oza
Jeel-Oza requested a review from durera August 20, 2026 13:44
@Jeel-Oza
Jeel-Oza requested a review from whitfiea August 21, 2026 10:02
@whitfiea
whitfiea added this pull request to the merge queue Aug 21, 2026
Merged via the queue into stable with commit 39f25dc Aug 21, 2026
3 checks passed
@whitfiea
whitfiea deleted the mascore-15959 branch August 21, 2026 11:36
karol-czarnecki added a commit that referenced this pull request Sep 7, 2026
commit e2ead3f
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Wed Sep 2 12:55:08 2026 +0000

    [minor] Support September Interim Catalog Update (#486)

    Co-authored-by: Abhishek Kushawaha <abhishek.kushawaha@ibm.com>

commit a9acded
Author: Abhishekkushawaha <159771922+Abhishekkushawaha@users.noreply.github.com>
Date:   Tue Sep 1 17:25:28 2026 +0000

    [patch] added db2u version in doc (#487)

commit 8bd1708
Author: AquaD17 <112812380+dixitgsathwara@users.noreply.github.com>
Date:   Mon Aug 31 04:50:31 2026 +0000

    [patch] add lookupPipelineStorageClass to read storage class from existing config-pvc (#484)

    Co-authored-by: Dixit Sathwara <Dixit.Sathwara1@ibm.com>

commit 3e5cd22
Author: Abhishekkushawaha <159771922+Abhishekkushawaha@users.noreply.github.com>
Date:   Thu Aug 27 16:50:53 2026 +0000

    [patch] added tech note for manage 90x-91x upgrad issue (#482)

commit c207cf8
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Thu Aug 27 13:44:59 2026 +0000

    [minor] Support August Catalog Update (#440)

    Co-authored-by: shimto-jacob-siby <shimto.jacob.siby@ibm.com>
    Co-authored-by: jainyjoseph <jainy587@gmail.com>
    Co-authored-by: Abhishekkushawaha <159771922+Abhishekkushawaha@users.noreply.github.com>

commit 8ec8751
Author: jainyjoseph <jainy587@gmail.com>
Date:   Sat Aug 22 14:42:34 2026 +0000

    [patch] Extending mongo 8.0.29 support (#469)

    Co-authored-by: Parveen Kumar <parveenkumar@ibm.com>

commit 39f25dc
Author: Jeel-Oza <jeel.hp.87@gmail.com>
Date:   Fri Aug 21 11:29:39 2026 +0000

    [patch] Delete and recreate config-pvc when storage class changes on upgrade (#468)

    Co-authored-by: Jeel Oza <jeel-oza@ibm.com>

commit b45cce7
Author: nehasangwai-ibm <Neha.Sangwai@ibm.com>
Date:   Thu Aug 20 18:44:11 2026 +0000

    Add OLM/Helm-based installation support for CPD 5.3.1 (#461)

    Co-authored-by: Prajesh Jain <Prajesh.Jain@ibm.com>
    Co-authored-by: SahilSheikh1 <sahilsheikh6897@gmail.com>

commit 52d9cda
Author: shimto-jacob-siby <shimto.jacob.siby@ibm.com>
Date:   Thu Aug 13 13:32:38 2026 +0000

    [patch] Enabling OCP 4.22 (#456)
karol-czarnecki added a commit that referenced this pull request Sep 7, 2026
commit f8848d4
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Thu Sep 3 12:46:10 2026 +0530

    [patch] Support September Catalog Update (#488)

commit f2c1bc8
Merge: f3bb741 e2ead3f
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Thu Sep 3 09:55:24 2026 +0530

    Merge branch 'stable' into monthlyupdate

commit e2ead3f
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Wed Sep 2 12:55:08 2026 +0000

    [minor] Support September Interim Catalog Update (#486)

    Co-authored-by: Abhishek Kushawaha <abhishek.kushawaha@ibm.com>

commit f3bb741
Merge: 15b1a58 a9acded
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Wed Sep 2 12:07:54 2026 +0530

    Merge branch 'stable' into monthlyupdate

commit a9acded
Author: Abhishekkushawaha <159771922+Abhishekkushawaha@users.noreply.github.com>
Date:   Tue Sep 1 17:25:28 2026 +0000

    [patch] added db2u version in doc (#487)

commit 15b1a58
Merge: f49325d 8bd1708
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Mon Aug 31 11:00:57 2026 +0530

    Merge branch 'stable' into monthlyupdate

commit 8bd1708
Author: AquaD17 <112812380+dixitgsathwara@users.noreply.github.com>
Date:   Mon Aug 31 04:50:31 2026 +0000

    [patch] add lookupPipelineStorageClass to read storage class from existing config-pvc (#484)

    Co-authored-by: Dixit Sathwara <Dixit.Sathwara1@ibm.com>

commit f49325d
Merge: c8f6782 3e5cd22
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Fri Aug 28 08:32:19 2026 +0530

    Merge branch 'stable' into monthlyupdate

commit 3e5cd22
Author: Abhishekkushawaha <159771922+Abhishekkushawaha@users.noreply.github.com>
Date:   Thu Aug 27 16:50:53 2026 +0000

    [patch] added tech note for manage 90x-91x upgrad issue (#482)

commit c8f6782
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Thu Aug 27 21:42:52 2026 +0530

    [patch] Support September Catalog Update (#481)

commit 9b320f7
Author: Parveen Kumar <Parveenkumar@ibm.com>
Date:   Thu Aug 27 20:11:33 2026 +0530

    [minor] Support September Catalog Update

commit c207cf8
Author: Parveen Kumar <parveenkumar@ibm.com>
Date:   Thu Aug 27 13:44:59 2026 +0000

    [minor] Support August Catalog Update (#440)

    Co-authored-by: shimto-jacob-siby <shimto.jacob.siby@ibm.com>
    Co-authored-by: jainyjoseph <jainy587@gmail.com>
    Co-authored-by: Abhishekkushawaha <159771922+Abhishekkushawaha@users.noreply.github.com>

commit 8ec8751
Author: jainyjoseph <jainy587@gmail.com>
Date:   Sat Aug 22 14:42:34 2026 +0000

    [patch] Extending mongo 8.0.29 support (#469)

    Co-authored-by: Parveen Kumar <parveenkumar@ibm.com>

commit 39f25dc
Author: Jeel-Oza <jeel.hp.87@gmail.com>
Date:   Fri Aug 21 11:29:39 2026 +0000

    [patch] Delete and recreate config-pvc when storage class changes on upgrade (#468)

    Co-authored-by: Jeel Oza <jeel-oza@ibm.com>

commit b45cce7
Author: nehasangwai-ibm <Neha.Sangwai@ibm.com>
Date:   Thu Aug 20 18:44:11 2026 +0000

    Add OLM/Helm-based installation support for CPD 5.3.1 (#461)

    Co-authored-by: Prajesh Jain <Prajesh.Jain@ibm.com>
    Co-authored-by: SahilSheikh1 <sahilsheikh6897@gmail.com>

commit 52d9cda
Author: shimto-jacob-siby <shimto.jacob.siby@ibm.com>
Date:   Thu Aug 13 13:32:38 2026 +0000

    [patch] Enabling OCP 4.22 (#456)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants