-
Notifications
You must be signed in to change notification settings - Fork 501
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
Make service port-name configurable in monitor #1521
Conversation
/run-e2e-in-kind |
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.
what about the PD and TiDB services?
pkg/monitor/monitor/util.go
Outdated
break | ||
} | ||
} | ||
} |
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 is redundant, why not use the desired port name at the first place?
grafanaPortName := "http-grafana"
if monitor.Spec.Grafana.Service.PortName != nil {
grafanaPortName := *monitor.Spec.Grafana.Service.PortName
}
...
Name: grafanaPortName,
...
pkg/monitor/monitor/util.go
Outdated
prometheusPortName := "http-prometheus" | ||
grafanaPortName := "http-grafana" | ||
|
||
if monitor.Spec.Reloader.Service.PortName != nil { |
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.
what if PortName
is non-nil but empty, should we use the default name in that case?
cc @aylei do you recommend to use *string
or 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.
what if
PortName
is non-nil but empty, should we use the default name in that case?
cc @aylei do you recommend to use*string
orstring
?
I think operator don't need to consider this case, if monitor service synced failed because of setting wrong by users, users should be responsible for it.
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.
It is about our purpose. For kubernetes, port name is optional and could be empty, so the current code is okay. If we think empty is not a valid value, then we could consider empty as unset
, pick default for it and use string
as the type, otherwise, just keep *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.
LGTM
pkg/monitor/monitor/util.go
Outdated
reloaderPortName := "tcp-reloader" | ||
prometheusPortName := "http-prometheus" | ||
grafanaPortName := "http-grafana" | ||
|
||
if monitor.Spec.Reloader.Service.PortName != nil { |
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 recommend add an access method for each Spec to get the port name to encapsulate the details of port name calculation.
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.
|
||
func (tm *TidbMonitor) ReloaderPortName() *string { | ||
return tm.Spec.Reloader.Service.PortName | ||
} |
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 all default values here, and in controller logic we can simply use TidbMonitor.(PrometheusPortName|GrafanaPortName|ReloaderPortName)
? like
tidb-operator/pkg/manager/member/pump_member_manager.go
Lines 373 to 379 in d314b25
Affinity: spec.Affinity(), | |
Tolerations: spec.Tolerations(), | |
NodeSelector: spec.NodeSelector(), | |
SchedulerName: spec.SchedulerName(), | |
SecurityContext: spec.PodSecurityContext(), | |
HostNetwork: spec.HostNetwork(), | |
DNSPolicy: spec.DnsPolicy(), |
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
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
cherry pick to release-1.1 in PR #1578 |
What problem does this PR solve?
#1512
Make service port-name configurable in the monitor (Both TidbMonitor and monitor config in
values.yaml
).Check List
Tests