[go: nahoru, domu]

Skip to content

Commit

Permalink
refactor: remove redis health check
Browse files Browse the repository at this point in the history
Signed-off-by: chlins <chlins.zhang@gmail.com>
  • Loading branch information
chlins committed Mar 1, 2021
1 parent 53c5fab commit ac162c6
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 208 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
cloud.google.com/go v0.58.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/alicebob/miniredis/v2 v2.14.1
github.com/go-kit/kit v0.10.0
github.com/go-logr/logr v0.3.0
github.com/go-logr/zapr v0.3.0 // indirect
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.14.1 h1:GjlbSeoJ24bzdLRs13HoMEeaRZx9kg5nHoRW7QV/nCs=
github.com/alicebob/miniredis/v2 v2.14.1/go.mod h1:uS970Sw5Gs9/iK3yBg0l9Uj9s25wXxSpQUE9EaJ/Blg=
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190726115642-cd293c93fd97/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ=
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
Expand Down Expand Up @@ -1088,8 +1084,6 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb h1:ZkM6LRnq40pR1Ox0hTHlnpkcOTuFIDQpZ1IN8rKKhX0=
github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs=
github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA=
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg=
Expand Down Expand Up @@ -1290,7 +1284,6 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
62 changes: 0 additions & 62 deletions pkg/cluster/controllers/cache/healthchecker.go

This file was deleted.

76 changes: 0 additions & 76 deletions pkg/cluster/controllers/cache/healtherchecker_test.go

This file was deleted.

58 changes: 0 additions & 58 deletions pkg/cluster/controllers/cache/readiness.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cache

import (
"context"
"errors"
"fmt"
"math/rand"

Expand All @@ -23,13 +22,6 @@ import (
// - ping redis server
// - return redis properties if redis has available.
func (rc *RedisController) Readiness(ctx context.Context, cluster *v1alpha2.HarborCluster) (*lcm.CRStatus, error) {
if checkResp, err := rc.CheckInClusterRedisHealth(ctx, cluster); err != nil {
rc.Log.Error(err, "Fail to check Redis.",
"namespace", cluster.Namespace, "name", cluster.Name, "checkResp", checkResp)

return cacheNotReadyStatus(ErrorCheckRedisHealth, err.Error()), err
}

rc.Log.Info("Redis already ready.",
"namespace", cluster.Namespace, "name", cluster.Name)

Expand Down Expand Up @@ -138,56 +130,6 @@ func (rc *RedisController) GetStatefulSetPods(name, namespace string) (*appsv1.S
return sts, pod, nil
}

// CheckInClusterRedisHealth checks in cluster redis health.
func (rc *RedisController) CheckInClusterRedisHealth(ctx context.Context, cluster *v1alpha2.HarborCluster) (*lcm.CheckResponse, error) {
secret := rc.ResourceManager.GetSecret()

password, err := rc.GetRedisPassword(secret.Name, secret.Namespace)
if err != nil {
return nil, err
}

_, sentinelPodList, err := rc.GetDeploymentPods(rc.ResourceManager.GetCacheCRName(), cluster.Namespace)
if err != nil {
rc.Log.Error(err, "Fail to get deployment pods.")

return nil, err
}

_, redisPodList, err := rc.GetStatefulSetPods(rc.ResourceManager.GetCacheCRName(), cluster.Namespace)
if err != nil {
rc.Log.Error(err, "Fail to get deployment pods.")

return nil, err
}

if len(sentinelPodList.Items) == 0 || len(redisPodList.Items) == 0 {
rc.Log.Info("pod list is empty,pls wait.")

return nil, errors.New("pod list is empty,pls wait")
}

sentinelPodArray := sentinelPodList.Items
_, currentSentinelPods := rc.GetPodsStatus(sentinelPodArray)

if len(currentSentinelPods) == 0 {
return nil, errors.New("need to requeue")
}

endpoint := rc.GetSentinelServiceURL(rc.ResourceManager.GetCacheCRName(), cluster.Namespace, currentSentinelPods)
config := &lcm.ServiceConfig{
Endpoint: &lcm.Endpoint{
Host: endpoint,
Port: RedisSentinelConnPort,
},
Credentials: &lcm.Credentials{
AccessSecret: password,
},
}

return rc.HealthChecker().CheckHealth(ctx, config, lcm.WithSentinel(true))
}

// GetPodsStatus returns deleting and current pod list.
func (rc *RedisController) GetPodsStatus(podArray []corev1.Pod) ([]corev1.Pod, []corev1.Pod) {
deletingPods := make([]corev1.Pod, 0)
Expand Down
4 changes: 0 additions & 4 deletions pkg/cluster/controllers/cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ type RedisController struct {
expectCR, actualCR runtime.Object
}

func (rc *RedisController) HealthChecker() lcm.HealthChecker {
return &RedisHealthChecker{}
}

// Apply creates/updates/scales the resources, like kubernetes apply operation.
func (rc *RedisController) Apply(ctx context.Context, cluster *goharborv1alpha2.HarborCluster) (*lcm.CRStatus, error) {
rc.DClient.WithContext(ctx)
Expand Down

0 comments on commit ac162c6

Please sign in to comment.