-
Notifications
You must be signed in to change notification settings - Fork 138
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
Adding Status conditions for CRs #2062
Conversation
pkg/controller/amazoncloudintegration/amazoncloudintegration_controller.go
Outdated
Show resolved
Hide resolved
pkg/controller/amazoncloudintegration/amazoncloudintegration_controller.go
Outdated
Show resolved
Hide resolved
pkg/controller/amazoncloudintegration/amazoncloudintegration_controller.go
Outdated
Show resolved
Hide resolved
6c37102
to
df1e690
Compare
dcd5789
to
d5272d5
Compare
pkg/controller/amazoncloudintegration/amazoncloudintegration_controller.go
Outdated
Show resolved
Hide resolved
pkg/controller/authentication/authentication_controller_test.go
Outdated
Show resolved
Hide resolved
pkg/controller/intrusiondetection/intrusiondetection_controller.go
Outdated
Show resolved
Hide resolved
3d2945b
to
ee4df77
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.
lgtm
427f527
to
bbf2f7d
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 made these comments before I thought to look at what was being done before. So I'm ok if we want to ignore these new comments and address them later.
The only one I'd say we should maybe consider doing now is changing the explicitDegradedMsg
type if it makes sense.
pkg/controller/status/status.go
Outdated
m.lock.Lock() | ||
defer m.lock.Unlock() | ||
m.degraded = true | ||
m.explicitDegradedReason = reason | ||
m.explicitDegradedMsg = msg | ||
m.explicitDegradedReason = string(reason) |
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.
Sorry I should have noticed this before but is there a reason to not change this explicitDegradedReason
to an operator.TigeraStatusReason so then we don't need to cast it to a string?
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.
Done
pkg/controller/status/status.go
Outdated
m.explicitDegradedReason = reason | ||
m.explicitDegradedMsg = msg | ||
m.explicitDegradedReason = string(reason) | ||
m.explicitDegradedMsg = fmt.Sprintf("%s - Error: %s", msg, errormsg) |
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 should leave out Error
and just have the format string be %s: %s
. I don't think Error adds anything to the message. 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.
Done
pkg/controller/status/status.go
Outdated
@@ -416,12 +418,17 @@ func (m *statusManager) RemoveCertificateSigningRequests(name string) { | |||
} | |||
|
|||
// SetDegraded sets degraded state with the provided reason and message. | |||
func (m *statusManager) SetDegraded(reason, msg string) { | |||
func (m *statusManager) SetDegraded(reason operator.TigeraStatusReason, msg string, err error, log logr.Logger) { | |||
log.WithValues(string(reason), msg).Error(err, string(reason)) |
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.
The expectation for logr for WithValues that it is (key, value, key, value, ...)
.
From the docs
obj.logger = mainLogger.WithValues(
"name", obj.name, "namespace", obj.namespace)
I think this log should be switched to log.WithValues("reason", string(reason)).Error(err, string(msg))
. This makes more sense to me because I feel like the reason is a category of an error and the real informational part is the msg.
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.
Done
9419a83
to
318f578
Compare
152bee1
to
0de497e
Compare
return reconcile.Result{}, err | ||
} | ||
|
||
var certificates []certificatemanagement.CertificateInterface | ||
if keyValidatorConfig != nil { | ||
dexSecret, err := certificateManager.GetCertificate(r.client, render.DexTLSSecretName, common.OperatorNamespace()) | ||
if err != nil { | ||
reqLogger.Error(err, fmt.Sprintf("failed to retrieve %s", render.DexTLSSecretName)) | ||
r.status.SetDegraded(fmt.Sprintf("Failed to retrieve %s", render.DexTLSSecretName), err.Error()) | ||
r.status.SetDegraded(operatorv1.ResourceRenderingError, fmt.Sprintf("Failed to retrieve %s", render.DexTLSSecretName), err, reqLogger) |
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 should be a read error
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.
Done
return reconcile.Result{}, false, err | ||
} | ||
|
||
if err = imageset.ResolveImages(imageSet, esKubeControllerComponents); err != nil { | ||
reqLogger.Error(err, "Error resolving ImageSet for elasticsearch kube-controllers components") | ||
r.status.SetDegraded("Error resolving ImageSet for elasticsearch kube-controllers components", err.Error()) | ||
r.status.SetDegraded(operatorv1.ResourceUpdateError, "Error resolving ImageSet for elasticsearch kube-controllers components", err, reqLogger) |
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 also a ResourceValidationError
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.
Done
Adding Status condition changes fix UT changes for Status condition Adding status condition UT fixes Adding status condition UT fixes Build fixes Usage comment chagnes Moving Setdegraded to status Fix UT for CR Condition status Rebase CR condition status changes with master Fix Intrusion detection UT update setdegraded definition to Tigerareason Rebase master Fix UT for setdegraded definition update
13240da
to
a577730
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.
lgtm
Description
For PR author
make gen-files
make gen-versions
For PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bug
if this is a bugfix.kind/enhancement
if this is a a new feature.enterprise
if this PR applies to Calico Enterprise only.