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

Fix defaulting webhook error #1876

Merged
merged 9 commits into from
Mar 10, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions pkg/apis/pingcap/v1alpha1/defaulting/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ func setTidbClusterSpecDefault(tc *v1alpha1.TidbCluster) {
}

func setTidbSpecDefault(tc *v1alpha1.TidbCluster) {
if tc.Spec.TiDB.Config == nil {
tc.Spec.TiDB.Config = &v1alpha1.TiDBConfig{}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this. @aylei could you have a look?

if len(tc.Spec.Version) > 0 || tc.Spec.TiDB.Version != nil {
if tc.Spec.TiDB.BaseImage == "" {
tc.Spec.TiDB.BaseImage = defaultTiDBImage
Expand All @@ -62,9 +59,6 @@ func setTidbSpecDefault(tc *v1alpha1.TidbCluster) {
}

func setTikvSpecDefault(tc *v1alpha1.TidbCluster) {
if tc.Spec.TiKV.Config == nil {
tc.Spec.TiKV.Config = &v1alpha1.TiKVConfig{}
}
if len(tc.Spec.Version) > 0 || tc.Spec.TiKV.Version != nil {
if tc.Spec.TiKV.BaseImage == "" {
tc.Spec.TiKV.BaseImage = defaultTiKVImage
Expand All @@ -73,9 +67,6 @@ func setTikvSpecDefault(tc *v1alpha1.TidbCluster) {
}

func setPdSpecDefault(tc *v1alpha1.TidbCluster) {
if tc.Spec.PD.Config == nil {
tc.Spec.PD.Config = &v1alpha1.PDConfig{}
}
if len(tc.Spec.Version) > 0 || tc.Spec.PD.Version != nil {
if tc.Spec.PD.BaseImage == "" {
tc.Spec.PD.BaseImage = defaultPDImage
Expand Down
9 changes: 0 additions & 9 deletions pkg/apis/pingcap/v1alpha1/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ func validateNewTidbClusterSpec(spec *v1alpha1.TidbClusterSpec, path *field.Path
if spec.PD.Image != "" {
allErrs = append(allErrs, field.Invalid(path.Child("pd.image"), spec.PD.Image, "image has been deprecated, use baseImage instead"))
}
if spec.TiDB.Config == nil {
allErrs = append(allErrs, field.Invalid(path.Child("tidb.config"), spec.TiDB.Config, "tidb.config must not be nil"))
}
if spec.TiKV.Config == nil {
allErrs = append(allErrs, field.Invalid(path.Child("tikv.config"), spec.TiKV.Config, "tidb.config must not be nil"))
}
if spec.PD.Config == nil {
allErrs = append(allErrs, field.Invalid(path.Child("pd.config"), spec.PD.Config, "tidb.config must not be nil"))
}
return allErrs
}

Expand Down
9 changes: 4 additions & 5 deletions tests/e2e/tidbcluster/serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,6 @@ var _ = ginkgo.Describe("[tidb-operator][Serial]", func() {
if empty, err := gomega.BeEmpty().Match(newTC.Spec.TiDB.BaseImage); empty {
e2elog.Failf("Expected tidb.baseImage has default value set, %v", err)
}
if isNil, err := gomega.BeNil().Match(newTC.Spec.TiDB.Config); isNil {
e2elog.Failf("Expected tidb.config has default value set, %v", err)
}

ginkgo.By("Validating should reject illegal update")
newTC.Labels = map[string]string{
Expand All @@ -601,8 +598,10 @@ var _ = ginkgo.Describe("[tidb-operator][Serial]", func() {
_, err = cli.PingcapV1alpha1().TidbClusters(ns).Update(newTC)
framework.ExpectError(err, "Could not set instance label with value other than cluster name")

newTC.Spec.PD.Config.Replication = &v1alpha1.PDReplicationConfig{
MaxReplicas: func() *uint64 { i := uint64(5); return &i }(),
newTC.Spec.PD.Config = &v1alpha1.PDConfig{
Replication: &v1alpha1.PDReplicationConfig{
MaxReplicas: func() *uint64 { i := uint64(5); return &i }(),
},
}
_, err = cli.PingcapV1alpha1().TidbClusters(ns).Update(newTC)
framework.ExpectError(err, "PD replication config is immutable through CR")
Expand Down