-
Notifications
You must be signed in to change notification settings - Fork 20
HYPERFLEET-971 - feat: reject nodepool create/patch on soft-deleted cluster #113
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,11 +190,15 @@ func (h ClusterNodePoolsHandler) Patch(w http.ResponseWriter, r *http.Request) { | |
| clusterID := mux.Vars(r)["id"] | ||
| nodePoolID := mux.Vars(r)["nodepool_id"] | ||
|
|
||
| _, err := h.clusterService.Get(ctx, clusterID) | ||
| cluster, err := h.clusterService.Get(ctx, clusterID) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if cluster.DeletedTime != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip nit — non-blocking suggestion Category: JIRA The JIRA ticket HYPERFLEET-971 acceptance criteria says "PUT /clusters/:clusterID/nodepools/:nodepoolID returns 409" but the API only exposes PATCH for nodepool updates — no PUT endpoint exists. The implementation here is correct (guarding PATCH), but worth updating the JIRA AC to match reality so the ticket closes cleanly. |
||
| return nil, errors.ConflictState("Cluster '%s' is marked for deletion", clusterID) | ||
| } | ||
|
kuudori marked this conversation as resolved.
|
||
|
|
||
| found, err := h.nodePoolService.Get(ctx, nodePoolID) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
@@ -204,6 +208,10 @@ func (h ClusterNodePoolsHandler) Patch(w http.ResponseWriter, r *http.Request) { | |
| return nil, errors.NotFound("NodePool '%s' not found for cluster '%s'", nodePoolID, clusterID) | ||
| } | ||
|
|
||
| if found.DeletedTime != nil { | ||
| return nil, errors.ConflictState("NodePool '%s' is marked for deletion", nodePoolID) | ||
| } | ||
|
|
||
| if patch.Spec != nil { | ||
| specJSON, jsonErr := json.Marshal(*patch.Spec) | ||
| if jsonErr != nil { | ||
|
|
@@ -258,6 +266,10 @@ func (h ClusterNodePoolsHandler) Create(w http.ResponseWriter, r *http.Request) | |
| return nil, err | ||
| } | ||
|
|
||
| if cluster.DeletedTime != nil { | ||
| return nil, errors.ConflictState("Cluster '%s' is marked for deletion", clusterID) | ||
| } | ||
|
|
||
| // Use the presenters.ConvertNodePool helper to convert the request | ||
| nodePoolModel, convErr := presenters.ConvertNodePool(&req, cluster.ID, "system@hyperfleet.local") | ||
| if convErr != nil { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
nit — non-blocking suggestion
Category: Standards
The error model standard defines
HYPERFLEET-CNF-003as "Operation not allowed in current state" but the implementation here says "Operation not allowed in current resource state". In practice it doesn't matter sinceConflictState()calls always pass a custom reason, but matching the standard keeps things consistent.