Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(infra): enable HA and increase retention for postgresql #1955

Merged
merged 4 commits into from
Feb 26, 2025

Conversation

arealmaas
Copy link
Collaborator

@arealmaas arealmaas commented Feb 25, 2025

Description

Enables High Availability for Staging and Production instances using availability zones: https://learn.microsoft.com/en-us/azure/reliability/reliability-postgresql-flexible-server?toc=%2Fazure%2Fpostgresql%2Ftoc.json&bc=%2Fazure%2Fpostgresql%2Fbreadcrumb%2Ftoc.json#availability-zone-support

Add retention to 32 days in production, using the default 7 days for other environments.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

@arealmaas arealmaas requested review from a team as code owners February 25, 2025 12:50
Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

Walkthrough

This pull request introduces new configuration options for PostgreSQL deployments, specifically high availability and backup retention settings. Two parameters, enableHighAvailability (boolean) and backupRetentionDays (integer), are added to the postgresConfiguration object in multiple Bicep files. These parameters are utilized in the PostgreSQL module instantiation and allow for tailored configurations in different environments. The PostgreSQL module is also updated to handle these new parameters effectively.

Changes

Files Change Summary
.azure/infrastructure/main.bicep Added parameters enableHighAvailability (bool) and backupRetentionDays (int) to the postgresConfiguration object and passed them to the postgresql module instantiation.
.azure/infrastructure/prod.bicepparam
.azure/infrastructure/staging.bicepparam
.azure/infrastructure/test.bicepparam
.azure/infrastructure/yt01.bicepparam
Added parameters enableHighAvailability and backupRetentionDays to the postgresConfiguration object, with values set to true (prod) and false (staging, test, yt01) for high availability, and 32 (prod) and 7 (staging, test, yt01) for backup retention days.
.azure/modules/postgreSql/create.bicep Introduced parameters enableHighAvailability (bool) and backupRetentionDays (int), created a variable highAvailabilityConfig for conditional high availability settings, and integrated backupRetentionDays into the PostgreSQL resource definition.

Suggested reviewers

  • oskogstad

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.azure/modules/postgreSql/create.bicep (2)

55-57: Introduce High Availability Parameter for Module Flexibility

The new parameter enableHighAvailability has been added to the module with an appropriate description, which facilitates conditional HA configuration.
Optional Improvement: Consider providing a default value (for example, false) if you want to make the parameter optional in scenarios where HA is not desired by default.


92-96: Conditional HA Configuration Logic

The variable highAvailabilityConfig is defined conditionally based on the enableHighAvailability flag. This configuration uses a static setting with:

  • mode set to 'ZoneRedundant'
  • standbyAvailabilityZone set to '2'

Optional Improvement: To make the module more flexible across different regions or setups, consider making standbyAvailabilityZone configurable through a separate parameter.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 691492a and b9211e0.

📒 Files selected for processing (6)
  • .azure/infrastructure/main.bicep (2 hunks)
  • .azure/infrastructure/prod.bicepparam (1 hunks)
  • .azure/infrastructure/staging.bicepparam (1 hunks)
  • .azure/infrastructure/test.bicepparam (1 hunks)
  • .azure/infrastructure/yt01.bicepparam (1 hunks)
  • .azure/modules/postgreSql/create.bicep (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Dry run deploy infrastructure / Deploy to test
🔇 Additional comments (7)
.azure/infrastructure/test.bicepparam (1)

39-39: High availability configuration looks good for test environment.

Setting highAvailability: false for the test environment is appropriate to reduce costs while still maintaining the same parameter structure across environments.

.azure/infrastructure/yt01.bicepparam (1)

41-41: High availability configuration looks good for yt01 environment.

Setting highAvailability: false for the yt01 environment is consistent with the approach for other non-production environments, helping to minimize resource costs where high availability isn't critical.

.azure/infrastructure/prod.bicepparam (1)

39-39: High availability enabled for production - perfect!

Setting highAvailability: true for the production environment aligns perfectly with the PR objective to enable HA for PostgreSQL in production. This critical setting will enhance reliability and minimize potential downtime.

.azure/infrastructure/staging.bicepparam (1)

39-39: High availability enabled for staging - looks good!

Setting highAvailability: true for the staging environment is appropriate as it aligns with the PR objective and follows best practices. Having the same HA configuration in staging as in production allows for proper testing of HA behavior before changes reach production.

.azure/infrastructure/main.bicep (2)

60-66: High Availability Parameter Addition in postgresConfiguration

The addition of the enableHighAvailability boolean within the postgresConfiguration parameter object is clear and directly supports the PR objective for enabling HA on PostgreSQL. Please ensure that all environment-specific parameter files set this flag appropriately.


217-220: Correct Passing of the HA Parameter to the PostgreSQL Module

The module instantiation for PostgreSQL correctly passes the enableHighAvailability parameter (i.e. enableHighAvailability: postgresConfiguration.enableHighAvailability). This ensures that the high availability configuration will be correctly applied during deployment.

.azure/modules/postgreSql/create.bicep (1)

117-118: Integration of High Availability Settings in PostgreSQL Resource

The PostgreSQL resource correctly integrates the high availability settings by assigning highAvailability: highAvailabilityConfig. This ensures that if high availability is enabled, the server is provisioned with the appropriate configuration.

knuhau
knuhau previously approved these changes Feb 25, 2025
@arealmaas arealmaas changed the title feat(infra): enable HA for postgresql feat(infra): enable HA and increase retention for postgresql Feb 26, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.azure/infrastructure/main.bicep (1)

65-66: Add Descriptive Annotations for New PostgreSQL Configuration Parameters
The addition of enableHighAvailability: bool and backupRetentionDays: int to the postgresConfiguration object meets the PR objectives. For clarity and maintainability, consider adding @description annotations for these new parameters so future readers can immediately understand their purpose and impact.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9211e0 and ac7aa8a.

📒 Files selected for processing (6)
  • .azure/infrastructure/main.bicep (2 hunks)
  • .azure/infrastructure/prod.bicepparam (1 hunks)
  • .azure/infrastructure/staging.bicepparam (1 hunks)
  • .azure/infrastructure/test.bicepparam (1 hunks)
  • .azure/infrastructure/yt01.bicepparam (1 hunks)
  • .azure/modules/postgreSql/create.bicep (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • .azure/infrastructure/test.bicepparam
  • .azure/infrastructure/staging.bicepparam
  • .azure/infrastructure/yt01.bicepparam
  • .azure/infrastructure/prod.bicepparam
  • .azure/modules/postgreSql/create.bicep
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Dry run deploy infrastructure / Deploy to test
🔇 Additional comments (1)
.azure/infrastructure/main.bicep (1)

219-220: Ensure Consistent Handling of New Parameters in PostgreSQL Module
The new parameters are correctly passed to the postgresql module as enableHighAvailability: postgresConfiguration.enableHighAvailability and backupRetentionDays: postgresConfiguration.backupRetentionDays. Please verify that the downstream module (../modules/postgreSql/create.bicep) is updated to properly handle these parameters.

@arealmaas arealmaas merged commit 84a3fc6 into main Feb 26, 2025
17 checks passed
@arealmaas arealmaas deleted the feat/enable-ha-for-postgresql branch February 26, 2025 14:42
arealmaas pushed a commit that referenced this pull request Feb 26, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.56.0](v1.55.5...v1.56.0)
(2025-02-26)


### Features

* **infra:** enable HA and increase retention for postgresql
([#1955](#1955))
([84a3fc6](84a3fc6))


### Miscellaneous Chores

* **e2e:** put filter on createdAfter for search in cleanup-step
e2e-tests ([#1970](#1970))
([f9d2099](f9d2099))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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