Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
cofyc committed Nov 6, 2019
1 parent 623dfbe commit 5ea91d1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
23 changes: 9 additions & 14 deletions cmd/controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,35 +152,30 @@ func main() {
},
}

var hijackKubeInformerFactory kubeinformers.SharedInformerFactory
var hijackKubeCli kubernetes.Interface
if features.DefaultFeatureGate.Enabled(features.AdvancedStatefulSet) {
// If AdvancedStatefulSet is enabled, we hijack client and informer factory to use AdvancedStatefulSet.
hijackKubeCli = helper.NewHijackClient(kubeCli, asCli)
hijackKubeInformerFactory = helper.NewHijackSharedInformerFactory(kubeInformerFactory, asInformerFactory)
} else {
hijackKubeCli = kubeCli
hijackKubeInformerFactory = kubeInformerFactory
// If AdvancedStatefulSet is enabled, we hijack the Kubernetes client to use
// AdvancedStatefulSet.
kubeCli = helper.NewHijackClient(kubeCli, asCli)
}

tcController := tidbcluster.NewController(hijackKubeCli, cli, informerFactory, hijackKubeInformerFactory, autoFailover, pdFailoverPeriod, tikvFailoverPeriod, tidbFailoverPeriod)
backupController := backup.NewController(hijackKubeCli, cli, informerFactory, hijackKubeInformerFactory)
restoreController := restore.NewController(hijackKubeCli, cli, informerFactory, hijackKubeInformerFactory)
bsController := backupschedule.NewController(hijackKubeCli, cli, informerFactory, hijackKubeInformerFactory)
tcController := tidbcluster.NewController(kubeCli, cli, informerFactory, kubeInformerFactory, autoFailover, pdFailoverPeriod, tikvFailoverPeriod, tidbFailoverPeriod)
backupController := backup.NewController(kubeCli, cli, informerFactory, kubeInformerFactory)
restoreController := restore.NewController(kubeCli, cli, informerFactory, kubeInformerFactory)
bsController := backupschedule.NewController(kubeCli, cli, informerFactory, kubeInformerFactory)
controllerCtx, cancel := context.WithCancel(context.Background())
defer cancel()

// Start informer factories after all controller are initialized.
informerFactory.Start(controllerCtx.Done())
hijackKubeInformerFactory.Start(controllerCtx.Done())
kubeInformerFactory.Start(controllerCtx.Done())

// Wait for all started informers' cache were synced.
for v, synced := range informerFactory.WaitForCacheSync(wait.NeverStop) {
if !synced {
glog.Fatalf("error syncing informer for %v", v)
}
}
for v, synced := range hijackKubeInformerFactory.WaitForCacheSync(wait.NeverStop) {
for v, synced := range kubeInformerFactory.WaitForCacheSync(wait.NeverStop) {
if !synced {
glog.Fatalf("error syncing informer for %v", v)
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/ant31/crd-validation v0.0.0-20180702145049-30f8a35d0ac2
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/cofyc/advanced-statefulset v0.0.0-20191105120117-6c0ac9b9df68
github.com/cofyc/advanced-statefulset v0.0.0-20191106043045-45c7bf25c7a8
github.com/coreos/go-semver v0.3.0
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0
github.com/docker/go-connections v0.4.0 // indirect
Expand Down Expand Up @@ -57,7 +57,7 @@ require (
github.com/sirupsen/logrus v1.4.2
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
github.com/spf13/pflag v1.0.3
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 // indirect
github.com/uber-go/atomic v0.0.0-00010101000000-000000000000 // indirect
github.com/uber/jaeger-client-go v2.19.0+incompatible // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
github.com/cofyc/advanced-statefulset v0.0.0-20191105120117-6c0ac9b9df68 h1:GsnTaZMgLtt0LR1TdL2GsWsEHDXp8/SbuWgpmVd1+k4=
github.com/cofyc/advanced-statefulset v0.0.0-20191105120117-6c0ac9b9df68/go.mod h1:4KdFa5r17cDhDS6PfRzw/S+Mwk2GwEjqE7aY6EGT0QE=
github.com/cofyc/advanced-statefulset v0.0.0-20191106043045-45c7bf25c7a8 h1:xINjJDlH682ktifMcT/PYC3zOFD1cFTAL3yL7MYD4WM=
github.com/cofyc/advanced-statefulset v0.0.0-20191106043045-45c7bf25c7a8/go.mod h1:p4XGgNi/AWGxWm9S4VorW0xQtVOfd2YXOMTeHouE7FU=
github.com/container-storage-interface/spec v1.1.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
github.com/containerd/console v0.0.0-20170925154832-84eeaae905fa/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
github.com/containerd/containerd v1.0.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
Expand Down Expand Up @@ -650,8 +650,6 @@ github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.2.1/go.mod h1:P4AexN0a+C9tGAnUFNwDMYYZv3pjFuvmeiMyKRaNVlI=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/storageos/go-api v0.0.0-20180912212459-343b3eff91fc/go.mod h1:ZrLn+e0ZuF3Y65PNF6dIwbJPZqfmtCXxFm9ckv0agOY=
Expand Down
File renamed without changes.

0 comments on commit 5ea91d1

Please sign in to comment.