From e22cd16cbe8f2ab06f92888e37da1c42835818dd Mon Sep 17 00:00:00 2001 From: amecea Date: Fri, 8 Feb 2019 16:38:38 +0200 Subject: [PATCH] Remove unused variables with ports --- .../mysqlcluster/internal/syncer/settings.go | 20 ++++--------- .../internal/syncer/statefullset.go | 29 +++++++------------ pkg/sidecar/util/util.go | 7 ++--- pkg/util/constants/constants.go | 11 +++---- 4 files changed, 22 insertions(+), 45 deletions(-) diff --git a/pkg/controller/mysqlcluster/internal/syncer/settings.go b/pkg/controller/mysqlcluster/internal/syncer/settings.go index 162bc4a5a..0a90e1941 100644 --- a/pkg/controller/mysqlcluster/internal/syncer/settings.go +++ b/pkg/controller/mysqlcluster/internal/syncer/settings.go @@ -28,25 +28,20 @@ const ( // MysqlPort is the default mysql port. MysqlPort = constants.MysqlPort - // HelperXtrabackupPortName is name of the port on which we take backups - HelperXtrabackupPortName = "xtrabackup" - // HelperXtrabackupPort is the port on which we serve backups - HelperXtrabackupPort = constants.HelperXtrabackupPort - // OrcTopologyDir path where orc conf secret is mounted OrcTopologyDir = constants.OrcTopologyDir - // HelperServerPort represents the port on which http server will run - HelperServerPort = constants.HelperServerPort - // HelperServerProbePath the probe path - HelperServerProbePath = constants.HelperServerProbePath + // SidecarServerPortName name of the port + SidecarServerPortName = "xtrabackup" + // SidecarServerPort represents the port on which http server will run + SidecarServerPort = constants.SidecarServerPort + // SidecarServerProbePath the probe path + SidecarServerProbePath = constants.SidecarServerProbePath // ExporterPort is the port that metrics will be exported ExporterPort = constants.ExporterPort - //ExporterPortName the name of the metrics exporter port ExporterPortName = "prometheus" - // ExporterPath is the path on which metrics are expose ExporterPath = constants.ExporterPath @@ -56,13 +51,10 @@ const ( // ConfVolumeMountPath is the path where mysql configs will be mounted ConfVolumeMountPath = constants.ConfVolumeMountPath - // DataVolumeMountPath is the path to mysql data DataVolumeMountPath = constants.DataVolumeMountPath - // ConfMapVolumeMountPath represents the temp config mount path in init containers ConfMapVolumeMountPath = constants.ConfMapVolumeMountPath - // ConfDPath is the path to extra mysql configs dir ConfDPath = constants.ConfDPath ) diff --git a/pkg/controller/mysqlcluster/internal/syncer/statefullset.go b/pkg/controller/mysqlcluster/internal/syncer/statefullset.go index d1f41e8d8..e987fb92b 100644 --- a/pkg/controller/mysqlcluster/internal/syncer/statefullset.go +++ b/pkg/controller/mysqlcluster/internal/syncer/statefullset.go @@ -85,14 +85,6 @@ func NewStatefulSetSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysq func (s *sfsSyncer) SyncFn(in runtime.Object) error { out := in.(*apps.StatefulSet) - if out.Status.ReadyReplicas == *s.cluster.Spec.Replicas { - s.cluster.UpdateStatusCondition(api.ClusterConditionReady, - core.ConditionTrue, "statefulset ready", "Cluster is ready.") - } else { - s.cluster.UpdateStatusCondition(api.ClusterConditionReady, - core.ConditionFalse, "statefulset not ready", "Cluster is not ready.") - } - s.cluster.Status.ReadyNodes = int(out.Status.ReadyReplicas) out.Spec.Replicas = s.cluster.Spec.Replicas @@ -356,21 +348,20 @@ func (s *sfsSyncer) ensureContainersSpec() []core.Container { }, }) - helper := s.ensureContainer(containerSidecarName, + // SIDECAR container + sidecar := s.ensureContainer(containerSidecarName, s.opt.HelperImage, []string{"config-and-serve"}, ) - helper.Ports = ensurePorts(core.ContainerPort{ - Name: HelperXtrabackupPortName, - ContainerPort: HelperXtrabackupPort, + sidecar.Ports = ensurePorts(core.ContainerPort{ + Name: SidecarServerPortName, + ContainerPort: SidecarServerPort, }) - helper.Resources = ensureResources(containerSidecarName) - - // HELPER container - helper.ReadinessProbe = ensureProbe(30, 5, 5, core.Handler{ + sidecar.Resources = ensureResources(containerSidecarName) + sidecar.ReadinessProbe = ensureProbe(30, 5, 5, core.Handler{ HTTPGet: &core.HTTPGetAction{ - Path: HelperServerProbePath, - Port: intstr.FromInt(HelperServerPort), + Path: SidecarServerProbePath, + Port: intstr.FromInt(SidecarServerPort), Scheme: core.URISchemeHTTP, }, }) @@ -417,7 +408,7 @@ func (s *sfsSyncer) ensureContainersSpec() []core.Container { containers := []core.Container{ mysql, - helper, + sidecar, exporter, heartbeat, } diff --git a/pkg/sidecar/util/util.go b/pkg/sidecar/util/util.go index 73889a2fe..9068f85d2 100644 --- a/pkg/sidecar/util/util.go +++ b/pkg/sidecar/util/util.go @@ -40,9 +40,6 @@ import ( var log = logf.Log.WithName("sidecar.util") var ( - // BackupPort is the port on which xtrabackup expose backups, 3306 - BackupPort = strconv.Itoa(constants.HelperXtrabackupPort) - // MysqlPort represents port on which mysql works MysqlPort = strconv.Itoa(constants.MysqlPort) @@ -71,9 +68,9 @@ var ( OrcTopologyDir = constants.OrcTopologyDir // ServerPort http server port - ServerPort = constants.HelperServerPort + ServerPort = constants.SidecarServerPort // ServerProbeEndpoint is the http server endpoint for probe - ServerProbeEndpoint = constants.HelperServerProbePath + ServerProbeEndpoint = constants.SidecarServerProbePath // ServerBackupEndpoint is the http server endpoint for backups ServerBackupEndpoint = "/xbackup" ) diff --git a/pkg/util/constants/constants.go b/pkg/util/constants/constants.go index e2385efac..22f2682a1 100644 --- a/pkg/util/constants/constants.go +++ b/pkg/util/constants/constants.go @@ -20,16 +20,13 @@ const ( // MysqlPort is the default mysql port. MysqlPort = 3306 - // HelperXtrabackupPort is the port on which we serve backups - HelperXtrabackupPort = 3307 - // OrcTopologyDir path where orc conf secret is mounted OrcTopologyDir = "/var/run/orc-topology" - // HelperServerPort represents the port on which http server will run - HelperServerPort = 8088 - // HelperServerProbePath the probe path - HelperServerProbePath = "/health" + // SidecarServerPort represents the port on which http server will run + SidecarServerPort = 8007 + // SidecarServerProbePath the probe path + SidecarServerProbePath = "/health" // ExporterPort is the port that metrics will be exported ExporterPort = 9125