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
THREESCALE-10092 refactor status reporting on proxyConfigPromote #863
Conversation
fa2a795
to
b8b57b1
Compare
log := logf.Log.WithName("Application status reconciler test") | ||
ctx := context.TODO() | ||
// Objects to track in the fake client. | ||
objs := []runtime.Object{getApplicationCR(), getProviderAccount(), getApiManger(), getApplicationProductList(), getApplicationDeveloperAccount(), getProviderAccountRefSecret()} |
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 was deleted however, I can restore with refactor of the getBaseReconciler func but wanted to make it in a seperate PR that refactors the unit tests.
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.
hmm yea I was wondering why there were changes to the application. I will take another look in the morning.
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.
Seems that the application tests pull the "baseReconciler" which was declared in the proxyConfigPromote.
The idea I have in mind is as part of unit test refactor to make the "baseReconciler" a util func that can be used for any of the unit tests instead. But refactor of unit tests would be done as a seperate PR since I want to figure out how to test entire reconcile func instead of the inner functions of each controller reconcile.
👀 |
_, err = threescaleAPIClient.PromoteProxyConfig(productIDStr, "sandbox", strconv.Itoa(stageElement.ProxyConfig.Version), "production") | ||
if err != nil { | ||
statusReconciler := NewProxyConfigPromoteStatusReconciler(r.BaseReconciler, proxyConfigPromote, "Failed", productIDStr, latestProductionVersion, latestStagingVersion, err) | ||
// The version can already be in the production meaning that it can't be updated again, the proxyPromote is not going to be deleted by the operator but instead, will notify the user of the issue | ||
statusReconciler := NewProxyConfigPromoteStatusReconciler(r.BaseReconciler, proxyConfigPromote, string(capabilitiesv1beta1.ProxyPromoteConfigFailedConditionType), productIDStr, latestProductionVersion, latestStagingVersion, err) |
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.
hey @austincunningham can you think of any other potentiall errors we could here apart from the comms error?
When there's nothing to promote the error returned in status isn't too informative IMO and customer might find it confusing on why it's failing. I was thinking of adding a custom error message here - something of "can't promote to production since there's no staged changes". WDYT?
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.
Yea I was thinking the same this is not informative enough to figure out what is happening for a user .
message: >-
error calling 3scale system - reason: {"version":["has already been
taken"]} - code: 422
Its not an error, version is already taken doesn't inform the user to the issue. How about can't promote to stage or production as no product changes detected
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 like that yes. Will update
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.
"can't promote to production as no product changes detected, delete the proxyConfigPromote CR or introduce changes to stage env first to proceed"
@austincunningham thanks, after reviewing the other controllers status reporting I've made an improvement to the way I was reporting status. Unfortunately this means we need another review. Sorry! |
a84cef6
to
7bae410
Compare
7bae410
to
b6cd305
Compare
Code Climate has analyzed commit b6cd305 and detected 3 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
Verificationrunning through verification again
Scenario 1Scenario 2
status:
conditions:
- lastTransitionTime: '2023-09-07T06:57:01Z'
status: 'False'
type: Failed
- lastTransitionTime: '2023-09-07T06:57:01Z'
message: >-
3scale product has been successfully promoted, any further interactions
with this CR (apart from deletion) won't be applied
status: 'True'
type: Ready
latestStagingVersion: 1
productId: '7'
status:
conditions:
- lastTransitionTime: '2023-09-07T07:05:00Z'
status: 'False'
type: Failed
- lastTransitionTime: '2023-09-07T07:05:00Z'
message: >-
3scale product has been successfully promoted, any further interactions
with this CR (apart from deletion) won't be applied
status: 'True'
type: Ready
latestProductionVersion: 1
latestStagingVersion: 1
productId: '7' Scenario 3
status:
conditions:
- lastTransitionTime: '2023-09-07T07:15:05Z'
message: >-
can't promote to production as no product changes detected, delete the
proxyConfigPromote CR or introduce changes to stage env first to proceed
status: 'True'
type: Failed
- lastTransitionTime: '2023-09-07T07:15:05Z'
status: 'False'
type: Ready
latestProductionVersion: 1
latestStagingVersion: 1
productId: '8'
|
What
Slight refactor to proxyConfigPromote so that the status is updated even if there's an error of updating to production if there's no actual updates to be done. Jira: https://issues.redhat.com/browse/THREESCALE-10092
NOTE: Some unit tests have been slightly refactored - there's more refactors to unit tests to be done in future Jiras, for example, configuring mock client that could be used within different tests instead of relying on proxyPromote tests etc.
To Verify
From this branch run:
Scenario 1
Successful reconciliation - going through stage and prod without explicit bump to stage
Expected outcome:
The ProxyConfigPromote CR is deleted
The product got promoted to production
Scenario 2
Successful promotion first to stage, then in seperate CR to production:
The outcome is:
Product is created and promoted to stage, not production, the proxyConfigPromote CR status is updated with appropriate status. The CR is not deleted
The outcome is:
Product got bumped to production in 3scale, the CR is not deleted.
Now delete the proxy promote CR by applying the flag to the above resource:
The CR should be deleted.
Scenario 3
Verify that the status of proxyConfigPromote CR has been applied although no updates has been done.
Product is now promoted and the CR is gone, apply the same CR again
The outcome is that the proxyConfigPromote CR has updated status with an error (coming from 3scale) on why was it not successful. The Deletion should NOT be triggered as user should have decide himself on what to do next.