measure UserSignup provision time#1148
measure UserSignup provision time#1148MatousJobanek merged 8 commits intocodeready-toolchain:masterfrom
Conversation
alexeykazakov
left a comment
There was a problem hiding this comment.
Code-wise looks good but this metric measures the time between the Signup request (UserSignupRequestReceivedTimeAnnotationKey which I guess will be added later in a separate PR?) and the UserSingup set to the Complete status.
But https://docs.google.com/document/d/1xr1CVKIjcTdp5obpmTMGoNr7syFplnVArd-h5-yQnDk/edit?tab=t.0#heading=h.xd8t24f9nad talks about the time from the signup request to the namespace/user creation. Which basically means a combination of UserSignup complete status AND Space & Mur Ready statuses.
The UserSignup.Status.Complete doesn't necessarily mean everything has been provisioned.
I guess that you already noticed the other PR in the reg-service: codeready-toolchain/registration-service#515
Look at this part of the code: host-operator/controllers/usersignup/usersignup_controller.go Lines 375 to 380 in ec07825 it actually waits until the Space is ready and provisioned, so this part is covered. Since MUR is created before and acts immediately on the presence of SpaceBinding and Space.Spec.TargetCluster, we could assume that it should be ready before the Space, but it's true that we don't check it explicitly. I added the check/wait here 84c6983 |
mfrancisc
left a comment
There was a problem hiding this comment.
Nice job 👍
I have only few cosmetic comments.
| delete(userSignup.Annotations, toolchainv1alpha1.UserSignupRequestReceivedTimeAnnotationKey) | ||
| if err := cl.Update(ctx, userSignup); err != nil { | ||
| return err | ||
| } |
There was a problem hiding this comment.
minor - should we delete at the end? once the provisionTimeSeconds was computed. Just in case something goes wrong in the middle.
There was a problem hiding this comment.
Yeah, I was thinking about it too. For the simplicity, I decided to delete it and log the information. In this case, the presence of the annotation says if the given UserSignup was already recorded or not. If we would want to keep it, then we would need to add another field into UserSignup.Status to store the provision time.
Both options are valid, I decided to go with the simpler one. We can always change it later.
But if there would be more people asking for having the information stored in UserSignup, then I can do it in this PR.
There was a problem hiding this comment.
Sorry , I was just wondering if we should move those lines after line 427, not keeping the information. Just move it as last thing in the function.
There was a problem hiding this comment.
ah, gotcha.
I used this order intentionally to ensure that the provision time for the particular UserSignup will be recorded only once. If the update fails (because of a conflict) then the controller requeue a new reconcile and try to remove the annotation again. With this approach, the provision time will be recorded only when the removal of the annotation is successful. If the removal was at the end of the function and the update failed, then we would have two records for the same UserSignup.
There was a problem hiding this comment.
gotcha, makes sense! thanks for explaining that!
I was thinking about the case in which fails after the update and before the recording ( basically parsing the value ). But I think that is tolerated, more than having duplicated recordings.
There was a problem hiding this comment.
If it fails for parsing the value, then there is some problem between reg-service and host-operator and we should only log the error and not return it nor try to parse it again. The resulting duration would be irrelevant and we shouldn't block the UserSignup because of some broken telemetry data.
OK. I missed when we started waiting for the Space to be ready. And with this change (wait for MUR) we can clean up our reg-service a bit: https://github.com/codeready-toolchain/registration-service/blob/60b898ffd19907210b19e9a43f0b26facabb1583/pkg/signup/service/signup_service.go#L398-L399 |
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexeykazakov, MatousJobanek, mfrancisc 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 |
|
/retest |
2d3af3b
into
codeready-toolchain:master
Codecov ReportAttention: Patch coverage is
❌ Your changes status has failed because you have indirect coverage changes. Learn more about Unexpected Coverage Changes and reasons for indirect coverage changes. Additional details and impacted files@@ Coverage Diff @@
## master #1148 +/- ##
==========================================
+ Coverage 79.67% 79.71% +0.03%
==========================================
Files 82 82
Lines 8154 8203 +49
==========================================
+ Hits 6497 6539 +42
- Misses 1466 1471 +5
- Partials 191 193 +2
|



Measures the provision time of the UserSignups.
The start-time is taken from the annotation set in reg-service, as the end-time is taken the moment when UserSignup is marked as Complete.
The provision time is measured only when:
The annotation is removed to ensure that we don't record the provision time twice for the same user
TODO:
depends on:
codeready-toolchain/api#464
codeready-toolchain/toolchain-common#461
codeready-toolchain/registration-service#515 (this needs to be merged first to properly test it in e2e tests)
paired with codeready-toolchain/toolchain-e2e#1126
SANDBOX-957