From cd1a31af7b36b856b18b76f75c02528cc2fc096d Mon Sep 17 00:00:00 2001 From: craig Date: Mon, 11 Mar 2024 09:59:02 +0000 Subject: [PATCH 1/3] remove health checker --- PROJECT | 9 - api/v1alpha1/dnshealthcheckprobe_types.go | 88 ------ api/v1alpha1/health_types.go | 56 ---- api/v1alpha1/zz_generated.deepcopy.go | 160 ---------- cmd/main.go | 25 +- .../kuadrant.io_dnshealthcheckprobes.yaml | 99 ------ config/crd/kustomization.yaml | 3 - .../cainjection_in_dnshealthcheckprobes.yaml | 7 - .../webhook_in_dnshealthcheckprobes.yaml | 16 - .../dns-operator.clusterserviceversion.yaml | 71 +++-- .../rbac/dnshealthcheckprobe_editor_role.yaml | 31 -- .../rbac/dnshealthcheckprobe_viewer_role.yaml | 27 -- config/rbac/role.yaml | 28 -- ...drant.io_v1alpha1_dnshealthcheckprobe.yaml | 12 - .../dnshealthcheckprobe_controller.go | 289 ------------------ .../dnsheathcheckprobe_controller_test.go | 98 ------ internal/controller/suite_test.go | 23 -- internal/health/metrics.go | 61 ---- internal/health/monitor.go | 96 ------ internal/health/notifier.go | 67 ---- internal/health/probeQueuer.go | 92 ------ internal/health/queuedProbeWorker.go | 217 ------------- 22 files changed, 36 insertions(+), 1539 deletions(-) delete mode 100644 api/v1alpha1/dnshealthcheckprobe_types.go delete mode 100644 api/v1alpha1/health_types.go delete mode 100644 config/crd/bases/kuadrant.io_dnshealthcheckprobes.yaml delete mode 100644 config/crd/patches/cainjection_in_dnshealthcheckprobes.yaml delete mode 100644 config/crd/patches/webhook_in_dnshealthcheckprobes.yaml delete mode 100644 config/rbac/dnshealthcheckprobe_editor_role.yaml delete mode 100644 config/rbac/dnshealthcheckprobe_viewer_role.yaml delete mode 100644 config/samples/kuadrant.io_v1alpha1_dnshealthcheckprobe.yaml delete mode 100644 internal/controller/dnshealthcheckprobe_controller.go delete mode 100644 internal/controller/dnsheathcheckprobe_controller_test.go delete mode 100644 internal/health/metrics.go delete mode 100644 internal/health/monitor.go delete mode 100644 internal/health/notifier.go delete mode 100644 internal/health/probeQueuer.go delete mode 100644 internal/health/queuedProbeWorker.go diff --git a/PROJECT b/PROJECT index 0f06754b..e634e8f5 100644 --- a/PROJECT +++ b/PROJECT @@ -27,12 +27,3 @@ resources: kind: DNSRecord path: github.com/kuadrant/dns-operator/api/v1alpha1 version: v1alpha1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: kuadrant.io - kind: DNSHealthCheckProbe - path: github.com/kuadrant/dns-operator/api/v1alpha1 - version: v1alpha1 -version: "3" diff --git a/api/v1alpha1/dnshealthcheckprobe_types.go b/api/v1alpha1/dnshealthcheckprobe_types.go deleted file mode 100644 index 4ad14631..00000000 --- a/api/v1alpha1/dnshealthcheckprobe_types.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2024. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// DNSHealthCheckProbeSpec defines the desired state of DNSHealthCheckProbe -type DNSHealthCheckProbeSpec struct { - Port int `json:"port,omitempty"` - Host string `json:"host,omitempty"` - Address string `json:"address,omitempty"` - Path string `json:"path,omitempty"` - Protocol HealthProtocol `json:"protocol,omitempty"` - Interval metav1.Duration `json:"interval,omitempty"` - AdditionalHeadersRef *AdditionalHeadersRef `json:"additionalHeadersRef,omitempty"` - FailureThreshold *int `json:"failureThreshold,omitempty"` - ExpectedResponses []int `json:"expectedResponses,omitempty"` - AllowInsecureCertificate bool `json:"allowInsecureCertificate,omitempty"` -} - -type AdditionalHeadersRef struct { - Name string `json:"name"` -} - -type AdditionalHeaders []AdditionalHeader - -type AdditionalHeader struct { - Name string `json:"name"` - Value string `json:"value"` -} - -// DNSHealthCheckProbeStatus defines the observed state of DNSHealthCheckProbe -type DNSHealthCheckProbeStatus struct { - LastCheckedAt metav1.Time `json:"lastCheckedAt"` - ConsecutiveFailures int `json:"consecutiveFailures,omitempty"` - Reason string `json:"reason,omitempty"` - Status int `json:"status,omitempty"` - Healthy *bool `json:"healthy"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:printcolumn:name="Healthy",type="boolean",JSONPath=".status.healthy",description="DNSHealthCheckProbe healthy." -//+kubebuilder:printcolumn:name="Last Checked",type="date",JSONPath=".status.lastCheckedAt",description="Last checked at." - -// DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes API -type DNSHealthCheckProbe struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec DNSHealthCheckProbeSpec `json:"spec,omitempty"` - Status DNSHealthCheckProbeStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// DNSHealthCheckProbeList contains a list of DNSHealthCheckProbe -type DNSHealthCheckProbeList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []DNSHealthCheckProbe `json:"items"` -} - -func (p *DNSHealthCheckProbe) Default() { - if p.Spec.Protocol == "" { - p.Spec.Protocol = HttpProtocol - } -} - -func init() { - SchemeBuilder.Register(&DNSHealthCheckProbe{}, &DNSHealthCheckProbeList{}) -} diff --git a/api/v1alpha1/health_types.go b/api/v1alpha1/health_types.go deleted file mode 100644 index 0ffbd080..00000000 --- a/api/v1alpha1/health_types.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2024. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import "strings" - -// HealthProtocol represents the protocol to use when making a health check request -type HealthProtocol string - -const ( - HttpProtocol HealthProtocol = "HTTP" - HttpsProtocol HealthProtocol = "HTTPS" -) - -func NewHealthProtocol(p string) HealthProtocol { - switch strings.ToUpper(p) { - case "HTTPS": - return HttpsProtocol - case "HTTP": - return HttpProtocol - } - return HttpProtocol -} - -func (p HealthProtocol) ToScheme() string { - switch p { - case HttpProtocol: - return "http" - case HttpsProtocol: - return "https" - default: - return "http" - } -} - -func (p HealthProtocol) IsHttp() bool { - return p == HttpProtocol -} - -func (p HealthProtocol) IsHttps() bool { - return p == HttpsProtocol -} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 9b68c431..298cd8e3 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -27,166 +27,6 @@ import ( "sigs.k8s.io/external-dns/endpoint" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdditionalHeader) DeepCopyInto(out *AdditionalHeader) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdditionalHeader. -func (in *AdditionalHeader) DeepCopy() *AdditionalHeader { - if in == nil { - return nil - } - out := new(AdditionalHeader) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in AdditionalHeaders) DeepCopyInto(out *AdditionalHeaders) { - { - in := &in - *out = make(AdditionalHeaders, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdditionalHeaders. -func (in AdditionalHeaders) DeepCopy() AdditionalHeaders { - if in == nil { - return nil - } - out := new(AdditionalHeaders) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdditionalHeadersRef) DeepCopyInto(out *AdditionalHeadersRef) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdditionalHeadersRef. -func (in *AdditionalHeadersRef) DeepCopy() *AdditionalHeadersRef { - if in == nil { - return nil - } - out := new(AdditionalHeadersRef) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSHealthCheckProbe) DeepCopyInto(out *DNSHealthCheckProbe) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSHealthCheckProbe. -func (in *DNSHealthCheckProbe) DeepCopy() *DNSHealthCheckProbe { - if in == nil { - return nil - } - out := new(DNSHealthCheckProbe) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DNSHealthCheckProbe) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSHealthCheckProbeList) DeepCopyInto(out *DNSHealthCheckProbeList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]DNSHealthCheckProbe, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSHealthCheckProbeList. -func (in *DNSHealthCheckProbeList) DeepCopy() *DNSHealthCheckProbeList { - if in == nil { - return nil - } - out := new(DNSHealthCheckProbeList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DNSHealthCheckProbeList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSHealthCheckProbeSpec) DeepCopyInto(out *DNSHealthCheckProbeSpec) { - *out = *in - out.Interval = in.Interval - if in.AdditionalHeadersRef != nil { - in, out := &in.AdditionalHeadersRef, &out.AdditionalHeadersRef - *out = new(AdditionalHeadersRef) - **out = **in - } - if in.FailureThreshold != nil { - in, out := &in.FailureThreshold, &out.FailureThreshold - *out = new(int) - **out = **in - } - if in.ExpectedResponses != nil { - in, out := &in.ExpectedResponses, &out.ExpectedResponses - *out = make([]int, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSHealthCheckProbeSpec. -func (in *DNSHealthCheckProbeSpec) DeepCopy() *DNSHealthCheckProbeSpec { - if in == nil { - return nil - } - out := new(DNSHealthCheckProbeSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSHealthCheckProbeStatus) DeepCopyInto(out *DNSHealthCheckProbeStatus) { - *out = *in - in.LastCheckedAt.DeepCopyInto(&out.LastCheckedAt) - if in.Healthy != nil { - in, out := &in.Healthy, &out.Healthy - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSHealthCheckProbeStatus. -func (in *DNSHealthCheckProbeStatus) DeepCopy() *DNSHealthCheckProbeStatus { - if in == nil { - return nil - } - out := new(DNSHealthCheckProbeStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DNSRecord) DeepCopyInto(out *DNSRecord) { *out = *in diff --git a/cmd/main.go b/cmd/main.go index 84db7409..208ed3bf 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -19,7 +19,6 @@ package main import ( "flag" "os" - "time" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -33,7 +32,6 @@ import ( "github.com/kuadrant/dns-operator/api/v1alpha1" "github.com/kuadrant/dns-operator/internal/controller" - "github.com/kuadrant/dns-operator/internal/health" "github.com/kuadrant/dns-operator/internal/provider" _ "github.com/kuadrant/dns-operator/internal/provider/aws" _ "github.com/kuadrant/dns-operator/internal/provider/google" @@ -84,19 +82,6 @@ func main() { providerFactory := provider.NewFactory(mgr.GetClient()) - healthMonitor := health.NewMonitor() - healthCheckQueue := health.NewRequestQueue(time.Second * 5) - - if err := mgr.Add(healthMonitor); err != nil { - setupLog.Error(err, "unable to start health monitor") - os.Exit(1) - } - - if err := mgr.Add(healthCheckQueue); err != nil { - setupLog.Error(err, "unable to start health check queue") - os.Exit(1) - } - if err = (&controller.ManagedZoneReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -113,15 +98,7 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "DNSRecord") os.Exit(1) } - if err = (&controller.DNSHealthCheckProbeReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - HealthMonitor: healthMonitor, - Queue: healthCheckQueue, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "DNSHealthCheckProbe") - os.Exit(1) - } + //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { diff --git a/config/crd/bases/kuadrant.io_dnshealthcheckprobes.yaml b/config/crd/bases/kuadrant.io_dnshealthcheckprobes.yaml deleted file mode 100644 index d98bd1ac..00000000 --- a/config/crd/bases/kuadrant.io_dnshealthcheckprobes.yaml +++ /dev/null @@ -1,99 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - name: dnshealthcheckprobes.kuadrant.io -spec: - group: kuadrant.io - names: - kind: DNSHealthCheckProbe - listKind: DNSHealthCheckProbeList - plural: dnshealthcheckprobes - singular: dnshealthcheckprobe - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: DNSHealthCheckProbe healthy. - jsonPath: .status.healthy - name: Healthy - type: boolean - - description: Last checked at. - jsonPath: .status.lastCheckedAt - name: Last Checked - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes - API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: DNSHealthCheckProbeSpec defines the desired state of DNSHealthCheckProbe - properties: - additionalHeadersRef: - properties: - name: - type: string - required: - - name - type: object - address: - type: string - allowInsecureCertificate: - type: boolean - expectedResponses: - items: - type: integer - type: array - failureThreshold: - type: integer - host: - type: string - interval: - type: string - path: - type: string - port: - type: integer - protocol: - description: HealthProtocol represents the protocol to use when making - a health check request - type: string - type: object - status: - description: DNSHealthCheckProbeStatus defines the observed state of DNSHealthCheckProbe - properties: - consecutiveFailures: - type: integer - healthy: - type: boolean - lastCheckedAt: - format: date-time - type: string - reason: - type: string - status: - type: integer - required: - - healthy - - lastCheckedAt - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index a8592adc..a9ea4a8b 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -4,7 +4,6 @@ resources: - bases/kuadrant.io_managedzones.yaml - bases/kuadrant.io_dnsrecords.yaml -- bases/kuadrant.io_dnshealthcheckprobes.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: @@ -12,14 +11,12 @@ patches: # patches here are for enabling the conversion webhook for each CRD #- path: patches/webhook_in_managedzones.yaml #- path: patches/webhook_in_dnsrecords.yaml -#- path: patches/webhook_in_dnshealthcheckprobes.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- path: patches/cainjection_in_managedzones.yaml #- path: patches/cainjection_in_dnsrecords.yaml -#- path: patches/cainjection_in_dnshealthcheckprobes.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_dnshealthcheckprobes.yaml b/config/crd/patches/cainjection_in_dnshealthcheckprobes.yaml deleted file mode 100644 index 4ee5ce08..00000000 --- a/config/crd/patches/cainjection_in_dnshealthcheckprobes.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: dnshealthcheckprobes.kuadrant.io diff --git a/config/crd/patches/webhook_in_dnshealthcheckprobes.yaml b/config/crd/patches/webhook_in_dnshealthcheckprobes.yaml deleted file mode 100644 index 34e60bad..00000000 --- a/config/crd/patches/webhook_in_dnshealthcheckprobes.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: dnshealthcheckprobes.kuadrant.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/config/manifests/bases/dns-operator.clusterserviceversion.yaml b/config/manifests/bases/dns-operator.clusterserviceversion.yaml index a3faa12b..3cd8af05 100644 --- a/config/manifests/bases/dns-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/dns-operator.clusterserviceversion.yaml @@ -15,53 +15,52 @@ spec: apiservicedefinitions: {} customresourcedefinitions: owned: - - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes - API - displayName: DNSHealth Check Probe - kind: DNSHealthCheckProbe - name: dnshealthcheckprobes.kuadrant.io - version: v1alpha1 - - description: DNSRecord is the Schema for the dnsrecords API - displayName: DNSRecord - kind: DNSRecord - name: dnsrecords.kuadrant.io - version: v1alpha1 - - description: ManagedZone is the Schema for the managedzones API - displayName: Managed Zone - kind: ManagedZone - name: managedzones.kuadrant.io - version: v1alpha1 + - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes API + displayName: DNSHealth Check Probe + kind: DNSHealthCheckProbe + name: dnshealthcheckprobes.kuadrant.io + version: v1alpha1 + - description: DNSRecord is the Schema for the dnsrecords API + displayName: DNSRecord + kind: DNSRecord + name: dnsrecords.kuadrant.io + version: v1alpha1 + - description: ManagedZone is the Schema for the managedzones API + displayName: Managed Zone + kind: ManagedZone + name: managedzones.kuadrant.io + version: v1alpha1 description: A Kubernetes Operator to manage the lifecycle of DNS resources displayName: DNS Operator icon: - - base64data: iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAHCklEQVR4nOzc72tWdQPH8e+tm/ecXGNO77mb3beZLgtkDxpCgT4IBBFqJT1YRqFS5oMS/BG5ioqhUc3IFKwHpqHSg9qDsCwIQeiBQoEotISyzcwa6bI5Nlyms8X4Lp1u1zzXub6f8/2ea+/XH3DO58GbXeec69opGhgYMIBrE3wPQGEiLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxIEBYkCAsShAUJwoIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxIEBYkCAsShAUJwoIEYUGCsCBR5HtAJI89uqytvT2fI2zetHnx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CsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxIEBYkCAsShAUJwoIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxI/B0AAP//uLJ9vDn6iowAAAAASUVORK5CYII= + mediatype: image/png install: spec: deployments: null strategy: "" installModes: - - supported: false - type: OwnNamespace - - supported: false - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces + - supported: false + type: OwnNamespace + - supported: false + type: SingleNamespace + - supported: false + type: MultiNamespace + - supported: true + type: AllNamespaces keywords: - - dns - - kuadrant + - dns + - kuadrant links: - - name: DNS Operator - url: https://github.com/Kuadrant/dns-operator + - name: DNS Operator + url: https://github.com/Kuadrant/dns-operator maintainers: - - email: mnairn@redhat.com - name: Michael Nairn - - email: pbrookes@redhat.com - name: Phil Brookes - - email: cbrookes@redhat.com - name: Craig Brookes + - email: mnairn@redhat.com + name: Michael Nairn + - email: pbrookes@redhat.com + name: Phil Brookes + - email: cbrookes@redhat.com + name: Craig Brookes maturity: alpha minKubeVersion: 1.8.0 provider: diff --git a/config/rbac/dnshealthcheckprobe_editor_role.yaml b/config/rbac/dnshealthcheckprobe_editor_role.yaml deleted file mode 100644 index 1e94c606..00000000 --- a/config/rbac/dnshealthcheckprobe_editor_role.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# permissions for end users to edit dnshealthcheckprobes. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: dnshealthcheckprobe-editor-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: dns-operator - app.kubernetes.io/part-of: dns-operator - app.kubernetes.io/managed-by: kustomize - name: dnshealthcheckprobe-editor-role -rules: -- apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes/status - verbs: - - get diff --git a/config/rbac/dnshealthcheckprobe_viewer_role.yaml b/config/rbac/dnshealthcheckprobe_viewer_role.yaml deleted file mode 100644 index 2be79c67..00000000 --- a/config/rbac/dnshealthcheckprobe_viewer_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to view dnshealthcheckprobes. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: dnshealthcheckprobe-viewer-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: dns-operator - app.kubernetes.io/part-of: dns-operator - app.kubernetes.io/managed-by: kustomize - name: dnshealthcheckprobe-viewer-role -rules: -- apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes - verbs: - - get - - list - - watch -- apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes/status - verbs: - - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 93144d85..1653add9 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -12,34 +12,6 @@ rules: - get - list - watch -- apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes/finalizers - verbs: - - get - - patch - - update -- apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes/status - verbs: - - get - - patch - - update - apiGroups: - kuadrant.io resources: diff --git a/config/samples/kuadrant.io_v1alpha1_dnshealthcheckprobe.yaml b/config/samples/kuadrant.io_v1alpha1_dnshealthcheckprobe.yaml deleted file mode 100644 index f15c1591..00000000 --- a/config/samples/kuadrant.io_v1alpha1_dnshealthcheckprobe.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kuadrant.io/v1alpha1 -kind: DNSHealthCheckProbe -metadata: - labels: - app.kubernetes.io/name: dnshealthcheckprobe - app.kubernetes.io/instance: dnshealthcheckprobe-sample - app.kubernetes.io/part-of: dns-operator - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: dns-operator - name: dnshealthcheckprobe-sample -spec: - # TODO(user): Add fields here diff --git a/internal/controller/dnshealthcheckprobe_controller.go b/internal/controller/dnshealthcheckprobe_controller.go deleted file mode 100644 index 8fd92def..00000000 --- a/internal/controller/dnshealthcheckprobe_controller.go +++ /dev/null @@ -1,289 +0,0 @@ -package controller - -import ( - "context" - "fmt" - "strings" - - "github.com/go-logr/logr" - - v1 "k8s.io/api/core/v1" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "sigs.k8s.io/controller-runtime/pkg/log" - gatewayapiv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" - - "github.com/kuadrant/dns-operator/api/v1alpha1" - "github.com/kuadrant/dns-operator/internal/common/slice" - "github.com/kuadrant/dns-operator/internal/health" -) - -//ToDO This should not require sigs.k8s.io/gateway-api/apis/v1 - -const ( - DNSHealthCheckProbeFinalizer = "kuadrant.io/dns-health-check-probe" -) - -var ( - ErrInvalidHeader = fmt.Errorf("invalid header format") -) - -type DNSHealthCheckProbeReconciler struct { - client.Client - Scheme *runtime.Scheme - HealthMonitor *health.Monitor - Queue *health.QueuedProbeWorker -} - -// +kubebuilder:rbac:groups=kuadrant.io,resources=dnshealthcheckprobes,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=kuadrant.io,resources=dnshealthcheckprobes/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=kuadrant.io,resources=dnshealthcheckprobes/finalizers,verbs=get;update;patch - -func (r *DNSHealthCheckProbeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - logger := log.FromContext(ctx) - - previous := &v1alpha1.DNSHealthCheckProbe{} - err := r.Client.Get(ctx, req.NamespacedName, previous) - if err != nil { - if err := client.IgnoreNotFound(err); err != nil { - return ctrl.Result{}, nil - } else { - return ctrl.Result{}, err - } - } - - logger.V(3).Info("DNSHealthCheckProbeReconciler Reconcile", "dnsHealthCheckProbe", previous) - - probeObj := previous.DeepCopy() - - if probeObj.DeletionTimestamp != nil && !probeObj.DeletionTimestamp.IsZero() { - logger.Info("deleting probe", "probe", probeObj) - - r.deleteProbe(probeObj) - controllerutil.RemoveFinalizer(probeObj, DNSHealthCheckProbeFinalizer) - - if err := r.Update(ctx, probeObj); err != nil { - return ctrl.Result{}, err - } - - return ctrl.Result{}, nil - } - - if !controllerutil.ContainsFinalizer(probeObj, DNSHealthCheckProbeFinalizer) { - controllerutil.AddFinalizer(probeObj, DNSHealthCheckProbeFinalizer) - if err := r.Update(ctx, probeObj); err != nil { - return ctrl.Result{}, err - } - } - - // Set the interval - interval := probeObj.Spec.Interval.Duration - - // Set the protocol: default to HTTP is not defined - protocol := probeObj.Spec.Protocol - if protocol == "" { - protocol = v1alpha1.HttpProtocol - } - - protocol = v1alpha1.NewHealthProtocol(string(probeObj.Spec.Protocol)) - - probeId := probeId(probeObj) - - additionalHeaders, err := getAdditionalHeaders(ctx, r.Client, probeObj) - - if err != nil { - f := false - logger.V(1).Info( - "error getting additional headers for probe", - "secret name", probeObj.Spec.AdditionalHeadersRef.Name, - "error", err) - //update probe status - probeObj.Status.Healthy = &f - probeObj.Status.LastCheckedAt = metav1.Now() - updateErr := r.Client.Status().Update(ctx, probeObj) - if updateErr != nil { - logger.V(1).Info("error updating probe status", "error", updateErr) - } - return ctrl.Result{}, err - } - - if r.HealthMonitor.HasProbe(probeId) { - r.HealthMonitor.UpdateProbe(probeId, func(p *health.ProbeQueuer) { - p.Interval = interval - p.Host = probeObj.Spec.Host - p.IPAddress = probeObj.Spec.Address - p.Path = probeObj.Spec.Path - p.Port = probeObj.Spec.Port - p.Protocol = protocol - p.AdditionalHeaders = additionalHeaders - p.ExpectedResponses = probeObj.Spec.ExpectedResponses - p.AllowInsecureCertificate = probeObj.Spec.AllowInsecureCertificate - }) - } else { - notifier, err := r.newProbeNotifierFor(ctx, logger, previous) - if err != nil { - return ctrl.Result{}, err - } - - r.HealthMonitor.AddProbeQueuer(&health.ProbeQueuer{ - ID: probeId, - Interval: interval, - Host: probeObj.Spec.Host, - Path: probeObj.Spec.Path, - Port: probeObj.Spec.Port, - Protocol: protocol, - IPAddress: probeObj.Spec.Address, - AdditionalHeaders: additionalHeaders, - ExpectedResponses: probeObj.Spec.ExpectedResponses, - AllowInsecureCertificate: probeObj.Spec.AllowInsecureCertificate, - Notifier: notifier, - Queue: r.Queue, - }) - } - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the manager -func (r *DNSHealthCheckProbeReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.DNSHealthCheckProbe{}). - Complete(r) -} - -func (r *DNSHealthCheckProbeReconciler) deleteProbe(probeObj *v1alpha1.DNSHealthCheckProbe) { - r.HealthMonitor.RemoveProbe(probeId(probeObj)) -} - -func probeId(probeObj *v1alpha1.DNSHealthCheckProbe) string { - return fmt.Sprintf("%s/%s", probeObj.Namespace, probeObj.Name) -} - -func getAdditionalHeaders(ctx context.Context, clt client.Client, probeObj *v1alpha1.DNSHealthCheckProbe) (v1alpha1.AdditionalHeaders, error) { - additionalHeaders := v1alpha1.AdditionalHeaders{} - - if probeObj.Spec.AdditionalHeadersRef != nil { - secretKey := client.ObjectKey{Name: probeObj.Spec.AdditionalHeadersRef.Name, Namespace: probeObj.Namespace} - additionalHeadersSecret := &v1.Secret{} - if err := clt.Get(ctx, secretKey, additionalHeadersSecret); client.IgnoreNotFound(err) != nil { - return additionalHeaders, fmt.Errorf("error retrieving additional headers secret %v/%v: %w", secretKey.Namespace, secretKey.Name, err) - } else if err != nil { - probeError := fmt.Errorf("error retrieving additional headers secret %v/%v: %w", secretKey.Namespace, secretKey.Name, err) - probeObj.Status.ConsecutiveFailures = 0 - probeObj.Status.Reason = fmt.Sprintf("additional headers secret '%v' not found", secretKey.Name) - return additionalHeaders, probeError - } - for k, v := range additionalHeadersSecret.Data { - if strings.ContainsAny(strings.TrimSpace(k), " \t") { - probeObj.Status.ConsecutiveFailures = 0 - probeObj.Status.Reason = "invalid header found: " + k - return nil, fmt.Errorf("invalid header, must not contain whitespace '%v': %w", k, ErrInvalidHeader) - } - additionalHeaders = append(additionalHeaders, v1alpha1.AdditionalHeader{ - Name: strings.TrimSpace(k), - Value: string(v), - }) - } - } - return additionalHeaders, nil -} - -func (r *DNSHealthCheckProbeReconciler) getGatewayFor(ctx context.Context, probe *v1alpha1.DNSHealthCheckProbe) (*gatewayapiv1beta1.Gateway, bool, error) { - if probe.Labels == nil { - return nil, false, nil - } - - name, nameOk := probe.Labels["kuadrant.io/gateway"] - namespace, namespaceOk := probe.Labels["kuadrant.io/gateway-namespace"] - - if !nameOk || !namespaceOk { - return nil, false, nil - } - - objKey := client.ObjectKey{ - Name: name, - Namespace: namespace, - } - - gw := &gatewayapiv1beta1.Gateway{} - if err := r.Client.Get(ctx, objKey, gw); err != nil { - return nil, false, err - } - - return gw, true, nil -} - -func (r *DNSHealthCheckProbeReconciler) newProbeNotifierFor(ctx context.Context, logger logr.Logger, probe *v1alpha1.DNSHealthCheckProbe) (health.ProbeNotifier, error) { - // Base notifier to update the probe CR - notifier := health.NewStatusUpdateProbeNotifier(r.Client, probe) - - // Try to find the associated Gateway, if not fount, return the base - // notifier - gateway, ok, err := r.getGatewayFor(ctx, probe) - if err != nil { - return nil, err - } - if !ok { - logger.V(3).Info("no gateway associated to probe. Creating status update notifier") - return notifier, nil - } - - // Try to find the associated DNSRecord, if not found, return the base - // notifier - dnsRecord, ok, err := getDNSRecord(ctx, r.Client, probe) - if err != nil { - return nil, err - } - if !ok { - logger.V(3).Info("no DNSRecord associated to probe. Creating status update notifier") - return notifier, nil - } - - // Find the listener in the Gateway that matches the DNSRecord - listener, ok := slice.Find(gateway.Spec.Listeners, func(listener gatewayapiv1beta1.Listener) bool { - dnsRecordName := fmt.Sprintf("%s-%s", gateway.Name, listener.Name) - return dnsRecord.Name == dnsRecordName - }) - if !ok { - return notifier, nil - } - - logger.V(3).Info("creating instrumented probe notifier for probe") - - // Wrap the base notifier with the instrumented one that updates metrics - return health.NewInstrumentedProbeNotifier( - gateway.Name, gateway.Namespace, string(listener.Name), - notifier, - ), nil -} - -func getDNSRecord(ctx context.Context, apiClient client.Client, obj metav1.Object) (*v1alpha1.DNSRecord, bool, error) { - if obj.GetAnnotations() == nil { - return nil, false, nil - } - - name, nameOk := obj.GetAnnotations()["dnsrecord-name"] - ns, nsOk := obj.GetAnnotations()["dnsrecord-namespace"] - - if !nameOk || !nsOk { - return nil, false, nil - } - - dnsRecord := &v1alpha1.DNSRecord{} - if err := apiClient.Get(ctx, client.ObjectKey{ - Name: name, - Namespace: ns, - }, dnsRecord); err != nil { - if k8serrors.IsNotFound(err) { - return nil, false, nil - } - - return nil, false, err - } - - return dnsRecord, true, nil -} diff --git a/internal/controller/dnsheathcheckprobe_controller_test.go b/internal/controller/dnsheathcheckprobe_controller_test.go deleted file mode 100644 index 4a4e9438..00000000 --- a/internal/controller/dnsheathcheckprobe_controller_test.go +++ /dev/null @@ -1,98 +0,0 @@ -//go:build integration - -package controller - -import ( - "context" - "fmt" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/kuadrant/dns-operator/api/v1alpha1" -) - -var _ = Describe("DNSHealthCheckProbe controller", func() { - const ( - ProbeName = "test-probe" - ProbeNamespace = "default" - - timeout = time.Second * 10 - duration = time.Second * 10 - interval = time.Millisecond * 250 - ) - - Context("When creating DNSHealthCheckProbe", func() { - It("Should update health status to healthy", func() { - By("Performing health check") - - ctx := context.Background() - probeObj := &v1alpha1.DNSHealthCheckProbe{ - ObjectMeta: metav1.ObjectMeta{ - Name: ProbeName, - Namespace: ProbeNamespace, - }, - Spec: v1alpha1.DNSHealthCheckProbeSpec{ - Host: "localhost", - Address: "0.0.0.0", - Port: 3333, - Interval: metav1.Duration{Duration: time.Second * 10}, - Path: "/healthy", - }, - } - - Expect(k8sClient.Create(ctx, probeObj)).Should(Succeed()) - - Eventually(func() error { - err := k8sClient.Get(ctx, client.ObjectKeyFromObject(probeObj), probeObj) - if err != nil { - return err - } - if probeObj.Status.LastCheckedAt.Time == (time.Time{}) { - return fmt.Errorf("expected probeObj.Status.LastCheckedAt to be non-zero %s, %s", probeObj.Status.LastCheckedAt.Time, (metav1.Time{}).Time) - } - return nil - }, timeout+(time.Second*20), interval).Should(BeNil()) - - GinkgoWriter.Print(probeObj) - - Expect(*probeObj.Status.Healthy).Should(BeTrue()) - Expect(probeObj.Status.LastCheckedAt).Should(Not(BeZero())) - }) - It("Should update health status to unhealthy", func() { - By("Updating to unhealthy endpoint") - - ctx := context.Background() - probeObj := &v1alpha1.DNSHealthCheckProbe{} - - err := k8sClient.Get(ctx, client.ObjectKey{ - Name: ProbeName, - Namespace: ProbeNamespace, - }, probeObj) - Expect(err).NotTo(HaveOccurred()) - - patch := client.MergeFrom(probeObj.DeepCopy()) - lastUpdate := probeObj.Status.LastCheckedAt - probeObj.Spec.Path = "/unhealthy" - Expect(k8sClient.Patch(ctx, probeObj, patch)).To(BeNil()) - - Eventually(func() error { - err := k8sClient.Get(ctx, client.ObjectKeyFromObject(probeObj), probeObj) - if err != nil { - return err - } - if !probeObj.Status.LastCheckedAt.Time.After(lastUpdate.Time) { - return fmt.Errorf("expected probeObj.Status.LastCheckedAt to be after lastUpdate") - } - return nil - }, timeout+(time.Second*20), interval).Should(BeNil()) - - Expect(*probeObj.Status.Healthy).Should(BeFalse()) - Expect(probeObj.Status.Reason).Should(Equal("Status code: 500")) - }) - }) -}) diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index ea18ca52..8b754daf 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -22,7 +22,6 @@ import ( "context" "path/filepath" "testing" - "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -39,7 +38,6 @@ import ( externaldnsplan "sigs.k8s.io/external-dns/plan" "github.com/kuadrant/dns-operator/api/v1alpha1" - "github.com/kuadrant/dns-operator/internal/health" "github.com/kuadrant/dns-operator/internal/provider" _ "github.com/kuadrant/dns-operator/internal/provider/aws" providerFake "github.com/kuadrant/dns-operator/internal/provider/fake" @@ -118,20 +116,6 @@ var _ = BeforeSuite(func() { }) Expect(err).ToNot(HaveOccurred()) - healthQueue := health.NewRequestQueue(1 * time.Second) - err = mgr.Add(healthQueue) - Expect(err).ToNot(HaveOccurred()) - - monitor := health.NewMonitor() - err = mgr.Add(monitor) - Expect(err).ToNot(HaveOccurred()) - - healthServer := &testHealthServer{ - Port: 3333, - } - err = mgr.Add(healthServer) - Expect(err).ToNot(HaveOccurred()) - err = (&ManagedZoneReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -146,13 +130,6 @@ var _ = BeforeSuite(func() { }).SetupWithManager(mgr) Expect(err).ToNot(HaveOccurred()) - err = (&DNSHealthCheckProbeReconciler{ - Client: mgr.GetClient(), - HealthMonitor: monitor, - Queue: healthQueue, - }).SetupWithManager(mgr) - Expect(err).ToNot(HaveOccurred()) - go func() { defer GinkgoRecover() err = mgr.Start(ctx) diff --git a/internal/health/metrics.go b/internal/health/metrics.go deleted file mode 100644 index 3a91092c..00000000 --- a/internal/health/metrics.go +++ /dev/null @@ -1,61 +0,0 @@ -package health - -import ( - "context" - - "github.com/prometheus/client_golang/prometheus" - - "sigs.k8s.io/controller-runtime/pkg/metrics" -) - -var ( - healthCheckAttempts = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "mgc_dns_health_check_attempts_total", - Help: "MGC DNS Health Check Probe total number of attempts", - }, - []string{"gateway_name", "gateway_namespace", "listener"}, - ) - - healthCheckFailures = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "mgc_dns_health_check_failures_total", - Help: "MGC DNS Health Check Probe total number of failures", - }, - []string{"gateway_name", "gateway_namespace", "listener"}, - ) -) - -func init() { - metrics.Registry.MustRegister( - healthCheckAttempts, - healthCheckFailures, - ) -} - -// InstrumentedProbeNotifier wraps a notifier by incrementing the failure counter -// when the result is unhealthy -type InstrumentedProbeNotifier struct { - gatewayName, gatewayNamespace, listener string - notifier ProbeNotifier -} - -func NewInstrumentedProbeNotifier(gatewayName, gatewayNamespace, listener string, notifier ProbeNotifier) *InstrumentedProbeNotifier { - return &InstrumentedProbeNotifier{ - gatewayName: gatewayName, - gatewayNamespace: gatewayNamespace, - listener: listener, - notifier: notifier, - } -} - -func (n *InstrumentedProbeNotifier) Notify(ctx context.Context, result ProbeResult) (NotificationResult, error) { - healthCheckAttempts.WithLabelValues(n.gatewayName, n.gatewayNamespace, n.listener).Inc() - if !result.Healthy { - healthCheckFailures.WithLabelValues(n.gatewayName, n.gatewayNamespace, n.listener).Inc() - } - - return n.notifier.Notify(ctx, result) -} - -var _ ProbeNotifier = &InstrumentedProbeNotifier{} diff --git a/internal/health/monitor.go b/internal/health/monitor.go deleted file mode 100644 index f76aa362..00000000 --- a/internal/health/monitor.go +++ /dev/null @@ -1,96 +0,0 @@ -package health - -import ( - "context" - "sync" - - "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/manager" -) - -type Monitor struct { - ProbeQueuers []*ProbeQueuer - - mux sync.Mutex -} - -func NewMonitor() *Monitor { - return &Monitor{ - ProbeQueuers: make([]*ProbeQueuer, 0), - } -} - -func (m *Monitor) Start(ctx context.Context) error { - logger := log.FromContext(ctx) - logger.V(3).Info("Starting health check monitor") - - <-ctx.Done() - m.mux.Lock() - defer m.mux.Unlock() - - logger.Info("Stopping health check monitor") - - for _, probeQueuer := range m.ProbeQueuers { - probeQueuer.Stop() - } - - return nil -} - -var _ manager.Runnable = &Monitor{} - -func (m *Monitor) HasProbe(id string) bool { - m.mux.Lock() - defer m.mux.Unlock() - - for _, probeQueuer := range m.ProbeQueuers { - if probeQueuer.ID == id { - return true - } - } - - return false -} - -func (m *Monitor) UpdateProbe(id string, update func(*ProbeQueuer)) { - m.mux.Lock() - defer m.mux.Unlock() - - for _, probeQueuer := range m.ProbeQueuers { - if probeQueuer.ID == id { - update(probeQueuer) - } - } -} - -func (m *Monitor) AddProbeQueuer(probeQueuer *ProbeQueuer) bool { - m.mux.Lock() - defer m.mux.Unlock() - - for _, existingProbe := range m.ProbeQueuers { - if probeQueuer.ID == existingProbe.ID { - return false - } - } - - m.ProbeQueuers = append(m.ProbeQueuers, probeQueuer) - probeQueuer.Start() - return true -} - -func (m *Monitor) RemoveProbe(id string) { - m.mux.Lock() - defer m.mux.Unlock() - - updatedProbes := []*ProbeQueuer{} - - for _, probeQueuer := range m.ProbeQueuers { - if probeQueuer.ID == id { - probeQueuer.Stop() - } else { - updatedProbes = append(updatedProbes, probeQueuer) - } - } - - m.ProbeQueuers = updatedProbes -} diff --git a/internal/health/notifier.go b/internal/health/notifier.go deleted file mode 100644 index ee0204ca..00000000 --- a/internal/health/notifier.go +++ /dev/null @@ -1,67 +0,0 @@ -package health - -import ( - "context" - - "github.com/aws/aws-sdk-go/aws" - - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/kuadrant/dns-operator/api/v1alpha1" -) - -type StatusUpdateProbeNotifier struct { - apiClient client.Client - probeObjKey client.ObjectKey -} - -var _ ProbeNotifier = StatusUpdateProbeNotifier{} - -func NewStatusUpdateProbeNotifier(apiClient client.Client, forObj *v1alpha1.DNSHealthCheckProbe) StatusUpdateProbeNotifier { - return StatusUpdateProbeNotifier{ - apiClient: apiClient, - probeObjKey: client.ObjectKeyFromObject(forObj), - } -} - -func (n StatusUpdateProbeNotifier) Notify(ctx context.Context, result ProbeResult) (NotificationResult, error) { - probeObj := &v1alpha1.DNSHealthCheckProbe{} - if err := n.apiClient.Get(ctx, n.probeObjKey, probeObj); err != nil { - return NotificationResult{}, err - } - - // Increase the number of consecutive failures if it failed previously - if !result.Healthy { - probeHealthy := true - if probeObj.Status.Healthy != nil { - probeHealthy = *probeObj.Status.Healthy - } - if probeHealthy { - probeObj.Status.ConsecutiveFailures = 1 - } else { - probeObj.Status.ConsecutiveFailures++ - } - } else { - probeObj.Status.ConsecutiveFailures = 0 - } - - probeObj.Status.LastCheckedAt = metav1.NewTime(result.CheckedAt) - if probeObj.Status.Healthy == nil { - probeObj.Status.Healthy = aws.Bool(true) - } - probeObj.Status.Healthy = &result.Healthy - probeObj.Status.Reason = result.Reason - probeObj.Status.Status = result.Status - - if err := n.apiClient.Status().Update(ctx, probeObj); err != nil { - if errors.IsConflict(err) { - return NotificationResult{Requeue: true}, nil - } - - return NotificationResult{}, err - } - - return NotificationResult{}, nil -} diff --git a/internal/health/probeQueuer.go b/internal/health/probeQueuer.go deleted file mode 100644 index 1ab55e04..00000000 --- a/internal/health/probeQueuer.go +++ /dev/null @@ -1,92 +0,0 @@ -package health - -import ( - "context" - "time" - - "github.com/go-logr/logr" - - "sigs.k8s.io/controller-runtime/pkg/log" - - "github.com/kuadrant/dns-operator/api/v1alpha1" -) - -type ProbeQueuer struct { - ID string - - Interval time.Duration - Protocol v1alpha1.HealthProtocol - Path string - IPAddress string - Host string - Port int - AdditionalHeaders v1alpha1.AdditionalHeaders - ExpectedResponses []int - AllowInsecureCertificate bool - - Notifier ProbeNotifier - Queue *QueuedProbeWorker - - cancel context.CancelFunc - started bool - logger logr.Logger -} - -type ProbeResult struct { - CheckedAt time.Time - Reason string - Status int - Healthy bool -} - -type ProbeNotifier interface { - Notify(ctx context.Context, result ProbeResult) (NotificationResult, error) -} - -type NotificationResult struct { - Requeue bool -} - -func (p *ProbeQueuer) Start() { - if p.started { - return - } - - ctx, cancel := context.WithCancel(context.Background()) - p.cancel = cancel - p.logger = log.FromContext(ctx) - - p.logger.V(3).Info("Starting probe queuer", "id", p.ID) - - go func() { - for { - select { - case <-time.After(p.Interval): - p.Queue.EnqueueCheck(HealthRequest{ - Host: p.Host, - Path: p.Path, - Protocol: p.Protocol, - Address: p.IPAddress, - Port: p.Port, - AdditionalHeaders: p.AdditionalHeaders, - ExpectedResponses: p.ExpectedResponses, - Notifier: p.Notifier, - AllowInsecureCertificate: p.AllowInsecureCertificate, - }) - case <-ctx.Done(): - return - } - } - }() - - p.started = true -} - -func (p *ProbeQueuer) Stop() { - if !p.started { - return - } - - p.logger.V(3).Info("stopping probe", "id", p.ID) - p.cancel() -} diff --git a/internal/health/queuedProbeWorker.go b/internal/health/queuedProbeWorker.go deleted file mode 100644 index 196d5860..00000000 --- a/internal/health/queuedProbeWorker.go +++ /dev/null @@ -1,217 +0,0 @@ -package health - -import ( - "context" - "crypto/tls" - "fmt" - "net" - "net/http" - "runtime" - "sync" - "time" - - "github.com/go-logr/logr" - - utilnet "k8s.io/apimachinery/pkg/util/net" - "sigs.k8s.io/controller-runtime/pkg/log" - - "github.com/kuadrant/dns-operator/api/v1alpha1" -) - -// QueuedProbeWorker funnels incoming health check requests from health probes, -// processing them one at a time and spacing them by a specified duration -type QueuedProbeWorker struct { - Throttle time.Duration - - requests []HealthRequest - logger logr.Logger - - mux sync.Mutex -} - -func NewRequestQueue(throttle time.Duration) *QueuedProbeWorker { - return &QueuedProbeWorker{ - Throttle: throttle, - requests: make([]HealthRequest, 0), - } -} - -type HealthRequest struct { - Host, Path, Address string - Protocol v1alpha1.HealthProtocol - Port int - AdditionalHeaders v1alpha1.AdditionalHeaders - ExpectedResponses []int - AllowInsecureCertificate bool - Notifier ProbeNotifier -} - -func (q *QueuedProbeWorker) EnqueueCheck(req HealthRequest) { - q.mux.Lock() - defer q.mux.Unlock() - - q.logger.V(3).Info("enqueueing health check", "request", req) - q.requests = append(q.requests, req) -} - -// deqeue takes the next element of the queue and returns it. It blocks -// if the queue is empty, and returns false if the context is cancelled -func (q *QueuedProbeWorker) dequeue(ctx context.Context) (HealthRequest, bool) { - reqChn := make(chan HealthRequest) - - go func() { - for { - select { - case <-ctx.Done(): - close(reqChn) - return - default: - } - - q.mux.Lock() - if len(q.requests) == 0 { - q.mux.Unlock() - runtime.Gosched() - continue - } - - req := q.requests[0] - q.requests = q.requests[1:] - q.mux.Unlock() - - reqChn <- req - return - } - - }() - - req, ok := <-reqChn - return req, ok -} - -func (q *QueuedProbeWorker) Start(ctx context.Context) error { - q.logger = log.FromContext(ctx) - q.logger.V(3).Info("Starting health check queue") - defer q.logger.Info("Stopping health check queue") - - for { - select { - case <-ctx.Done(): - if ctx.Err() != context.Canceled { - return ctx.Err() - } - return nil - case <-time.After(q.Throttle): - q.logger.V(3).Info("dequeing health check") - req, ok := q.dequeue(ctx) - if !ok { - return nil - } - - q.process(ctx, req) - } - } -} - -func (q *QueuedProbeWorker) process(ctx context.Context, req HealthRequest) { - go func() { - result := q.performRequest(ctx, req) - notificationResult, err := req.Notifier.Notify(ctx, result) - if err != nil { - q.logger.Error(err, "failed to notify health check result") - } - - if notificationResult.Requeue { - q.EnqueueCheck(req) - } - }() -} - -func (q *QueuedProbeWorker) performRequest(ctx context.Context, req HealthRequest) ProbeResult { - q.logger.V(3).Info("performing health check", "request", req) - - probeClient := &http.Client{ - Transport: TransportWithDNSResponse(map[string]string{req.Host: req.Address}), - } - - if req.AllowInsecureCertificate { - probeClient.Transport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - } - - // Default port to 80 - port := 80 - if req.Port != 0 { - port = req.Port - } - - // Build the http request - httpReq, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s://%s:%d%s", req.Protocol.ToScheme(), req.Host, port, req.Path), nil) - if err != nil { - return ProbeResult{CheckedAt: time.Now(), Healthy: false, Reason: err.Error()} - } - - // add any user-defined additional headers - for _, h := range req.AdditionalHeaders { - httpReq.Header.Add(h.Name, h.Value) - } - - // Send the request - res, err := probeClient.Do(httpReq) - if utilnet.IsConnectionReset(err) { - res = &http.Response{StatusCode: 104} - } else if err != nil { - return ProbeResult{CheckedAt: time.Now(), Healthy: false, Reason: fmt.Sprintf("error: %s, response: %+v", err.Error(), res)} - } - - // Create the result based on the response - if req.ExpectedResponses == nil { - req.ExpectedResponses = []int{200, 201} - } - healthy := true - reason := "" - - if !checkResponse(res.StatusCode, req.ExpectedResponses) { - healthy = false - reason = fmt.Sprintf("Status code: %d", res.StatusCode) - } - - return ProbeResult{ - CheckedAt: time.Now(), - Healthy: healthy, - Status: res.StatusCode, - Reason: reason, - } -} - -func checkResponse(response int, expected []int) bool { - for _, i := range expected { - if response == i { - return true - } - } - return false -} - -// TransportWithDNSResponse creates a new transport which overrides hostnames. -func TransportWithDNSResponse(overrides map[string]string) http.RoundTripper { - transport := http.DefaultTransport.(*http.Transport).Clone() - dialer := &net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - } - - transport.DialContext = func(ctx context.Context, network, address string) (net.Conn, error) { - host, port, err := net.SplitHostPort(address) - if err != nil { - return nil, err - } - newHost, ok := overrides[host] - if !ok { - return dialer.DialContext(ctx, network, address) - } - overrideAddress := net.JoinHostPort(newHost, port) - return dialer.DialContext(ctx, network, overrideAddress) - } - - return transport -} From 8e2feda9b2bc97f1793b60ad391114e3b30f0f8c Mon Sep 17 00:00:00 2001 From: craig Date: Mon, 11 Mar 2024 11:01:59 +0000 Subject: [PATCH 2/3] update bundle --- PROJECT | 1 + .../dns-operator.clusterserviceversion.yaml | 51 +-------- .../kuadrant.io_dnshealthcheckprobes.yaml | 105 ------------------ .../dns-operator.clusterserviceversion.yaml | 71 ++++++------ config/samples/kustomization.yaml | 1 - 5 files changed, 38 insertions(+), 191 deletions(-) delete mode 100644 bundle/manifests/kuadrant.io_dnshealthcheckprobes.yaml diff --git a/PROJECT b/PROJECT index e634e8f5..89ab7979 100644 --- a/PROJECT +++ b/PROJECT @@ -27,3 +27,4 @@ resources: kind: DNSRecord path: github.com/kuadrant/dns-operator/api/v1alpha1 version: v1alpha1 +version: "3" \ No newline at end of file diff --git a/bundle/manifests/dns-operator.clusterserviceversion.yaml b/bundle/manifests/dns-operator.clusterserviceversion.yaml index 0be3de40..cde091a2 100644 --- a/bundle/manifests/dns-operator.clusterserviceversion.yaml +++ b/bundle/manifests/dns-operator.clusterserviceversion.yaml @@ -4,21 +4,6 @@ metadata: annotations: alm-examples: |- [ - { - "apiVersion": "kuadrant.io/v1alpha1", - "kind": "DNSHealthCheckProbe", - "metadata": { - "labels": { - "app.kubernetes.io/created-by": "dns-operator", - "app.kubernetes.io/instance": "dnshealthcheckprobe-sample", - "app.kubernetes.io/managed-by": "kustomize", - "app.kubernetes.io/name": "dnshealthcheckprobe", - "app.kubernetes.io/part-of": "dns-operator" - }, - "name": "dnshealthcheckprobe-sample" - }, - "spec": null - }, { "apiVersion": "kuadrant.io/v1alpha1", "kind": "DNSRecord", @@ -71,7 +56,7 @@ metadata: capabilities: Basic Install categories: Integration & Delivery containerImage: quay.io/kuadrant/dns-operator:latest - createdAt: "2024-03-05T14:47:38Z" + createdAt: "2024-03-11T11:01:25Z" description: A Kubernetes Operator to manage the lifecycle of DNS resources operators.operatorframework.io/builder: operator-sdk-v1.33.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 @@ -83,12 +68,6 @@ spec: apiservicedefinitions: {} customresourcedefinitions: owned: - - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes - API - displayName: DNSHealth Check Probe - kind: DNSHealthCheckProbe - name: dnshealthcheckprobes.kuadrant.io - version: v1alpha1 - description: DNSRecord is the Schema for the dnsrecords API displayName: DNSRecord kind: DNSRecord @@ -116,34 +95,6 @@ spec: - get - list - watch - - apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - - apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes/finalizers - verbs: - - get - - patch - - update - - apiGroups: - - kuadrant.io - resources: - - dnshealthcheckprobes/status - verbs: - - get - - patch - - update - apiGroups: - kuadrant.io resources: diff --git a/bundle/manifests/kuadrant.io_dnshealthcheckprobes.yaml b/bundle/manifests/kuadrant.io_dnshealthcheckprobes.yaml deleted file mode 100644 index 3b732a22..00000000 --- a/bundle/manifests/kuadrant.io_dnshealthcheckprobes.yaml +++ /dev/null @@ -1,105 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - creationTimestamp: null - name: dnshealthcheckprobes.kuadrant.io -spec: - group: kuadrant.io - names: - kind: DNSHealthCheckProbe - listKind: DNSHealthCheckProbeList - plural: dnshealthcheckprobes - singular: dnshealthcheckprobe - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: DNSHealthCheckProbe healthy. - jsonPath: .status.healthy - name: Healthy - type: boolean - - description: Last checked at. - jsonPath: .status.lastCheckedAt - name: Last Checked - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes - API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: DNSHealthCheckProbeSpec defines the desired state of DNSHealthCheckProbe - properties: - additionalHeadersRef: - properties: - name: - type: string - required: - - name - type: object - address: - type: string - allowInsecureCertificate: - type: boolean - expectedResponses: - items: - type: integer - type: array - failureThreshold: - type: integer - host: - type: string - interval: - type: string - path: - type: string - port: - type: integer - protocol: - description: HealthProtocol represents the protocol to use when making - a health check request - type: string - type: object - status: - description: DNSHealthCheckProbeStatus defines the observed state of DNSHealthCheckProbe - properties: - consecutiveFailures: - type: integer - healthy: - type: boolean - lastCheckedAt: - format: date-time - type: string - reason: - type: string - status: - type: integer - required: - - healthy - - lastCheckedAt - type: object - type: object - served: true - storage: true - subresources: - status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: null - storedVersions: null diff --git a/config/manifests/bases/dns-operator.clusterserviceversion.yaml b/config/manifests/bases/dns-operator.clusterserviceversion.yaml index 3cd8af05..a3faa12b 100644 --- a/config/manifests/bases/dns-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/dns-operator.clusterserviceversion.yaml @@ -15,52 +15,53 @@ spec: apiservicedefinitions: {} customresourcedefinitions: owned: - - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes API - displayName: DNSHealth Check Probe - kind: DNSHealthCheckProbe - name: dnshealthcheckprobes.kuadrant.io - version: v1alpha1 - - description: DNSRecord is the Schema for the dnsrecords API - displayName: DNSRecord - kind: DNSRecord - name: dnsrecords.kuadrant.io - version: v1alpha1 - - description: ManagedZone is the Schema for the managedzones API - displayName: Managed Zone - kind: ManagedZone - name: managedzones.kuadrant.io - version: v1alpha1 + - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes + API + displayName: DNSHealth Check Probe + kind: DNSHealthCheckProbe + name: dnshealthcheckprobes.kuadrant.io + version: v1alpha1 + - description: DNSRecord is the Schema for the dnsrecords API + displayName: DNSRecord + kind: DNSRecord + name: dnsrecords.kuadrant.io + version: v1alpha1 + - description: ManagedZone is the Schema for the managedzones API + displayName: Managed Zone + kind: ManagedZone + name: managedzones.kuadrant.io + version: v1alpha1 description: A Kubernetes Operator to manage the lifecycle of DNS resources displayName: DNS Operator icon: - - base64data: iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAHCklEQVR4nOzc72tWdQPH8e+tm/ecXGNO77mb3beZLgtkDxpCgT4IBBFqJT1YRqFS5oMS/BG5ioqhUc3IFKwHpqHSg9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G2rXxer1BSV/W/tW84HSVBWEkrrV04d3dL7LZmNb3qepEEYXlQVF4Zr63ql5eH8IqiKAjLjxhtZeprZzzxonKUS4TlTU5tFddkbt/0jn6UM4TlU8S2JlZMmrP17WC/vRkVYXkWpa3qxtVpubS6hrD8G7utynVLQ/5OMBvCCkK2tsqX3ZuKp1YjEVYoRraVqa+d/foer6PiI6yADG+rpK4qXbeBNynyPSCSmrxf2FpRUeFoi5Zt60zzxpmNW9J1G3iTfw0MDPjegALERyEkCAsShAUJwoIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxIEBYkCAsShAUJwoIEYUGCsCBBWJAgLEgQFiQICxKEBQnCggRhQYKwIEFYkCAsSBAWJAgLEoQFCcKCBGFBgrAgQViQICxI/B0AAP//uLJ9vDn6iowAAAAASUVORK5CYII= + mediatype: image/png install: spec: deployments: null strategy: "" installModes: - - supported: false - type: OwnNamespace - - supported: false - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces + - supported: false + type: OwnNamespace + - supported: false + type: SingleNamespace + - supported: false + type: MultiNamespace + - supported: true + type: AllNamespaces keywords: - - dns - - kuadrant + - dns + - kuadrant links: - - name: DNS Operator - url: https://github.com/Kuadrant/dns-operator + - name: DNS Operator + url: https://github.com/Kuadrant/dns-operator maintainers: - - email: mnairn@redhat.com - name: Michael Nairn - - email: pbrookes@redhat.com - name: Phil Brookes - - email: cbrookes@redhat.com - name: Craig Brookes + - email: mnairn@redhat.com + name: Michael Nairn + - email: pbrookes@redhat.com + name: Phil Brookes + - email: cbrookes@redhat.com + name: Craig Brookes maturity: alpha minKubeVersion: 1.8.0 provider: diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 02b1dc67..7bf6c2a0 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -2,5 +2,4 @@ resources: - kuadrant.io_v1alpha1_managedzone.yaml - kuadrant.io_v1alpha1_dnsrecord.yaml -- kuadrant.io_v1alpha1_dnshealthcheckprobe.yaml #+kubebuilder:scaffold:manifestskustomizesamples From a8b5246b88a7eca1b40ff6420805bd4ecc27bdd1 Mon Sep 17 00:00:00 2001 From: craig Date: Mon, 11 Mar 2024 12:29:51 +0000 Subject: [PATCH 3/3] updates post review --- PROJECT | 2 +- .../manifests/bases/dns-operator.clusterserviceversion.yaml | 6 ------ go.mod | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/PROJECT b/PROJECT index 89ab7979..73f0acc7 100644 --- a/PROJECT +++ b/PROJECT @@ -27,4 +27,4 @@ resources: kind: DNSRecord path: github.com/kuadrant/dns-operator/api/v1alpha1 version: v1alpha1 -version: "3" \ No newline at end of file +version: "3" diff --git a/config/manifests/bases/dns-operator.clusterserviceversion.yaml b/config/manifests/bases/dns-operator.clusterserviceversion.yaml index a3faa12b..2c8461a7 100644 --- a/config/manifests/bases/dns-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/dns-operator.clusterserviceversion.yaml @@ -15,12 +15,6 @@ spec: apiservicedefinitions: {} customresourcedefinitions: owned: - - description: DNSHealthCheckProbe is the Schema for the dnshealthcheckprobes - API - displayName: DNSHealth Check Probe - kind: DNSHealthCheckProbe - name: dnshealthcheckprobes.kuadrant.io - version: v1alpha1 - description: DNSRecord is the Schema for the dnsrecords API displayName: DNSRecord kind: DNSRecord diff --git a/go.mod b/go.mod index 49124e48..6df9ca13 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/onsi/ginkgo/v2 v2.11.0 github.com/onsi/gomega v1.27.10 github.com/prometheus/client_golang v1.17.0 - github.com/sirupsen/logrus v1.9.3 google.golang.org/api v0.134.0 k8s.io/api v0.28.3 k8s.io/apimachinery v0.28.3 @@ -16,7 +15,6 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b sigs.k8s.io/controller-runtime v0.16.3 sigs.k8s.io/external-dns v0.14.0 - sigs.k8s.io/gateway-api v0.7.1 ) require ( @@ -69,6 +67,7 @@ require ( github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/pflag v1.0.5 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect @@ -98,6 +97,7 @@ require ( k8s.io/component-base v0.28.3 // indirect k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect + sigs.k8s.io/gateway-api v0.7.1 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect