Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-9970

Cluster CAPI operator webhook for Cluster object panics with empty spec

    XMLWordPrintable

Details

    • No
    • CLOUD Sprint 233, CLOUD Sprint 234, CLOUD Sprint 235, CLOUD Sprint 236, CLOUD Sprint 237
    • 5
    • False
    • Hide

      None

      Show
      None

    Description

      Description of problem:

      InfraStructureRef* is dereferenced without checking for nil value

      Version-Release number of selected component (if applicable):

       

      How reproducible:

      Always

      Steps to Reproduce:

      1. Run TechPreview cluster
      2. Try to create Cluster object with empty spec
      apiVersion: cluster.x-k8s.io/v1beta1
      kind: Cluster
      metadata:
        name: example
        namespace: openshift-cluster-api
      spec: {}
       3. Observe panic in cluster-capi-operator
      

      Actual results:

      2023/03/10 14:13:31 http: panic serving 10.129.0.2:39614: runtime error: invalid memory address or nil pointer dereference
      goroutine 3619 [running]:
      net/http.(*conn).serve.func1()
          /usr/lib/golang/src/net/http/server.go:1850 +0xbf
      panic({0x16cada0, 0x2948bc0})
          /usr/lib/golang/src/runtime/panic.go:890 +0x262
      github.com/openshift/cluster-capi-operator/pkg/webhook.(*ClusterWebhook).ValidateCreate(0xc000ceac00?, {0x24?, 0xc00090fff0?}, {0x1b72d68?, 0xc0010831e0?})
          /go/src/github.com/openshift/cluster-capi-operator/pkg/webhook/cluster.go:32 +0x39
      sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*validatorForType).Handle(_, {_, _}, {{{0xc000ceac00, 0x24}, {{0xc00090fff0, 0x10}, {0xc000838000, 0x7}, {0xc000838007, ...}}, ...}})
          /go/src/github.com/openshift/cluster-capi-operator/vendor/sigs.k8s.io/controller-runtime/pkg/webhook/admission/validator_custom.go:79 +0x2dd
      sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Webhook).Handle(_, {_, _}, {{{0xc000ceac00, 0x24}, {{0xc00090fff0, 0x10}, {0xc000838000, 0x7}, {0xc000838007, ...}}, ...}})
          /go/src/github.com/openshift/cluster-capi-operator/vendor/sigs.k8s.io/controller-runtime/pkg/webhook/admission/webhook.go:169 +0xfd
      sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Webhook).ServeHTTP(0xc000630e80, {0x7f26f94b5580?, 0xc000f80280}, 0xc000750800)
          /go/src/github.com/openshift/cluster-capi-operator/vendor/sigs.k8s.io/controller-runtime/pkg/webhook/admission/http.go:98 +0xeb5
      github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerInFlight.func1({0x7f26f94b5580, 0xc000f80280}, 0x1b7ff00?)
          /go/src/github.com/openshift/cluster-capi-operator/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go:60 +0xd4
      net/http.HandlerFunc.ServeHTTP(0x1b7ffb0?, {0x7f26f94b5580?, 0xc000f80280?}, 0x7afe60?)
          /usr/lib/golang/src/net/http/server.go:2109 +0x2f
      github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerCounter.func1({0x1b7ffb0?, 0xc000a72000?}, 0xc000750800)
          /go/src/github.com/openshift/cluster-capi-operator/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go:146 +0xb8
      net/http.HandlerFunc.ServeHTTP(0x0?, {0x1b7ffb0?, 0xc000a72000?}, 0xc00056f0e1?)
          /usr/lib/golang/src/net/http/server.go:2109 +0x2f
      github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerDuration.func2({0x1b7ffb0, 0xc000a72000}, 0xc000750800)
          /go/src/github.com/openshift/cluster-capi-operator/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go:108 +0xbf
      net/http.HandlerFunc.ServeHTTP(0xc000a72000?, {0x1b7ffb0?, 0xc000a72000?}, 0x18e45d1?)
          /usr/lib/golang/src/net/http/server.go:2109 +0x2f
      net/http.(*ServeMux).ServeHTTP(0xc00056f0c0?, {0x1b7ffb0, 0xc000a72000}, 0xc000750800)
          /usr/lib/golang/src/net/http/server.go:2487 +0x149
      net/http.serverHandler.ServeHTTP({0x1b71dc8?}, {0x1b7ffb0, 0xc000a72000}, 0xc000750800)
          /usr/lib/golang/src/net/http/server.go:2947 +0x30c
      net/http.(*conn).serve(0xc00039af00, {0x1b81198, 0xc000416c00})
          /usr/lib/golang/src/net/http/server.go:1991 +0x607
      created by net/http.(*Server).Serve
          /usr/lib/golang/src/net/http/server.go:3102 +0x4db

      Expected results:

      Webhook returns error, but does not panic

      Additional info:

       

      Attachments

        Issue Links

          Activity

            People

              rmanak@redhat.com Radek Manak
              rmanak@redhat.com Radek Manak
              Zhaohua Sun Zhaohua Sun
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: