Skip to content

nodeset/v1: allow for postgres resources override#6

Merged
zytek merged 1 commit intomainfrom
feat/nodeset-dbres
Jul 21, 2025
Merged

nodeset/v1: allow for postgres resources override#6
zytek merged 1 commit intomainfrom
feat/nodeset-dbres

Conversation

@zytek
Copy link
Copy Markdown
Contributor

@zytek zytek commented Jul 21, 2025

Added the ability to specify resources for the Postgres component in the nodeset composite component.

  1. Added PostgresResources field to Props struct - This allows users to specify CPU and memory resource requirements for the PostgreSQL component using a map[string]map[string]string structure.

  2. Updated component logic - Modified the nodeSet function to include the specified resources in the PostgreSQL Helm chart values under the primary.resources path, which follows the Bitnami PostgreSQL chart structure.

  3. Added comprehensive tests - Created three new test functions:

    • TestNodeSetWithPostgresResources - Verifies PostgreSQL resources are properly applied when specified
    • TestNodeSetBackwardCompatibility - Ensures existing code without specifying resources continues to work
    • TestNodeSetWithEmptyPostgresResources - Tests that empty resources map works correctly
  4. Fixed linting issues - Removed unnecessary nil check for map as recommended by staticcheck

  • Backward Compatible: Existing code using the component without specifying PostgresResources will continue to work
  • Flexible Resource Specification: Users can specify both requests and limits for CPU and memory
  • Proper Integration: Resources are passed to the underlying PostgreSQL Helm chart through the correct value path
  • Well Tested: Comprehensive test coverage including edge cases and backward compatibility
nodesetProps := &nodesetv1.Props{
    Namespace: "my-namespace",
    Size: 3,
    PostgresResources: map[string]map[string]string{
        "requests": {
            "cpu":    "500m",
            "memory": "512Mi",
        },
        "limits": {
            "cpu":    "1000m",
            "memory": "1Gi",
        },
    },
    NodeProps: [...], // chainlink node configurations
}

All tests pass and the code passes linting without any issues:

  • ✅ All existing tests continue to pass (backward compatibility)
  • ✅ New tests verify PostgreSQL resource functionality
  • ✅ Code passes golangci-lint with zero issues

Added the ability to specify resources for the Postgres component in the nodeset composite component.

1. **Added `PostgresResources` field to Props struct** - This allows users to specify CPU and memory resource requirements for the PostgreSQL component using a `map[string]map[string]string` structure.

2. **Updated component logic** - Modified the `nodeSet` function to include the specified resources in the PostgreSQL Helm chart values under the `primary.resources` path, which follows the Bitnami PostgreSQL chart structure.

3. **Added comprehensive tests** - Created three new test functions:
   - `TestNodeSetWithPostgresResources` - Verifies PostgreSQL resources are properly applied when specified
   - `TestNodeSetBackwardCompatibility` - Ensures existing code without specifying resources continues to work
   - `TestNodeSetWithEmptyPostgresResources` - Tests that empty resources map works correctly

4. **Fixed linting issues** - Removed unnecessary nil check for map as recommended by staticcheck

- **Backward Compatible**: Existing code using the component without specifying `PostgresResources` will continue to work
- **Flexible Resource Specification**: Users can specify both requests and limits for CPU and memory
- **Proper Integration**: Resources are passed to the underlying PostgreSQL Helm chart through the correct value path
- **Well Tested**: Comprehensive test coverage including edge cases and backward compatibility

```go
nodesetProps := &nodesetv1.Props{
    Namespace: "my-namespace",
    Size: 3,
    PostgresResources: map[string]map[string]string{
        "requests": {
            "cpu":    "500m",
            "memory": "512Mi",
        },
        "limits": {
            "cpu":    "1000m",
            "memory": "1Gi",
        },
    },
    NodeProps: [...], // chainlink node configurations
}
```

All tests pass and the code passes linting without any issues:
- ✅ All existing tests continue to pass (backward compatibility)
- ✅ New tests verify PostgreSQL resource functionality
- ✅ Code passes `golangci-lint` with zero issues
@zytek zytek marked this pull request as ready for review July 21, 2025 12:59
@zytek zytek requested a review from a team as a code owner July 21, 2025 12:59
@zytek zytek enabled auto-merge (squash) July 21, 2025 13:13
@zytek zytek merged commit edcc244 into main Jul 21, 2025
7 checks passed
@zytek zytek deleted the feat/nodeset-dbres branch July 21, 2025 13:37
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.

2 participants