OT-CONTAINER-KIT / redis-operator

A golang based redis operator that will make/oversee Redis standalone/cluster/replication/sentinel mode setup on top of the Kubernetes.
https://ot-redis-operator.netlify.app/
Apache License 2.0
829 stars 229 forks source link

[0.6.0] Password-less Redis causes nil pointer #105

Closed anthr76 closed 3 years ago

anthr76 commented 3 years ago

Pleasant surprise.. Looks like the spec changed enough to break things. Updated the spec though things are not healthy....

---
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: Redis
metadata:
  name: authentik-redis
  namespace: networking
spec:
  redisExporter:
    enabled: true
    image: quay.io/opstree/redis-exporter:1.0
    imagePullPolicy: Always
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 100m
        memory: 128Mi
  kubernetesConfig:
    image: quay.io/opstree/redis:v6.2
    imagePullPolicy: IfNotPresent
    resources:
      requests:
        cpu: 101m
        memory: 128Mi
      limits:
        cpu: 101m
        memory: 128Mi
    serviceType: ClusterIP
  redisConfig: {}
  storage:
    volumeClaimTemplate:
      spec:
        storageClassName: cstor-replica-pool
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 5Gi
I0630 15:42:19.565514       1 request.go:645] Throttling request took 1.001949406s, request: GET:https://10.42.0.1:443/apis/image.toolkit.fluxcd.io/v1beta1?ti
meout=32s                                                                                                                                                     
2021-06-30T15:42:20.624Z        INFO    controller-runtime.metrics      metrics server is starting to listen    {"addr": ":8080"}                             
2021-06-30T15:42:20.661Z        INFO    setup   starting manager                                                                                              
I0630 15:42:20.662695       1 leaderelection.go:243] attempting to acquire leader lease  database/6cab913b.redis.opstreelabs.in...                            
2021-06-30T15:42:20.663Z        INFO    controller-runtime.manager      starting metrics server {"path": "/metrics"}                                          
I0630 15:42:38.128211       1 leaderelection.go:253] successfully acquired lease database/6cab913b.redis.opstreelabs.in                                       
2021-06-30T15:42:38.128Z        INFO    controller-runtime.manager.controller.rediscluster      Starting EventSource    {"reconciler group": "redis.redis.opst
reelabs.in", "reconciler kind": "RedisCluster", "source": "kind source: /, Kind="}                                                                            
2021-06-30T15:42:38.128Z        INFO    controller-runtime.manager.controller.redis     Starting EventSource    {"reconciler group": "redis.redis.opstreelabs.
in", "reconciler kind": "Redis", "source": "kind source: /, Kind="}                                                                                           
2021-06-30T15:42:38.128Z        DEBUG   controller-runtime.manager.events       Normal  {"object": {"kind":"ConfigMap","namespace":"database","name":"6cab913b
.redis.opstreelabs.in","uid":"d9daf262-63e7-42fd-9b62-995964983ef1","apiVersion":"v1","resourceVersion":"43652858"}, "reason": "LeaderElection", "message": "r
edis-operator-6f7dd898d9-dmqt2_798c202a-d6ea-42d1-887e-2a55a46f3faf became leader"}                                                                           
2021-06-30T15:42:38.128Z        DEBUG   controller-runtime.manager.events       Normal  {"object": {"kind":"Lease","namespace":"database","name":"6cab913b.red
is.opstreelabs.in","uid":"4b2716af-6c7d-4b3a-9ac4-0b0a23304cc6","apiVersion":"coordination.k8s.io/v1","resourceVersion":"43652859"}, "reason": "LeaderElection
", "message": "redis-operator-6f7dd898d9-dmqt2_798c202a-d6ea-42d1-887e-2a55a46f3faf became leader"}                                                           
2021-06-30T15:42:38.228Z        INFO    controller-runtime.manager.controller.rediscluster      Starting Controller     {"reconciler group": "redis.redis.opst
reelabs.in", "reconciler kind": "RedisCluster"}                                                                                                               
2021-06-30T15:42:38.229Z        INFO    controller-runtime.manager.controller.rediscluster      Starting workers        {"reconciler group": "redis.redis.opst
reelabs.in", "reconciler kind": "RedisCluster", "worker count": 1}                                                                                            
2021-06-30T15:42:38.228Z        INFO    controller-runtime.manager.controller.redis     Starting Controller     {"reconciler group": "redis.redis.opstreelabs.
in", "reconciler kind": "Redis"}                                                                                                                              
2021-06-30T15:42:38.229Z        INFO    controller-runtime.manager.controller.redis     Starting workers        {"reconciler group": "redis.redis.opstreelabs.
in", "reconciler kind": "Redis", "worker count": 1}                                                                                                           
2021-06-30T15:42:38.230Z        INFO    controllers.Redis       Reconciling opstree redis controller    {"Request.Namespace": "infra", "Request.Name": "renova
te-redis"}                                                                                                                                                    
2021-06-30T15:42:38.237Z        INFO    controller_redis        Redis statefulset get action is failed  {"Request.StateFulSet.Namespace": "infra", "Request.St
ateFulSet.Name": "renovate-redis"}                                                                                                                            
E0630 15:42:38.238004       1 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or n
il pointer dereference)                                                                                                                                       
goroutine 331 [running]:                                                                                                                                      
k8s.io/apimachinery/pkg/util/runtime.logPanic(0x1670520, 0x23de090)                                                                                           
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/runtime/runtime.go:74 +0xa6                                                                          
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)                                                                                               
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/runtime/runtime.go:48 +0x89                                                                          
panic(0x1670520, 0x23de090)                                                                                                                                   
        /usr/local/go/src/runtime/panic.go:969 +0x1b9                                                                                                         
redis-operator/k8sutils.getEnvironmentVariables(...)                                                                                                          
        /workspace/k8sutils/statefulset.go:208                                                                                                                
redis-operator/k8sutils.generateContainerDef(0xc0003ff790, 0xe, 0xc0007994e0, 0x1a, 0xc0003ff7c4, 0xc, 0xc0007e0780, 0xc0007c6ed0, 0x22, 0xc0003ff80a, ...)   
        /workspace/k8sutils/statefulset.go:145 +0x138                                                                                                         
redis-operator/k8sutils.generateStateFulSetsDef(0xc0003ff790, 0xe, 0x0, 0x0, 0xc0003ff7a0, 0x5, 0x0, 0x0, 0x0, 0x0, ...)                                      
        /workspace/k8sutils/statefulset.go:103 +0xc7                                                                                                          
redis-operator/k8sutils.CreateOrUpdateStateFul(0xc0003ff7a0, 0x5, 0xc0003ff790, 0xe, 0x0, 0x0, 0xc0003ff7a0, 0x5, 0x0, 0x0, ...)                              
        /workspace/k8sutils/statefulset.go:49 +0x2a5                                                                                                          
redis-operator/k8sutils.CreateStandAloneRedis(0xc0003ef440, 0xc0003ef440, 0x1a4fc20)                                                                          
        /workspace/k8sutils/redis-standalone.go:40 +0x825                                                                                                     
redis-operator/controllers.(*RedisReconciler).Reconcile(0xc000624240, 0x1a2b5a0, 0xc0007dcb70, 0xc0003ff7a0, 0x5, 0xc0003ff790, 0xe, 0xc0007dcb70, 0x40a27f, 0
xc000030000, ...)                                                                                                                                             
        /workspace/controllers/redis_controller.go:58 +0x328                                                                                                  
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000271e00, 0x1a2b4e0, 0xc00058b740, 0x16c7a60, 0xc000704220)         
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.0/pkg/internal/controller/controller.go:263 +0x317                                                    
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000271e00, 0x1a2b4e0, 0xc00058b740, 0xc000178600)                 
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.0/pkg/internal/controller/controller.go:235 +0x205                                                    
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1.1(0x1a2b4e0, 0xc00058b740)
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.0/pkg/internal/controller/controller.go:198 +0x4a                                                     
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1()
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:185 +0x37                                                                               
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc000178750)
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:155 +0x5f 
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc000783f50, 0x19f4d40, 0xc0007dca80, 0xc00058b701, 0xc000242000)
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:156 +0xad 
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000178750, 0x3b9aca00, 0x0, 0x1, 0xc000242000)
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:133 +0x98 
k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext(0x1a2b4e0, 0xc00058b740, 0xc0007e0690, 0x3b9aca00, 0x0, 0x1)
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:185 +0xa6 
k8s.io/apimachinery/pkg/util/wait.UntilWithContext(0x1a2b4e0, 0xc00058b740, 0xc0007e0690, 0x3b9aca00)
        /go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/util/wait/wait.go:99 +0x57
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.7.0/pkg/internal/controller/controller.go:195 +0x4e7
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference 
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1534b98]
iamabhishek-dubey commented 3 years ago

I guess this issue persists for password less setup, I will check this