Skip to content

Conversation

@deads2k
Copy link
Collaborator

@deads2k deads2k commented Dec 2, 2025

This brings our mutation into the same pattern of decode to internal, manipulate, validate, store, then finally convert back to external for encoding.

builds on #3379 to convert nodepools.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Please rebase pull request.

This brings our mutation into the same pattern of decode to internal,
manipulate, validate, store, then finally convert back to external for
encoding.
Comment on lines +472 to +473
conversion.CopyReadOnlyClusterValues(newInternalCluster, oldInternalCluster)
newInternalCluster.SystemData = systemData
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

change to align to the update flow. Users shouldn't be able to set these at all.

Comment on lines +530 to +532
clusterUpdateOperation.TenantID = request.Header.Get(arm.HeaderNameHomeTenantID)
clusterUpdateOperation.ClientID = request.Header.Get(arm.HeaderNameClientObjectID)
clusterUpdateOperation.NotificationURI = request.Header.Get(arm.HeaderNameAsyncNotificationURI)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added for consistency. the ExposeOperation does the same work below, but this makes it read in parallel to create.

return err
}

// TODO is patch supposed to be status accepted?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wondered about this. Nothing is failing, but should it be different?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, good catch. Response code should be 202 (Accepted).

Resource Provider Contract quote (emphasis mine):

Response

The response includes an HTTP status code, a set of response headers, and a response body.

Status Code

The resource provider must return 200 (OK) to indicate that the synchronous Patch operation completed successfully. 202 (Accepted) must be returned to indicate that the operation will complete asynchronously.

If the resource group or resource does not exist, 404 (NotFound) should be returned.

// mergeToInternalCluster renders a CS Cluster object in JSON format, applying
// the necessary conversions for the API version of the request.
// TODO this overwrite will transformed into a "set" function as we transition fields to ownership in cosmos
func mergeToInternalCluster(csCluster *arohcpv1alpha1.Cluster, internalCluster *api.HCPOpenShiftCluster) (*api.HCPOpenShiftCluster, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

next three functions are moved here and delegate to each other so they are consistent. There were two slightly different flows before.

}

return f.updateHCPClusterInCosmos(ctx, writer, request, newInternalCluster, oldInternalCluster)
return f.readInternalClusterFromClusterService(ctx, internalCluster)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

delegated for consistency (found when re-using in nodepool cluster lookup)

logger.Error(fmt.Sprintf("%v", err), args...) // fmt used to handle nil

var ocmError *ocmerrors.Error
if errors.As(err, &ocmError) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

convenient for error handling when we're able to do this.

}
}

if database.IsResponseError(err, http.StatusNotFound) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

convenient for error handling simplification.

@@ -1,3 +1,4 @@
InvalidRequestContent: properties.autoRepair: Forbidden: field is immutable
Copy link
Collaborator Author

@deads2k deads2k Dec 2, 2025

Choose a reason for hiding this comment

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

Not sure how this was missed before in decoding, but we're now honoring user intent and it fails validation as expected. Let me know if we shouldn't.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's correct. API spec has autoRepair as create-only.

@janboll
Copy link
Collaborator

janboll commented Dec 3, 2025

/test e2e-parallel

@deads2k
Copy link
Collaborator Author

deads2k commented Dec 3, 2025

Same e2e tests fail in other runs, so probably not failure here. But this is a great indication of success otherwise!

Copy link
Collaborator

@mbarnes mbarnes left a comment

Choose a reason for hiding this comment

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

Had a concern about the top-level error handling, and also that http.StatusOK -> http.StatusAccepted you spotted needs fixed. The rest LGTM.

Comment on lines 63 to 66
if err != nil {
arm.WriteInternalServerError(w)
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe don't throw an Internal Server Error here. Some endpoint paths don't form a valid resource ID (e.g. certain list endpoints). A nil resource ID is ok to pass to ocm.CSErrorToCloudError.

Comment on lines +81 to +84
if err != nil {
arm.WriteInternalServerError(w)
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same concern as above except arm.NewResourceNotFoundError does require a resource ID. I can't think of any cases where this will be a problem, so maybe it's fine until we discover it isn't.

@deads2k
Copy link
Collaborator Author

deads2k commented Dec 3, 2025

Had a concern about the top-level error handling, and also that http.StatusOK -> http.StatusAccepted you spotted needs fixed. The rest LGTM.

Fixed all comments. Plan to merge on green.

@openshift-ci
Copy link

openshift-ci bot commented Dec 3, 2025

@deads2k: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-parallel 8dc9834 link false /test e2e-parallel

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@deads2k deads2k merged commit 54b3408 into main Dec 3, 2025
34 of 36 checks passed
@deads2k deads2k deleted the cs-57-node-align branch December 3, 2025 20:02
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