-
Notifications
You must be signed in to change notification settings - Fork 169
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
Add worker profile status #3053
Conversation
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.
LGTM
The code LGTM. Let's identify the code using these API endpoints and check if they need updates in a subsequent PR. |
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.
I think we're missing updating any usage to point to the new workerProfilesStatus.
Anywhere we use kubeSubnets or the workerProfiles field internally may be subject to breakage or not complete / expected functionality. We should explore them, as the PRs should be merged together to prevent any breaking changes by introducing this change.
@@ -141,6 +141,9 @@ func (tw *typeWalker) schemaFromType(t types.Type, deps map[*types.Named]struct{ | |||
|
|||
properties := tw.schemaFromType(field.Type(), deps) | |||
properties.Description = strings.Trim(node.Doc.Text(), "\n") | |||
if field.Name() == "WorkerProfilesStatus" { | |||
properties.ReadOnly = true | |||
} |
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.
does ARM prevent the user passing in values for this if we set the swagger specification to ReadOnly? If not, we should do a server-side check to ensure the user can't actually patch this.
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.
Updated openshiftcluster_validatestatic.go to validate workerProfilesStatus filed is nil in the input request. This gets called during preflightvalidation.
workerProfiles := oc.Properties.WorkerProfiles | ||
|
||
// Use enriched worker profile data when available | ||
if oc.Properties.WorkerProfilesStatus != nil { | ||
workerProfiles = oc.Properties.WorkerProfilesStatus | ||
} | ||
|
||
out.Properties.WorkerProfiles = make([]WorkerProfile, 0, len(workerProfiles)) | ||
for _, p := range workerProfiles { |
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.
Wouldn't this generate new examples for the older API?
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.
Nope, because under openshiftcluster_example.go package we set the WorkerProfilesStatus field to nil before calling the converter function (ToExternal). This will ensure that the swagger examples remain unchanged.
Older APIs swagger examples never showed the enriched worker profile data under workerProfiles field. So I decided to keep it same.
@@ -64,6 +64,9 @@ type OpenShiftClusterProperties struct { | |||
// The cluster worker profiles. | |||
WorkerProfiles []WorkerProfile `json:"workerProfiles,omitempty"` | |||
|
|||
// The cluster worker profiles status. | |||
WorkerProfilesStatus []WorkerProfile `json:"workerProfilesStatus,omitempty"` |
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.
i'm wondering if we should make a new type for this. In the update code, we never actually set some of the parameters that exist within a workerProfile struct.
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.
WorkerProfilesStatus - I see all the field are set/referenced under worker_profile.go package while performing the enrichment.
These are the list of ARO-RP pkgs that had reference to workerProfiles filed and I had updated whichever needs to be updated to workerProfilesStatus. Let me know if you think I'm missing anything. |
Please rebase pull request. |
aef1db6
to
560399e
Compare
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.
I believe we need to at least rethink the conversion logic so it can account for nil workerProfileStatus before workerProfiles since the enrichment in this PR will never populate workerProfiles. See comments below.
@@ -102,10 +102,10 @@ func (ce machineClientEnricher) Enrich( | |||
oc.Lock.Lock() | |||
defer oc.Lock.Unlock() | |||
|
|||
oc.Properties.WorkerProfiles = workerProfiles |
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.
after further thinking, I believe this will break our admin api. Since the doc will not have workerProfiles
set, when the conversion is made, workerProfiles is nil and so the output will not have workerProfiles since we first check for workerProfiles and then check for workerProfileStatus. Any automation in place which relies on the workerProfiles via admin API would need to be changed.
I think an alternative approach, would be to leave the doc the same (always have it be enriched via workerProfiles) and for new API versions we can do the conversion.
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.
Updated workerProfiles references as suggested by Ben.
I haven't had the chance to review the list of places it's been used yet, but we need to be careful this change doesn't break existing functionality. Think this:
I would say generally we can proceed by:
|
made changes to the workerProfiles references as suggested. |
/azp run e2e |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Hi @gouthamMN thank you for the PR. I believe it should work as is, but this has potential to go in regression. Meaning, I approve, but we need at least one more approve before merging. @bennerv ?
@bennerv - I have added JIRA item https://issues.redhat.com/browse/ARO-4016 to work on updating the azure-cli to take the intersection of workerProfiles and workerProfilesStatus to ensure we have the proper FPSP and CSP RBAC to work. Once this PR is merged I will update the azure-cli. |
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.
lgtm, considering the risk of regression and the importance of workerprofiles, can we deploy this branch to INT, create a cluster and run an az aro update on it, PUCM it, and see what the output of the GetCluster GA is?
As suggested, performed the Regression Tests:
From the test it was confirmed there were no changes in the behavior of the existing stable API (v2023-04-01). The new API (v2023-09-04) cannot be tested at this point as the az cli is not updated to use it. |
stale, appears concerns have been addressed
* add workerProfilesStatus field to hold the enriched worker profile data * update swagger * swagger examples * update clients * resolve golint * update defaults * validate worker Profile status is nil in input request * make client changes after rebase * rebase * update workerProfiles references and UTs * fix golint errors * remove duplicate logic of verifing workerProfilesStatus not nil --------- Co-authored-by: gniranjan <[email protected]>
Which issue this PR addresses:
Fixes https://issues.redhat.com/browse/ARO-2124
What this PR does / why we need it:
OpenShiftCluster GET API returns enriched worker profile data under a new field "workerProfilesStatus". This change is introduced only to new API. More details can be found on Design Doc
Any API call made to endpoints /openShiftClusters or /openShiftCluster with GET method using newer API versions (>= v2023-09-04) will return the enriched worker profile data under a new field "workerProfilesStatus" in the response and "workerProfiles" filed will contain the last input that was passed in PUT/PATCH request body for cluster creation or update.
The response and behavior of any older APIs versions (< v2023-09-04) remain unchanged i.e, only "workerProfiles" filed exists in the response.
Test plan for issue:
Existing unit tests and E2E test copied over from previous API.
As suggested in the comments, performed the Regression Tests:
**az aro create**
.**az aro update**
.From the test, it was confirmed that there were no changes in the behavior of the existing stable API (v2023-04-01). The new API (v2023-09-04) cannot be tested at this point as the az cli is not updated to use it.
Is there any documentation that needs to be updated for this PR?
N/A