Skip to content
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

Merged
merged 19 commits into from
Jan 17, 2020

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Jan 9, 2020

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

  • Manual test

@Yisaer
Copy link
Contributor Author

Yisaer commented Jan 9, 2020

/run-e2e-in-kind

Copy link
Contributor

@aylei aylei left a 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?

charts/tidb-cluster/values.yaml Outdated Show resolved Hide resolved
pkg/monitor/monitor/util.go Outdated Show resolved Hide resolved
pkg/monitor/monitor/util.go Outdated Show resolved Hide resolved
pkg/monitor/monitor/util.go Outdated Show resolved Hide resolved
@Yisaer Yisaer requested a review from aylei January 9, 2020 10:18
@Yisaer
Copy link
Contributor Author

Yisaer commented Jan 10, 2020

what about the PD and TiDB services?

I think we could create a new issue as good first issue for community contributors to finish other service port name config work. @aylei

ref #1538

break
}
}
}
Copy link
Contributor

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,
...

@Yisaer Yisaer requested review from aylei and cofyc January 16, 2020 07:30
prometheusPortName := "http-prometheus"
grafanaPortName := "http-grafana"

if monitor.Spec.Reloader.Service.PortName != nil {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

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.

Copy link
Contributor

@aylei aylei Jan 16, 2020

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

cofyc
cofyc previously approved these changes Jan 16, 2020
Copy link
Contributor

@cofyc cofyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 642 to 646
reloaderPortName := "tcp-reloader"
prometheusPortName := "http-prometheus"
grafanaPortName := "http-grafana"

if monitor.Spec.Reloader.Service.PortName != nil {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@Yisaer Yisaer requested review from aylei and cofyc January 17, 2020 05:06

func (tm *TidbMonitor) ReloaderPortName() *string {
return tm.Spec.Reloader.Service.PortName
}
Copy link
Contributor

@cofyc cofyc Jan 17, 2020

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

Affinity: spec.Affinity(),
Tolerations: spec.Tolerations(),
NodeSelector: spec.NodeSelector(),
SchedulerName: spec.SchedulerName(),
SecurityContext: spec.PodSecurityContext(),
HostNetwork: spec.HostNetwork(),
DNSPolicy: spec.DnsPolicy(),

Copy link
Contributor

@cofyc cofyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Yisaer Yisaer added the area/monitor monitoring label Jan 17, 2020
Copy link
Contributor

@aylei aylei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aylei aylei merged commit 97d07a1 into pingcap:master Jan 17, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jan 17, 2020

cherry pick to release-1.1 in PR #1578

aylei pushed a commit that referenced this pull request Jan 18, 2020
* add port name

* Update zz_generated.deepcopy.go

* fix

* Update values.yaml

* Update util.go

* add Monitor Portname access

* exponse public access for tibdmonitor

Co-authored-by: Song Gao <disxiaofei@163.com>
@Yisaer Yisaer deleted the config_service_port_name branch February 26, 2020 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants