-
Notifications
You must be signed in to change notification settings - Fork 204
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
Messages to Azure Sql Firewall Rule #356
Conversation
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.
Requesting at least one change... make sure Messages that occur need logging statements are passed to the logging call... this ensures things are aligned. Also, I'm confused by new updateerr conditions you added. I may be 100% wrong, but if you can explain them to me, that would be great. :-) Thanks Mel (sorry for so many comments)
@@ -67,6 +67,10 @@ func (r *AzureSqlFirewallRuleReconciler) Reconcile(req ctrl.Request) (ctrl.Resul | |||
if helpers.HasFinalizer(&instance, azureSQLFirewallRuleFinalizerName) { | |||
if err := r.deleteExternal(&instance); err != nil { | |||
log.Info("Delete AzureSqlFirewallRule failed with ", "error", err.Error()) | |||
instance.Status.Message = fmt.Sprintf("Delete AzureSqlFirewallRule failed with %s", err.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.
move this above the log.Info and then send this exact message to log.Info... this will ensure everything is unified :-)
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 good practice for the future - I'm going to leave it as is for now since it is consistent across the other controllers. I think it would be good to handle these all together as a new task 👍
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.
Decided to fix it @WilliamMortlMicrosoft :) Good idea! I think this looks a lot cleaner, too!! Except, I still have the log in the same spot. I didn't think that mattered!
@@ -81,6 +85,10 @@ func (r *AzureSqlFirewallRuleReconciler) Reconcile(req ctrl.Request) (ctrl.Resul | |||
if !helpers.HasFinalizer(&instance, azureSQLFirewallRuleFinalizerName) { | |||
if err := r.addFinalizer(&instance); err != nil { | |||
log.Info("Adding AzureSqlFirewallRule finalizer failed with ", "error", err.Error()) | |||
instance.Status.Message = fmt.Sprintf("Adding AzureSqlFirewallRule finalizer failed with error %s", err.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.
(same as above) use with log.Info
@@ -98,6 +106,10 @@ func (r *AzureSqlFirewallRuleReconciler) Reconcile(req ctrl.Request) (ctrl.Resul | |||
if azerr, ok := err.(*errhelp.AzureError); ok { | |||
if helpers.ContainsString(catch, azerr.Type) { | |||
log.Info("Got ignorable error", "type", azerr.Type) | |||
instance.Status.Message = fmt.Sprintf("Got ignorable error of type %s", azerr.Type) |
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.
(same as above) use with log.Info
if updateerr := r.Status().Update(ctx, &instance); updateerr != nil { | ||
r.Recorder.Event(&instance, corev1.EventTypeWarning, "Failed", "Unable to update instance") |
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'm confused by this new error trap... please double check... also, the message should reflect the warning, no? (I may be 100% wrong on this)
if updateerr := r.Status().Update(ctx, instance); updateerr != nil { | ||
r.Recorder.Event(instance, corev1.EventTypeWarning, "Failed", "Unable to update instance") |
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.
same as earlier, confused by the error trap and why message isnt being set
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.
So this is needed because we need to set the message variable which is done through r.Status().
But the error check is if it is somehow unable to update that variable (which shouldn't happen). Have this across the controllers as well
if updateerr := r.Status().Update(ctx, instance); updateerr != nil { | ||
r.Recorder.Event(instance, corev1.EventTypeWarning, "Failed", "Unable to update instance") |
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.
same as earlier, confused by the error trap and why message isnt being set
if updateerr := r.Status().Update(ctx, instance); updateerr != nil { | ||
r.Recorder.Event(instance, corev1.EventTypeWarning, "Failed", "Unable to update instance") | ||
} |
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.
same as earlier, confused by the error trap and why message isnt being set
if updateerr := r.Status().Update(ctx, instance); updateerr != nil { | ||
r.Recorder.Event(instance, corev1.EventTypeWarning, "Failed", "Unable to update instance") | ||
} |
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.
same as earlier, confused by the error trap and why message isnt being set
if updateerr := r.Status().Update(context.Background(), instance); updateerr != nil { | ||
r.Recorder.Event(instance, corev1.EventTypeWarning, "Failed", "Unable to update instance") | ||
} |
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.
same as earlier, confused by the error trap and why message isnt being set
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
Address #326
What this PR does / why we need it:
Adding messages to the AzureSqlFirewall controller
Special notes for your reviewer:
Create an azure sql firewall instance
Run
k get azuresqlfirewallrule -o yaml
to see current message status of instance.Should see a message field like:
If applicable: