chore(role_assignment): make roleassignment reconcile async#1873
Conversation
|
Hi @sonasingh46. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
|
/ok-to-test |
35426b5 to
082d85c
Compare
082d85c to
1bbe5b6
Compare
5b5d1d9 to
3073807
Compare
| actual := NewService(mps, resourceskus.NewStaticCache(nil, "")) | ||
| g.Expect(actual).ToNot(BeNil()) | ||
| } | ||
| // ToDo: Fix this test case |
There was a problem hiding this comment.
@CecileRobertMichon @shysank -- Any suggestions on fixing this test case. This test case requires to import scope package and hence causes import loop.
There was a problem hiding this comment.
looking, I don't think we should be creating real scopes to test NewService(). NewService takes a ScaleSetScope, which we have a mock for, so we should be able to do:
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
scopeMock := NewMockScaleSetScope(mockCtrl)
actual := NewService(scopeMock, resourceskus.NewStaticCache(nil, ""))
g.Expect(actual).ToNot(BeNil())
If that doesn't work, that test isn't testing much since the NewService func just sets the parameters into a struct and returns it, so worst case we can get rid of the test altogether.
There was a problem hiding this comment.
I tried something like below:
scopeMock := mock_scalesets.NewMockScaleSetScope(mockCtrl)
rec:=scopeMock.EXPECT()
rec.SubscriptionID().Return("123")
rec.BaseURI().Return("/dummy")
rec.Authorizer().Return(scopeMock)
actual := NewService(scopeMock, resourceskus.NewStaticCache(nil, ""))
g.Expect(actual).ToNot(BeNil())
I added those mock Returns as they were expected but at the end I got error something like this:
wrong type of argument 0 to Return for *mock_scalesets.MockScaleSetScope.Authorizer: *mock_scalesets.MockScaleSetScope is not assignable to autorest.Authorizer [/Users/kuashutosh/go/src/sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets/scalesets_test.go:66]
|
Hey @sonasingh46, how's it going with the role assignments PR? I worked on a lot of the async refactor PRs with @CecileRobertMichon, and I'd be happy to answer any questions or to do a code review. |
| if len(s.Scope.RoleAssignmentSpecs(to.StringPtr(""))) < 1 { | ||
| log.V(2).Info("no role assignment spec to reconcile") | ||
| return nil | ||
| } |
There was a problem hiding this comment.
This is a redundant call to role assignments spec that I had to make so that when we fetch principalID -- nil point exception does not occur.
When there is not role assignment spec, while fetching the vm details, some of fields are nil and looks more simpler to return early in case there is no role assignment spec.
So this first call passes an empty principal ID and validates if role assignment spec is present and then below finds the principal ID and calls this spec function once again to finally get the correct role assignment specs.
cc @CecileRobertMichon @Jont828
There was a problem hiding this comment.
I'd suggest adding another method to scope that just returns true/false if the machine/machinepool has system assigned identity for better readability.
There was a problem hiding this comment.
I'd suggest adding another method to scope that just returns true/false if the machine/machinepool has system assigned identity for better readability.
+1
1ad6487 to
b9fcc7f
Compare
|
/test pull-cluster-api-provider-azure-e2e |
|
/test pull-cluster-api-provider-azure-e2e-windows-dockershim |
|
@sonasingh46: The specified target(s) for
The following commands are available to trigger optional jobs:
Use
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. |
CecileRobertMichon
left a comment
There was a problem hiding this comment.
/lgtm
/assign @shysank
|
@sonasingh46 can you please squash? |
|
@sonasingh46 were you able to find the cause of failure for the vmss e2e test? |
|
/retest |
b9fcc7f to
71ac260
Compare
|
@shysank -- Not sure why it failed but when I rebased and pushed again the test passed. |
Signed-off-by: Ashutosh Kumar <sonasingh46@gmail.com>
71ac260 to
0b74770
Compare
|
/retest |
1 similar comment
|
/retest |
|
@sonasingh46: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shysank 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 |
Signed-off-by: Ashutosh Kumar sonasingh46@gmail.com
What type of PR is this?
What this PR does / why we need it:
Implementation of async service for role assignment.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #1718
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
TODOs:
Release note: