[FIX][NPA-1847] - Added a validation on node_info field #523
[FIX][NPA-1847] - Added a validation on node_info field #523Chaithra001 wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a configuration-time guard in the Grid Member resource to prevent invalid standalone configurations that specify an HA-style node_info (2 nodes) while enable_ha is false, which previously led to incomplete/incorrect WAPI results (single node returned and missing mgmt_lan).
Changes:
- Add
ValidateConfigvalidation requiringenable_ha = truewhennode_infocontains exactly 2 nodes. - Surface a clear validation error message to block the invalid configuration before WAPI interaction.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if len(nodeInfo) == 2 { | ||
| if data.EnableHa.IsNull() || data.EnableHa.IsUnknown() || !data.EnableHa.ValueBool() { | ||
| resp.Diagnostics.AddError("Validation Error", "enable_ha must be true when node_info contains 2 nodes") | ||
| } | ||
| } |
There was a problem hiding this comment.
fix the formatting issue
| if len(nodeInfo) == 2 { | ||
| if data.EnableHa.IsNull() || data.EnableHa.IsUnknown() || !data.EnableHa.ValueBool() { | ||
| resp.Diagnostics.AddError("Validation Error", "enable_ha must be true when node_info contains 2 nodes") | ||
| } |
|
|
||
| if len(nodeInfo) == 2 { | ||
| if data.EnableHa.IsNull() || data.EnableHa.IsUnknown() || !data.EnableHa.ValueBool() { | ||
| resp.Diagnostics.AddError("Validation Error", "enable_ha must be true when node_info contains 2 nodes") | ||
| } | ||
| } |
There was a problem hiding this comment.
fix the formatting issue
| if len(nodeInfo) == 2 { | ||
| if data.EnableHa.IsNull() || data.EnableHa.IsUnknown() || !data.EnableHa.ValueBool() { | ||
| resp.Diagnostics.AddError("Validation Error", "enable_ha must be true when node_info contains 2 nodes") | ||
| } |
There was a problem hiding this comment.
can we add test case around this
| } | ||
| } | ||
|
|
||
| if len(nodeInfo) == 2 { |
There was a problem hiding this comment.
is it possible len(nodeInfo) > 2, if yes then write the logic accordingly
| ), | ||
| }, | ||
| // Update and Read | ||
| { |
There was a problem hiding this comment.
add test cases for other failure scenarios too
Issue: When
node_infocontained two nodes andenable_hawas set tofalse, the WAPI response returned only a single node because the member was treated as a standalone node andmgmt_laninformation was also not returned.Fix: Added validation to ensure that
enable_hais set totruewhenevernode_infocontains two nodes, preventing invalid configurations and ensuring the expected node andmgmt_landata are returned.