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

remove enableAdvertiseAddress field, --advertise-address should be always configured #2076

Merged
merged 1 commit into from Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions charts/tidb-cluster/templates/scripts/_start_tidb.sh.tpl
Expand Up @@ -29,9 +29,7 @@ fi
# Use HOSTNAME if POD_NAME is unset for backward compatibility.
POD_NAME=${POD_NAME:-$HOSTNAME}
ARGS="--store=tikv \
{{- if .Values.tidb.enableAdvertiseAddress | default false }}
--advertise-address=${POD_NAME}.${HEADLESS_SERVICE_NAME}.${NAMESPACE}.svc \
{{- end }}
--host=0.0.0.0 \
--path=${CLUSTER_NAME}-pd:2379 \
--config=/etc/tidb/tidb.toml
Expand Down
3 changes: 0 additions & 3 deletions charts/tidb-cluster/values.yaml
Expand Up @@ -433,9 +433,6 @@ tidb:
# cloud.google.com/load-balancer-type: Internal
separateSlowLog: true

# Add --advertise-address to TiDB's startup parameters
enableAdvertiseAddress: false

slowLogTailer:
image: busybox:1.26.2
resources:
Expand Down
13 changes: 0 additions & 13 deletions docs/api-references/docs.html
Expand Up @@ -7927,19 +7927,6 @@ <h3 id="pingcap.com/v1alpha1.TiDBSpec">TiDBSpec
</tr>
<tr>
<td>
<code>enableAdvertiseAddress</code></br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>Add &ndash;advertise-address to TiDB&rsquo;s startup parameters
Optional: Defaults to false</p>
</td>
</tr>
<tr>
<td>
<code>maxFailoverCount</code></br>
<em>
int32
Expand Down
4 changes: 0 additions & 4 deletions manifests/crd.yaml
Expand Up @@ -4075,10 +4075,6 @@ spec:
cluster-level updateStrategy if present Optional: Defaults to
cluster-level setting'
type: string
enableAdvertiseAddress:
description: 'Add --advertise-address to TiDB''s startup parameters
Optional: Defaults to false'
type: boolean
env:
description: List of environment variables to set in the container,
like v1.Container.Env. Note that following env names cannot be
Expand Down
7 changes: 0 additions & 7 deletions pkg/apis/pingcap/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 7 additions & 15 deletions pkg/apis/pingcap/v1alpha1/tidbcluster.go
Expand Up @@ -22,14 +22,13 @@ import (

const (
// defaultHelperImage is default image of helper
defaultHelperImage = "busybox:1.26.2"
defaultTimeZone = "UTC"
defaultEnableTLSCluster = false
defaultEnableTLSClient = false
defaultExposeStatus = true
defaultSeparateSlowLog = true
defaultEnablePVReclaim = false
defaultEnableTiDBAdvertiseAddress = false
defaultHelperImage = "busybox:1.26.2"
defaultTimeZone = "UTC"
defaultEnableTLSCluster = false
defaultEnableTLSClient = false
defaultExposeStatus = true
defaultSeparateSlowLog = true
defaultEnablePVReclaim = false
)

var (
Expand Down Expand Up @@ -347,13 +346,6 @@ func (tidb *TiDBSpec) IsTLSClientEnabled() bool {
return tidb.TLSClient != nil && tidb.TLSClient.Enabled
}

func (tidb *TiDBSpec) IsAdvertiseAddressEnabled() bool {
if tidb.EnableAdvertiseAddress == nil {
return defaultEnableTiDBAdvertiseAddress
}
return *tidb.EnableAdvertiseAddress
}

func (tidb *TiDBSpec) ShouldSeparateSlowLog() bool {
separateSlowLog := tidb.SeparateSlowLog
if separateSlowLog == nil {
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/pingcap/v1alpha1/types.go
Expand Up @@ -304,11 +304,6 @@ type TiDBSpec struct {
// +optional
BinlogEnabled *bool `json:"binlogEnabled,omitempty"`

// Add --advertise-address to TiDB's startup parameters
// Optional: Defaults to false
// +optional
EnableAdvertiseAddress *bool `json:"enableAdvertiseAddress,omitempty"`

// MaxFailoverCount limit the max replicas could be added in failover, 0 means no failover
// Optional: Defaults to 3
// +kubebuilder:validation:Minimum=0
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions pkg/manager/member/template.go
Expand Up @@ -50,9 +50,7 @@ fi
# Use HOSTNAME if POD_NAME is unset for backward compatibility.
POD_NAME=${POD_NAME:-$HOSTNAME}
ARGS="--store=tikv \
{{- if .EnableAdvertiseAddress }}
--advertise-address=${POD_NAME}.${HEADLESS_SERVICE_NAME}.${NAMESPACE}.svc \
{{- end }}
--host=0.0.0.0 \
--path=${CLUSTER_NAME}-pd:2379 \
--config=/etc/tidb/tidb.toml
Expand All @@ -79,11 +77,10 @@ exec /tidb-server ${ARGS}
`))

type TidbStartScriptModel struct {
ClusterName string
EnableAdvertiseAddress bool
EnablePlugin bool
PluginDirectory string
PluginList string
ClusterName string
EnablePlugin bool
PluginDirectory string
PluginList string
}

func RenderTiDBStartScript(model *TidbStartScriptModel) (string, error) {
Expand Down
47 changes: 20 additions & 27 deletions pkg/manager/member/tidb_member_manager.go
Expand Up @@ -337,11 +337,10 @@ func getTiDBConfigMap(tc *v1alpha1.TidbCluster) (*corev1.ConfigMap, error) {

plugins := tc.Spec.TiDB.Plugins
startScript, err := RenderTiDBStartScript(&TidbStartScriptModel{
ClusterName: tc.Name,
EnableAdvertiseAddress: tc.Spec.TiDB.IsAdvertiseAddressEnabled(),
EnablePlugin: len(plugins) > 0,
PluginDirectory: "/plugins",
PluginList: strings.Join(plugins, ","),
ClusterName: tc.Name,
EnablePlugin: len(plugins) > 0,
PluginDirectory: "/plugins",
PluginList: strings.Join(plugins, ","),
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -609,32 +608,26 @@ func getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbCluster, cm *corev1.ConfigMap)
Name: "SLOW_LOG_FILE",
Value: slowLogFileEnvVal,
},
}

if tc.Spec.TiDB.IsAdvertiseAddressEnabled() {
advertiseEnvs := []corev1.EnvVar{
{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
},
{
Name: "NAMESPACE",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
{
Name: "NAMESPACE",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
{
Name: "HEADLESS_SERVICE_NAME",
Value: headlessSvcName,
},
}
envs = append(envs, advertiseEnvs...)
},
{
Name: "HEADLESS_SERVICE_NAME",
Value: headlessSvcName,
},
}

scheme := corev1.URISchemeHTTP
Expand Down