@@ -33,7 +33,6 @@ import (
3333 "github.com/openshift/library-go/pkg/operator/events"
3434 certapiv1 "k8s.io/api/certificates/v1"
3535 v1 "k8s.io/api/core/v1"
36- apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3736 apierrors "k8s.io/apimachinery/pkg/api/errors"
3837 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3938 k8sruntime "k8s.io/apimachinery/pkg/runtime"
@@ -205,27 +204,6 @@ type Operator struct {
205204
206205 ruleController * alert.RuleController
207206 relabelController * alert.RelabelConfigController
208-
209- // lastKnownVPACustomResourceDefinitionPresent is a boolean pointer that
210- // remembers the presence of the VPA CRD in the cluster between
211- // kube-state-metrics task reconciliations. It is used to determine
212- // whether to enable kube-state-metrics custom-resource-state-based
213- // metrics for VPA CRs, even in cases where the Kube API may emit a
214- // transient error (errors excluding `IsNotFound`) on the VPA CRD `GET`
215- // requests (to determine its presence).
216- // * `true` indicates that the VPA CRD is already present in the
217- // cluster, and the custom-resource-state-based metrics can be safely
218- // enabled.
219- // * `false` indicates that the VPA CRD is not present in the cluster,
220- // and enabling the custom-resource-state-based metrics will cause
221- // kube-state-metrics to error (affecting `KubeStateMetricsListErrors`).
222- // * `nil` indicates that the presence of the VPA CRD is unknown, and
223- // the operator will attempt to determine the presence of the VPA CRD in
224- // the current reconciliation cycle, and remember its state in the next
225- // one. In the case where the VPA CRD is added or removed between
226- // reconciliations, the variable "forgets" it, and is set to `nil`,
227- // triggering a check on the next cycle.
228- lastKnownVPACustomResourceDefinitionPresent * bool
229207}
230208
231209func New (
@@ -446,20 +424,6 @@ func New(
446424 }
447425 o .informers = append (o .informers , informer )
448426
449- informer = cache .NewSharedIndexInformer (
450- o .client .VerticalPodAutoscalerCRDListWatch (ctx ),
451- & apiextv1.CustomResourceDefinition {}, resyncPeriod , cache.Indexers {},
452- )
453- // Only trigger reconciliation on the addition or removal of VPA CRDs.
454- _ , err = informer .AddEventHandler (cache.ResourceEventHandlerFuncs {
455- AddFunc : o .handleEvent ,
456- DeleteFunc : o .handleEvent ,
457- })
458- if err != nil {
459- return nil , err
460- }
461- o .informers = append (o .informers , informer )
462-
463427 kubeInformersOperatorNS := informers .NewSharedInformerFactoryWithOptions (
464428 c .KubernetesInterface (),
465429 resyncPeriod ,
@@ -667,10 +631,7 @@ func (o *Operator) handleEvent(obj interface{}) {
667631 * configv1.APIServer ,
668632 * configv1.Console ,
669633 * configv1.ClusterOperator ,
670- * configv1.ClusterVersion ,
671- // Currently, the CRDs that trigger reconciliation are:
672- // * verticalpodautoscalers.autoscaling.k8s.io
673- * apiextv1.CustomResourceDefinition :
634+ * configv1.ClusterVersion :
674635 // Log GroupKind and Name of the obj
675636 rtObj := obj .(k8sruntime.Object )
676637 gk := rtObj .GetObjectKind ().GroupVersionKind ().GroupKind ()
@@ -819,18 +780,6 @@ func (o *Operator) sync(ctx context.Context, key string) error {
819780 klog .Warningf ("Fail to load ConsoleConfig, AlertManager's externalURL may be outdated" )
820781 }
821782
822- // Enable kube-state-metrics' custom-resource-state-based metrics if VPA CRD is installed within the cluster.
823- o .lastKnownVPACustomResourceDefinitionPresent , err = o .client .VPACustomResourceDefinitionPresent (ctx , o .lastKnownVPACustomResourceDefinitionPresent )
824- if err != nil {
825- // Throw on all transient errors.
826- return fmt .Errorf ("unable to guess the desired state for kube-state-metrics' custom-resource-state metrics enablement: %w" , err )
827- } else {
828- // If we didn't get an error, we can safely assume that the CRD is deterministically either present or absent.
829- if * o .lastKnownVPACustomResourceDefinitionPresent {
830- klog .Infof ("%s CRD found, enabling kube-state-metrics' custom-resource-state-based metrics" , client .VerticalPodAutoscalerCRDMetadataName )
831- }
832- }
833-
834783 factory := manifests .NewFactory (
835784 o .namespace ,
836785 o .namespaceUserWorkload ,
@@ -859,7 +808,7 @@ func (o *Operator) sync(ctx context.Context, key string) error {
859808 newTaskSpec ("Prometheus" , tasks .NewPrometheusTask (o .client , factory , config )),
860809 newTaskSpec ("Alertmanager" , tasks .NewAlertmanagerTask (o .client , factory , config )),
861810 newTaskSpec ("NodeExporter" , tasks .NewNodeExporterTask (o .client , factory )),
862- newTaskSpec ("KubeStateMetrics" , tasks .NewKubeStateMetricsTask (o .client , factory , * o . lastKnownVPACustomResourceDefinitionPresent )),
811+ newTaskSpec ("KubeStateMetrics" , tasks .NewKubeStateMetricsTask (o .client , factory )),
863812 newTaskSpec ("OpenshiftStateMetrics" , tasks .NewOpenShiftStateMetricsTask (o .client , factory )),
864813 newTaskSpec ("MetricsServer" , tasks .NewMetricsServerTask (ctx , o .namespace , o .client , factory , config )),
865814 newTaskSpec ("TelemeterClient" , tasks .NewTelemeterClientTask (o .client , factory , config )),
0 commit comments