Skip to content

Storage created before migratedb and server start#89

Open
desmax74 wants to merge 2 commits into
guacsec:mainfrom
desmax74:storageCreateIndependet
Open

Storage created before migratedb and server start#89
desmax74 wants to merge 2 commits into
guacsec:mainfrom
desmax74:storageCreateIndependet

Conversation

@desmax74

@desmax74 desmax74 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Enhancements:

  • Move the storage PersistentVolumeClaim template to a common location and add lookup logic to skip creating the PVC when it already exists.

Signed-off-by: desmax74 <mdessi@redhat.com>
@sourcery-ai

sourcery-ai Bot commented May 19, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Makes the common storage PersistentVolumeClaim a Helm pre-install/pre-upgrade hook that is created (once) before other components, with resource retention, by moving it to the common chart and guarding it with a lookup-based existence check.

Sequence diagram for Helm pre-install/pre-upgrade PVC creation

sequenceDiagram
    participant Helm
    participant Hook_pre_install
    participant Kubernetes
    participant Migratedb
    participant Server

    Helm->>Hook_pre_install: execute pre-install hooks
    Hook_pre_install->>Kubernetes: lookup v1 PersistentVolumeClaim storage
    alt [PVC does not exist]
        Hook_pre_install->>Kubernetes: create PersistentVolumeClaim storage
        Note over Hook_pre_install,Kubernetes: annotations: helm.sh/hook pre-install,pre-upgrade
    else [PVC already exists]
        Hook_pre_install-->>Kubernetes: skip creation
    end
    Helm->>Migratedb: install/upgrade migratedb
    Helm->>Server: install/upgrade server
Loading

Flow diagram for PVC creation guard using lookup

flowchart TD
    A[Helm pre-install or pre-upgrade hook] --> B[lookup PersistentVolumeClaim storage]
    B -->|not found| C[create PersistentVolumeClaim storage
annotations: hook, hook-weight, resource-policy keep]
    B -->|found| D[skip PVC creation]
    C --> E[continue chart installation]
    D --> E[continue chart installation]
Loading

File-Level Changes

Change Details Files
Convert the storage PersistentVolumeClaim into a common, hook-based resource that is created before other components and retained across releases.
  • Move the PVC template from the server-specific templates directory to the common templates directory so it is no longer gated by the server module enablement flag.
  • Introduce template variables for the PVC name and a Helm lookup to detect an existing PVC in the release namespace.
  • Wrap the PVC manifest in a conditional so it is rendered only when no existing PVC with the same name is found.
  • Add Helm hook annotations (pre-install, pre-upgrade) with a weight to ensure early execution before dependent components.
  • Add a resource-policy keep annotation so Helm does not delete the PVC on uninstall or upgrade.
charts/trustify/templates/services/server/010-PersistentVolumeClaim-storage.yaml
charts/trustify/templates/common/010-PersistentVolumeClaim-storage.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@desmax74 desmax74 requested review from ctron and mrrajan May 19, 2026 13:57

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • With the .Values.modules.server.enabled guard removed and the PVC moved to common, this volume will now be created for all releases regardless of which modules are enabled; please confirm this broader scope is intentional or consider reintroducing a narrower condition if only certain modules require it.
  • Using helm.sh/resource-policy: keep means the PVC will persist even after uninstall or template removal, which can complicate cleanup and future installs; consider whether this is desired or if a hook delete policy (e.g. helm.sh/hook-delete-policy) would better match your lifecycle needs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- With the `.Values.modules.server.enabled` guard removed and the PVC moved to `common`, this volume will now be created for all releases regardless of which modules are enabled; please confirm this broader scope is intentional or consider reintroducing a narrower condition if only certain modules require it.
- Using `helm.sh/resource-policy: keep` means the PVC will persist even after uninstall or template removal, which can complicate cleanup and future installs; consider whether this is desired or if a hook delete policy (e.g. `helm.sh/hook-delete-policy`) would better match your lifecycle needs.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ctron

ctron commented May 20, 2026

Copy link
Copy Markdown
Contributor

Not sure this is still relevant? As there's also the other PR?

@desmax74

desmax74 commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@ctron this pr ensure the storage is present on migratedb and on server pods, the other PR #8 add only a configuration but but doesn't fix the missing storage when migratedb was executed since was performed only when the server start after the migratedb that failed due to the not yet available pvc. This PR fix move the storage creation in the migratedb and leave as is for the server executed as a last pod.

@ctron ctron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. But I guess this might break upgrade process.

@mrrajan

mrrajan commented May 20, 2026

Copy link
Copy Markdown
Contributor

@ctron @desmax74 I am testing this fix with Fresh installation using File system and S3 storage. Will keep you posted.

@mrrajan

mrrajan commented May 20, 2026

Copy link
Copy Markdown
Contributor

As @ctron mentioned, fresh installation works without any issues. But upgrade with fileSystem storage type fails for timeout. The PVC storage stuck in terminating state and as long as the PVC is not terminated, the helm installation fails due to timeout.
image

Signed-off-by: desmax74 <mdessi@redhat.com>
@desmax74

Copy link
Copy Markdown
Contributor Author

@sourcery-ai review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Removing the modules.server.enabled guard means this PVC will now be rendered whenever storage.type is filesystem, regardless of which modules are enabled; double‑check this won't create unused PVCs or conflict with other module configurations.
  • Because the PVC is now created as a pre-install,pre-upgrade hook with helm.sh/resource-policy: keep, updates to the PVC spec will not be reconciled for existing claims; confirm that future spec changes are either unnecessary or will be handled via a migration process.
  • The lookup guard prevents duplicate PVC creation but assumes the Helm release has RBAC to list PVCs in the namespace; consider what happens in restricted environments and whether you need a fallback or explicit note about this requirement.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Removing the `modules.server.enabled` guard means this PVC will now be rendered whenever `storage.type` is `filesystem`, regardless of which modules are enabled; double‑check this won't create unused PVCs or conflict with other module configurations.
- Because the PVC is now created as a `pre-install,pre-upgrade` hook with `helm.sh/resource-policy: keep`, updates to the PVC spec will not be reconciled for existing claims; confirm that future spec changes are either unnecessary or will be handled via a migration process.
- The `lookup` guard prevents duplicate PVC creation but assumes the Helm release has RBAC to list PVCs in the namespace; consider what happens in restricted environments and whether you need a fallback or explicit note about this requirement.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ctron ctron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my understanding, this would lead to data corruption. As the migration would NOT run with the actual data. But with an empty set.

@desmax74 desmax74 force-pushed the storageCreateIndependet branch from 8f2761c to c0a8f53 Compare May 25, 2026 15:59
@desmax74 desmax74 changed the title Storage create before migratedb and server start Storage created before migratedb and server start May 26, 2026
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