From f4d911b3daad05b4111a0914d514150e64ec3c07 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Thu, 15 Aug 2019 14:07:49 +0800 Subject: [PATCH 1/5] Support hostNetwork --- pkg/apis/pingcap.com/v1alpha1/types.go | 34 +++-- .../v1alpha1/zz_generated.deepcopy.go | 123 +++++++----------- pkg/manager/member/pd_member_manager.go | 15 +++ pkg/manager/member/tidb_member_manager.go | 7 + pkg/manager/member/tikv_member_manager.go | 15 +++ 5 files changed, 98 insertions(+), 96 deletions(-) diff --git a/pkg/apis/pingcap.com/v1alpha1/types.go b/pkg/apis/pingcap.com/v1alpha1/types.go index 03cee04b11..4920cf747d 100644 --- a/pkg/apis/pingcap.com/v1alpha1/types.go +++ b/pkg/apis/pingcap.com/v1alpha1/types.go @@ -103,26 +103,28 @@ type TidbClusterStatus struct { TiDB TiDBStatus `json:"tidb,omitempty"` } +// PodSpec repreresents shared pod fields between PD/TiDB/TiKV +type PodSpec struct { + Replicas int32 `json:"replicas"` + Affinity *corev1.Affinity `json:"affinity,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + HostNetwork bool `json:"hostNetwork,omitempty"` +} + // PDSpec contains details of PD member type PDSpec struct { ContainerSpec - Replicas int32 `json:"replicas"` - Affinity *corev1.Affinity `json:"affinity,omitempty"` - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - StorageClassName string `json:"storageClassName,omitempty"` - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - Annotations map[string]string `json:"annotations,omitempty"` + PodSpec + StorageClassName string `json:"storageClassName,omitempty"` } // TiDBSpec contains details of PD member type TiDBSpec struct { ContainerSpec - Replicas int32 `json:"replicas"` - Affinity *corev1.Affinity `json:"affinity,omitempty"` - NodeSelector map[string]string `json:"nodeSelector,omitempty"` + PodSpec StorageClassName string `json:"storageClassName,omitempty"` - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - Annotations map[string]string `json:"annotations,omitempty"` BinlogEnabled bool `json:"binlogEnabled,omitempty"` MaxFailoverCount int32 `json:"maxFailoverCount,omitempty"` SeparateSlowLog bool `json:"separateSlowLog,omitempty"` @@ -137,13 +139,9 @@ type TiDBSlowLogTailerSpec struct { // TiKVSpec contains details of PD member type TiKVSpec struct { ContainerSpec - Privileged bool `json:"privileged,omitempty"` - Replicas int32 `json:"replicas"` - Affinity *corev1.Affinity `json:"affinity,omitempty"` - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - StorageClassName string `json:"storageClassName,omitempty"` - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - Annotations map[string]string `json:"annotations,omitempty"` + PodSpec + Privileged bool `json:"privileged,omitempty"` + StorageClassName string `json:"storageClassName,omitempty"` } // TiKVPromGatewaySpec runs as a sidecar with TiKVSpec diff --git a/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go index fe9b4d0061..d0ffc842fa 100644 --- a/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go @@ -321,32 +321,7 @@ func (in *PDMember) DeepCopy() *PDMember { func (in *PDSpec) DeepCopyInto(out *PDSpec) { *out = *in in.ContainerSpec.DeepCopyInto(&out.ContainerSpec) - if in.Affinity != nil { - in, out := &in.Affinity, &out.Affinity - *out = new(v1.Affinity) - (*in).DeepCopyInto(*out) - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Tolerations != nil { - in, out := &in.Tolerations, &out.Tolerations - *out = make([]v1.Toleration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Annotations != nil { - in, out := &in.Annotations, &out.Annotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } + in.PodSpec.DeepCopyInto(&out.PodSpec) return } @@ -396,6 +371,48 @@ func (in *PDStatus) DeepCopy() *PDStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodSpec) DeepCopyInto(out *PodSpec) { + *out = *in + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSpec. +func (in *PodSpec) DeepCopy() *PodSpec { + if in == nil { + return nil + } + out := new(PodSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceRequirement) DeepCopyInto(out *ResourceRequirement) { *out = *in @@ -623,32 +640,7 @@ func (in *TiDBSlowLogTailerSpec) DeepCopy() *TiDBSlowLogTailerSpec { func (in *TiDBSpec) DeepCopyInto(out *TiDBSpec) { *out = *in in.ContainerSpec.DeepCopyInto(&out.ContainerSpec) - if in.Affinity != nil { - in, out := &in.Affinity, &out.Affinity - *out = new(v1.Affinity) - (*in).DeepCopyInto(*out) - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Tolerations != nil { - in, out := &in.Tolerations, &out.Tolerations - *out = make([]v1.Toleration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Annotations != nil { - in, out := &in.Annotations, &out.Annotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } + in.PodSpec.DeepCopyInto(&out.PodSpec) in.SlowLogTailer.DeepCopyInto(&out.SlowLogTailer) return } @@ -736,32 +728,7 @@ func (in *TiKVPromGatewaySpec) DeepCopy() *TiKVPromGatewaySpec { func (in *TiKVSpec) DeepCopyInto(out *TiKVSpec) { *out = *in in.ContainerSpec.DeepCopyInto(&out.ContainerSpec) - if in.Affinity != nil { - in, out := &in.Affinity, &out.Affinity - *out = new(v1.Affinity) - (*in).DeepCopyInto(*out) - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Tolerations != nil { - in, out := &in.Tolerations, &out.Tolerations - *out = make([]v1.Toleration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Annotations != nil { - in, out := &in.Annotations, &out.Annotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } + in.PodSpec.DeepCopyInto(&out.PodSpec) return } diff --git a/pkg/manager/member/pd_member_manager.go b/pkg/manager/member/pd_member_manager.go index f85013eeea..222edc7cb4 100644 --- a/pkg/manager/member/pd_member_manager.go +++ b/pkg/manager/member/pd_member_manager.go @@ -484,6 +484,11 @@ func (pmm *pdMemberManager) getNewPDSetForTidbCluster(tc *v1alpha1.TidbCluster) } } + dnsPolicy := corev1.DNSClusterFirst // same as k8s defaults + if tc.Spec.PD.HostNetwork { + dnsPolicy = corev1.DNSClusterFirstWithHostNet + } + pdSet := &apps.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: setName, @@ -503,6 +508,8 @@ func (pmm *pdMemberManager) getNewPDSetForTidbCluster(tc *v1alpha1.TidbCluster) SchedulerName: tc.Spec.SchedulerName, Affinity: tc.Spec.PD.Affinity, NodeSelector: tc.Spec.PD.NodeSelector, + HostNetwork: tc.Spec.PD.HostNetwork, + DNSPolicy: dnsPolicy, Containers: []corev1.Container{ { Name: v1alpha1.PDMemberType.String(), @@ -532,6 +539,14 @@ func (pmm *pdMemberManager) getNewPDSetForTidbCluster(tc *v1alpha1.TidbCluster) }, }, }, + { + Name: "POD_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.name", + }, + }, + }, { Name: "PEER_SERVICE_NAME", Value: controller.PDPeerMemberName(tcName), diff --git a/pkg/manager/member/tidb_member_manager.go b/pkg/manager/member/tidb_member_manager.go index 9a28d0451a..25686f55d8 100644 --- a/pkg/manager/member/tidb_member_manager.go +++ b/pkg/manager/member/tidb_member_manager.go @@ -329,6 +329,11 @@ func (tmm *tidbMemberManager) getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbClust }, }) + dnsPolicy := corev1.DNSClusterFirst // same as k8s defaults + if tc.Spec.PD.HostNetwork { + dnsPolicy = corev1.DNSClusterFirstWithHostNet + } + tidbLabel := label.New().Instance(instanceName).TiDB() podAnnotations := CombineAnnotations(controller.AnnProm(10080), tc.Spec.TiDB.Annotations) tidbSet := &apps.StatefulSet{ @@ -350,6 +355,8 @@ func (tmm *tidbMemberManager) getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbClust SchedulerName: tc.Spec.SchedulerName, Affinity: tc.Spec.TiDB.Affinity, NodeSelector: tc.Spec.TiDB.NodeSelector, + HostNetwork: tc.Spec.PD.HostNetwork, + DNSPolicy: dnsPolicy, Containers: containers, RestartPolicy: corev1.RestartPolicyAlways, Tolerations: tc.Spec.TiDB.Tolerations, diff --git a/pkg/manager/member/tikv_member_manager.go b/pkg/manager/member/tikv_member_manager.go index 8b7c50dbe9..4e36f05f7b 100644 --- a/pkg/manager/member/tikv_member_manager.go +++ b/pkg/manager/member/tikv_member_manager.go @@ -320,6 +320,11 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster) storageClassName = controller.DefaultStorageClassName } + dnsPolicy := corev1.DNSClusterFirst // same as k8s defaults + if tc.Spec.PD.HostNetwork { + dnsPolicy = corev1.DNSClusterFirstWithHostNet + } + tikvset := &apps.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: setName, @@ -339,6 +344,8 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster) SchedulerName: tc.Spec.SchedulerName, Affinity: tc.Spec.TiKV.Affinity, NodeSelector: tc.Spec.TiKV.NodeSelector, + HostNetwork: tc.Spec.PD.HostNetwork, + DNSPolicy: dnsPolicy, Containers: []corev1.Container{ { Name: v1alpha1.TiKVMemberType.String(), @@ -366,6 +373,14 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster) }, }, }, + { + Name: "POD_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.name", + }, + }, + }, { Name: "CLUSTER_NAME", Value: tcName, From 606030560563ae4a3f13be5283c4fa1a8aee0005 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Thu, 15 Aug 2019 14:12:15 +0800 Subject: [PATCH 2/5] Use POD_NAME instead of HOSTNAME --- charts/tidb-cluster/templates/scripts/_start_pd.sh.tpl | 4 ++-- charts/tidb-cluster/templates/scripts/_start_tikv.sh.tpl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/tidb-cluster/templates/scripts/_start_pd.sh.tpl b/charts/tidb-cluster/templates/scripts/_start_pd.sh.tpl index 36273d8693..b5058aef65 100644 --- a/charts/tidb-cluster/templates/scripts/_start_pd.sh.tpl +++ b/charts/tidb-cluster/templates/scripts/_start_pd.sh.tpl @@ -30,7 +30,7 @@ fi # the general form of variable PEER_SERVICE_NAME is: "-pd-peer" cluster_name=`echo ${PEER_SERVICE_NAME} | sed 's/-pd-peer//'` -domain="${HOSTNAME}.${PEER_SERVICE_NAME}.${NAMESPACE}.svc" +domain="${POD_NAME}.${PEER_SERVICE_NAME}.${NAMESPACE}.svc" discovery_url="${cluster_name}-discovery.${NAMESPACE}.svc:10261" encoded_domain_url=`echo ${domain}:2380 | base64 | tr "\n" " " | sed "s/ //g"` @@ -57,7 +57,7 @@ while true; do done ARGS="--data-dir=/var/lib/pd \ ---name=${HOSTNAME} \ +--name=${POD_NAME} \ --peer-urls=http://0.0.0.0:2380 \ --advertise-peer-urls=http://${domain}:2380 \ --client-urls=http://0.0.0.0:2379 \ diff --git a/charts/tidb-cluster/templates/scripts/_start_tikv.sh.tpl b/charts/tidb-cluster/templates/scripts/_start_tikv.sh.tpl index 8345ffed6c..9f42d26e48 100644 --- a/charts/tidb-cluster/templates/scripts/_start_tikv.sh.tpl +++ b/charts/tidb-cluster/templates/scripts/_start_tikv.sh.tpl @@ -29,7 +29,7 @@ then fi ARGS="--pd=${CLUSTER_NAME}-pd:2379 \ ---advertise-addr=${HOSTNAME}.${HEADLESS_SERVICE_NAME}.${NAMESPACE}.svc:20160 \ +--advertise-addr=${POD_NAME}.${HEADLESS_SERVICE_NAME}.${NAMESPACE}.svc:20160 \ --addr=0.0.0.0:20160 \ --data-dir=/var/lib/tikv \ --capacity=${CAPACITY} \ From 7a7b3a283ca4d7549579512ebd08bbd0bad34617 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Tue, 20 Aug 2019 10:08:04 +0800 Subject: [PATCH 3/5] Update chart --- charts/tidb-cluster/templates/tidb-cluster.yaml | 3 +++ charts/tidb-cluster/values.yaml | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/charts/tidb-cluster/templates/tidb-cluster.yaml b/charts/tidb-cluster/templates/tidb-cluster.yaml index bf8adc11dd..0f86e6c006 100644 --- a/charts/tidb-cluster/templates/tidb-cluster.yaml +++ b/charts/tidb-cluster/templates/tidb-cluster.yaml @@ -45,6 +45,7 @@ spec: annotations: {{ toYaml .Values.pd.annotations | indent 6 }} {{- end }} + hostNetwork: {{ .Values.pd.hostNetwork }} tikv: replicas: {{ .Values.tikv.replicas }} image: {{ .Values.tikv.image }} @@ -67,6 +68,7 @@ spec: annotations: {{ toYaml .Values.tikv.annotations | indent 6 }} {{- end }} + hostNetwork: {{ .Values.tikv.hostNetwork }} tidb: replicas: {{ .Values.tidb.replicas }} image: {{ .Values.tidb.image }} @@ -86,6 +88,7 @@ spec: annotations: {{ toYaml .Values.tidb.annotations | indent 6 }} {{- end }} + hostNetwork: {{ .Values.tidb.hostNetwork }} binlogEnabled: {{ .Values.binlog.pump.create | default false }} maxFailoverCount: {{ .Values.tidb.maxFailoverCount | default 3 }} separateSlowLog: {{ .Values.tidb.separateSlowLog | default false }} diff --git a/charts/tidb-cluster/values.yaml b/charts/tidb-cluster/values.yaml index dcb94bf0e4..c241648c9f 100644 --- a/charts/tidb-cluster/values.yaml +++ b/charts/tidb-cluster/values.yaml @@ -152,6 +152,10 @@ pd: # effect: "NoSchedule" annotations: {} + # Use the host's network namespace if enabled. + # Default to false. + hostNetwork: false + tikv: # Please refer to https://github.com/tikv/tikv/blob/master/etc/config-template.toml for the default # tikv configurations (change to the tags of your tikv version), @@ -248,6 +252,10 @@ tikv: # effect: "NoSchedule" annotations: {} + # Use the host's network namespace if enabled. + # Default to false. + hostNetwork: false + tidb: # Please refer to https://github.com/pingcap/tidb/blob/master/config/config.toml.example for the default # tidb configurations(change to the tags of your tidb version), @@ -297,6 +305,11 @@ tidb: # value: tidb # effect: "NoSchedule" annotations: {} + + # Use the host's network namespace if enabled. + # Default to false. + hostNetwork: false + maxFailoverCount: 3 service: type: NodePort From ecc8a6dda0b703a8b8ef4ffd7b9e0d99cbdb7628 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Tue, 20 Aug 2019 16:47:30 +0800 Subject: [PATCH 4/5] e2e test --- tests/cluster_info.go | 11 +++++++++++ tests/cmd/e2e/main.go | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/tests/cluster_info.go b/tests/cluster_info.go index 0caea9decd..d81eef1a66 100644 --- a/tests/cluster_info.go +++ b/tests/cluster_info.go @@ -31,6 +31,17 @@ func (tc *TidbClusterConfig) ScaleTiDB(replicas uint) *TidbClusterConfig { return tc } +func (tc *TidbClusterConfig) RunInHost(flag bool) *TidbClusterConfig { + val := "false" + if flag { + val := "true" + } + tc.set("pd.hostNetwork", val) + tc.set("tikv.hostNetwork", val) + tc.set("tidb.hostNetwork", val) + return tc +} + func (tc *TidbClusterConfig) UpgradePD(image string) *TidbClusterConfig { tc.PDImage = image return tc diff --git a/tests/cmd/e2e/main.go b/tests/cmd/e2e/main.go index f0db2a828c..1e05c9884d 100644 --- a/tests/cmd/e2e/main.go +++ b/tests/cmd/e2e/main.go @@ -111,6 +111,18 @@ func main() { UpdateTiDBTokenLimit(cfg.TiDBTokenLimit) oa.UpgradeTidbClusterOrDie(cluster1) oa.CheckTidbClusterStatusOrDie(cluster1) + + // switch to host network + cluster1.RunInHost(true) + oa.UpgradeTidbClusterOrDie(cluster1) + oa.CheckUpgradeOrDie(ctx, cluster1) + oa.CheckTidbClusterStatusOrDie(cluster1) + + // switch to pod network + cluster1.RunInHost(false) + oa.UpgradeTidbClusterOrDie(cluster1) + oa.CheckUpgradeOrDie(ctx, cluster1) + oa.CheckTidbClusterStatusOrDie(cluster1) } fn2 := func(wg *sync.WaitGroup) { defer wg.Done() From e937e2cf1f35b627c4607e6d7ab7e1d80d218f16 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Tue, 20 Aug 2019 16:58:47 +0800 Subject: [PATCH 5/5] remove PodSpec --- pkg/apis/pingcap.com/v1alpha1/types.go | 37 +++--- .../v1alpha1/zz_generated.deepcopy.go | 123 +++++++++++------- tests/cluster_info.go | 2 +- tests/cmd/e2e/main.go | 2 - 4 files changed, 100 insertions(+), 64 deletions(-) diff --git a/pkg/apis/pingcap.com/v1alpha1/types.go b/pkg/apis/pingcap.com/v1alpha1/types.go index 4920cf747d..055a8467df 100644 --- a/pkg/apis/pingcap.com/v1alpha1/types.go +++ b/pkg/apis/pingcap.com/v1alpha1/types.go @@ -103,27 +103,27 @@ type TidbClusterStatus struct { TiDB TiDBStatus `json:"tidb,omitempty"` } -// PodSpec repreresents shared pod fields between PD/TiDB/TiKV -type PodSpec struct { - Replicas int32 `json:"replicas"` - Affinity *corev1.Affinity `json:"affinity,omitempty"` - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - Annotations map[string]string `json:"annotations,omitempty"` - HostNetwork bool `json:"hostNetwork,omitempty"` -} - // PDSpec contains details of PD member type PDSpec struct { ContainerSpec - PodSpec - StorageClassName string `json:"storageClassName,omitempty"` + Replicas int32 `json:"replicas"` + Affinity *corev1.Affinity `json:"affinity,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + HostNetwork bool `json:"hostNetwork,omitempty"` + StorageClassName string `json:"storageClassName,omitempty"` } // TiDBSpec contains details of PD member type TiDBSpec struct { ContainerSpec - PodSpec + Replicas int32 `json:"replicas"` + Affinity *corev1.Affinity `json:"affinity,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + HostNetwork bool `json:"hostNetwork,omitempty"` StorageClassName string `json:"storageClassName,omitempty"` BinlogEnabled bool `json:"binlogEnabled,omitempty"` MaxFailoverCount int32 `json:"maxFailoverCount,omitempty"` @@ -139,9 +139,14 @@ type TiDBSlowLogTailerSpec struct { // TiKVSpec contains details of PD member type TiKVSpec struct { ContainerSpec - PodSpec - Privileged bool `json:"privileged,omitempty"` - StorageClassName string `json:"storageClassName,omitempty"` + Replicas int32 `json:"replicas"` + Affinity *corev1.Affinity `json:"affinity,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + HostNetwork bool `json:"hostNetwork,omitempty"` + Privileged bool `json:"privileged,omitempty"` + StorageClassName string `json:"storageClassName,omitempty"` } // TiKVPromGatewaySpec runs as a sidecar with TiKVSpec diff --git a/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go index d0ffc842fa..fe9b4d0061 100644 --- a/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go @@ -321,7 +321,32 @@ func (in *PDMember) DeepCopy() *PDMember { func (in *PDSpec) DeepCopyInto(out *PDSpec) { *out = *in in.ContainerSpec.DeepCopyInto(&out.ContainerSpec) - in.PodSpec.DeepCopyInto(&out.PodSpec) + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } return } @@ -371,48 +396,6 @@ func (in *PDStatus) DeepCopy() *PDStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodSpec) DeepCopyInto(out *PodSpec) { - *out = *in - if in.Affinity != nil { - in, out := &in.Affinity, &out.Affinity - *out = new(v1.Affinity) - (*in).DeepCopyInto(*out) - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Tolerations != nil { - in, out := &in.Tolerations, &out.Tolerations - *out = make([]v1.Toleration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Annotations != nil { - in, out := &in.Annotations, &out.Annotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSpec. -func (in *PodSpec) DeepCopy() *PodSpec { - if in == nil { - return nil - } - out := new(PodSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceRequirement) DeepCopyInto(out *ResourceRequirement) { *out = *in @@ -640,7 +623,32 @@ func (in *TiDBSlowLogTailerSpec) DeepCopy() *TiDBSlowLogTailerSpec { func (in *TiDBSpec) DeepCopyInto(out *TiDBSpec) { *out = *in in.ContainerSpec.DeepCopyInto(&out.ContainerSpec) - in.PodSpec.DeepCopyInto(&out.PodSpec) + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.SlowLogTailer.DeepCopyInto(&out.SlowLogTailer) return } @@ -728,7 +736,32 @@ func (in *TiKVPromGatewaySpec) DeepCopy() *TiKVPromGatewaySpec { func (in *TiKVSpec) DeepCopyInto(out *TiKVSpec) { *out = *in in.ContainerSpec.DeepCopyInto(&out.ContainerSpec) - in.PodSpec.DeepCopyInto(&out.PodSpec) + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } return } diff --git a/tests/cluster_info.go b/tests/cluster_info.go index d81eef1a66..d11d805656 100644 --- a/tests/cluster_info.go +++ b/tests/cluster_info.go @@ -34,7 +34,7 @@ func (tc *TidbClusterConfig) ScaleTiDB(replicas uint) *TidbClusterConfig { func (tc *TidbClusterConfig) RunInHost(flag bool) *TidbClusterConfig { val := "false" if flag { - val := "true" + val = "true" } tc.set("pd.hostNetwork", val) tc.set("tikv.hostNetwork", val) diff --git a/tests/cmd/e2e/main.go b/tests/cmd/e2e/main.go index 1e05c9884d..06c8c32af7 100644 --- a/tests/cmd/e2e/main.go +++ b/tests/cmd/e2e/main.go @@ -115,13 +115,11 @@ func main() { // switch to host network cluster1.RunInHost(true) oa.UpgradeTidbClusterOrDie(cluster1) - oa.CheckUpgradeOrDie(ctx, cluster1) oa.CheckTidbClusterStatusOrDie(cluster1) // switch to pod network cluster1.RunInHost(false) oa.UpgradeTidbClusterOrDie(cluster1) - oa.CheckUpgradeOrDie(ctx, cluster1) oa.CheckTidbClusterStatusOrDie(cluster1) } fn2 := func(wg *sync.WaitGroup) {