-
Notifications
You must be signed in to change notification settings - Fork 1.5k
OCPBUGS-4549: destroy: azure: handle nil responses from msgraph sdk
#6717
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
Conversation
|
@r4f4: This pull request references Jira Issue OCPBUGS-4549, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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/test-infra repository. |
0e49c94 to
746cc30
Compare
pkg/destroy/azure/azure.go
Outdated
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.
Do we know what a nil response means? Was the deletion successful? API not supported?
If we don't know, or aren't certain, I would suggest do a little more here in terms of logging, perhaps a warning or or adding an error to the error list.
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.
In this case it's just a GET (all the apps with ID == appID), the delete happens a few lines later. I cannot easily tell why, would have to dig dipper into the msgraph code: https://github.com/microsoftgraph/msgraph-sdk-go/blob/main/serviceprincipals/service_principal_item_request_builder.go#L267-L273
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 this is the SendAsync function: https://github.com/microsoft/kiota-http-go/blob/main/nethttp_request_adapter.go#L286-L287
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.
Anyway, it's probably a good idea to at least add some logging in those cases. Thanks.
|
/hold |
It seems the SDK can return `nil` as a response even if no errors
occurred. If we don't check for that, we get the following error on Gov
cloud:
```
12-19 13:21:52.860 level=debug msg=deleting application registrations
12-19 13:21:52.860 E1219 05:21:48.969224 743 runtime.go:79] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
12-19 13:21:52.860 goroutine 1 [running]:
12-19 13:21:52.860 k8s.io/apimachinery/pkg/util/runtime.logPanic({0x6132160?, 0x22371b20})
12-19 13:21:52.860 /go/src/github.com/openshift/installer/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:75 +0x99
12-19 13:21:52.860 k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0x0?})
12-19 13:21:52.860 /go/src/github.com/openshift/installer/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:49 +0x75
12-19 13:21:52.861 panic({0x6132160, 0x22371b20})
12-19 13:21:52.861 /usr/lib/golang/src/runtime/panic.go:884 +0x212
12-19 13:21:52.861 github.com/openshift/installer/pkg/destroy/azure.getServicePrincipalsByTag({0x1d9580b0, 0xc0008443c0}, 0xc000cec420, {0xc000792570, 0x29}, {0xc000dcc650, 0xd})
12-19 13:21:52.861 /go/src/github.com/openshift/installer/pkg/destroy/azure/azure.go:632 +0x322
12-19 13:21:52.861 github.com/openshift/installer/pkg/destroy/azure.deleteApplicationRegistrations({0x1d9580b0, 0xc0008443c0}, 0xc000cec420, {0x1d98a0d0, 0xc0001da000}, {0xc000dcc650, 0xd})
```
8609a62 to
420b556
Compare
|
/hold cancel |
barbacbd
left a comment
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
| if err != nil { | ||
| return errors.Wrap(err, "failed to gather list of Service Principals by tag") | ||
| } | ||
| // msgraphsdk can return a `nil` response even if no errors occurred |
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.
This logic can be moved within https://github.com/openshift/installer/blob/master/pkg/destroy/azure/azure.go#L621. Also, looking at getServicePrincipalsByTag(), it appears that this method can set resp to nil even if the original API did not return a 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.
I preferred to do it here so I don't have to change the getServicePrincipalsByTag to receive a logger just so I can log a message in case that happens. I can change it if you think there is an advantage in doing that.
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.
Also, looking at getServicePrincipalsByTag(), it appears that this method can set resp to nil even if the original API did not return a nil.
That's OK because in that case err != nil and the error condition will (and should) be evaluated first.
| logger.Debugf("Empty response getting Application from Service Principal %s", *sp.GetDisplayName()) | ||
| continue | ||
| } | ||
| apps := resp.GetValue() |
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.
Do we have to chck for resp == nil for https://github.com/openshift/installer/blob/master/pkg/destroy/azure/azure.go#L611?
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.
Hard to say since the API is not very clear about it. I don't think so since in the docs they don't mention any error handling https://learn.microsoft.com/en-us/graph/sdks/create-requests?tabs=Go#delete-an-entity. Notice that ApplicationsById does not return an Application object, but an ApplicationItemRequestBuilder instead. I'd be very surprised if a nil response was returned for that.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: patrickdillon The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold Revision 420b556 was retested 3 times: holding |
|
/hold cancel |
|
/skip |
|
/retest-required |
|
/hold Revision 420b556 was retested 3 times: holding |
|
/hold cancel |
|
@r4f4: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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/test-infra repository. I understand the commands that are listed here. |
|
@r4f4: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-4549 has been moved to the MODIFIED state. DetailsIn response to this:
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/test-infra repository. |
It seems the SDK can return
nilas a response even if no errors occurred. If we don't check for that, we get the following error on Gov cloud:This is a fallout of #6614