nodeset/v1: allow for postgres resources override#6
Merged
Conversation
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
njegosrailic
approved these changes
Jul 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added the ability to specify resources for the Postgres component in the nodeset composite component.
Added
PostgresResourcesfield to Props struct - This allows users to specify CPU and memory resource requirements for the PostgreSQL component using amap[string]map[string]stringstructure.Updated component logic - Modified the
nodeSetfunction to include the specified resources in the PostgreSQL Helm chart values under theprimary.resourcespath, which follows the Bitnami PostgreSQL chart structure.Added comprehensive tests - Created three new test functions:
TestNodeSetWithPostgresResources- Verifies PostgreSQL resources are properly applied when specifiedTestNodeSetBackwardCompatibility- Ensures existing code without specifying resources continues to workTestNodeSetWithEmptyPostgresResources- Tests that empty resources map works correctlyFixed linting issues - Removed unnecessary nil check for map as recommended by staticcheck
PostgresResourceswill continue to workAll tests pass and the code passes linting without any issues:
golangci-lintwith zero issues