-
Notifications
You must be signed in to change notification settings - Fork 499
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
Revise TidbMonitor controller #1500
Conversation
please add a release note |
/run-all-test |
/run-all-tests |
return err | ||
} | ||
mm.recorder.Event(monitor, corev1.EventTypeNormal, SuccessSync, fmt.Sprintf("Sync TidbMonitor[%s/%s] Service Success", monitor.Namespace, monitor.Name)) |
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 suggest not recording successful sync to reduce verbosity, also, note that there is a global event rate-limit of tidb-controller-manager
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.
updated, all successful sync wouldn't be recorded.
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 good practice is to record a successful event once the operation is done successfully and skip if nothing needs to do because the actual state matches the desired state
in this case, the events of objects will be like:
- optional warning events about failures
- one successful event
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 pattern can be applied to the most scenarios that the desired state is often only changed by the reconciliation controller, e.g. object specs managed by our controller
we can improve it in the future
@@ -182,3 +209,13 @@ func (mm *MonitorManager) syncTidbMonitorRbac(monitor *v1alpha1.TidbMonitor) (*c | |||
|
|||
return sa, nil | |||
} | |||
|
|||
// If the namespace in ClusterRef is empty, we would set the TidbMonitor's namespace in the default | |||
func setDefaultNamespaceForClusterRef(tm *v1alpha1.TidbMonitor) { |
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.
Please do not mutate spec in controller, spec is user intent and by definition, is owned by user
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.
updated.
Co-Authored-By: Aylei <[email protected]>
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.
By the way, can we add some basic tests for functions in pkg/monitor/monitor
? No tests yet right now.
pkg/monitor/monitor/util.go
Outdated
@@ -729,3 +734,10 @@ func getMonitorPVC(monitor *v1alpha1.TidbMonitor) *core.PersistentVolumeClaim { | |||
}, | |||
} | |||
} | |||
|
|||
// If the namespace in ClusterRef is empty, we would set the TidbMonitor's namespace in the default | |||
func setDefaultNamespaceForClusterRef(model *MonitorConfigModel, tm *v1alpha1.TidbMonitor) { |
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 don't need to create a new function for this
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.
updated.
Sure, and issued in #1554. |
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
BTW, it is recommended to separate PR to logic complete unit, so that each feature/fix could be independently rollbacked or cherry-picked, also, the release note will be easier to write. |
/merge |
/run-all-tests |
/run-all-tests |
@Yisaer merge failed. |
/run-e2e-in-kind |
cherry pick to release-1.1 in PR #1557 |
* fix log bug * add default namespace for clusterRef * fix error log which don't requeue * add event recorder * Update pkg/monitor/monitor/monitor_manager.go Co-Authored-By: Aylei <[email protected]> * fix by conment * Update monitor_manager.go * Update util.go Co-authored-by: Song Gao <[email protected]> Co-authored-by: Aylei <[email protected]>
What problem does this PR solve?
fix the bug for the log level of the Prometheus Spec in TidbMonitor which would cause TidbMonitor Failed to start. TidbMonitor: should not specify log level when prometheus.logLevel is empty #1482
Add default namespace for the
ClusterRef
if it's empty in TidbMonitor Spec. no default for.spec.clusterRef.namespace
of TiDB monitor #1480Add events for TidbMonitor Controller for a more user-friendly experience. clearer message when TidbMonitor failed syncing because of the absence of referenced cluster #1481
Does this PR introduce a user-facing change?: