Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "OCPBUGS-13547: [OCPCLOUD-2034] Update Library-go and API for new featuregate changes" #3739

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
39 changes: 2 additions & 37 deletions cmd/machine-config-controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import (
"flag"
"fmt"
"os"
"time"

"github.com/golang/glog"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
"github.com/openshift/machine-config-operator/cmd/common"
"github.com/openshift/machine-config-operator/internal/clients"
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
Expand All @@ -22,7 +20,6 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/leaderelection"
"k8s.io/klog/v2"
)

var (
Expand Down Expand Up @@ -63,11 +60,10 @@ func runStartCmd(cmd *cobra.Command, args []string) {
if err != nil {
ctrlcommon.WriteTerminationError(fmt.Errorf("creating clients: %w", err))
}

run := func(ctx context.Context) {
go common.SignalHandler(runCancel)

ctrlctx := ctrlcommon.CreateControllerContext(ctx, cb, componentName)
ctrlctx := ctrlcommon.CreateControllerContext(cb, ctx.Done(), componentName)

// Start the metrics handler
go ctrlcommon.StartMetricsListener(startOpts.promMetricsListenAddress, ctrlctx.Stop, ctrlcommon.RegisterMCCMetrics)
Expand All @@ -89,20 +85,6 @@ func runStartCmd(cmd *cobra.Command, args []string) {

close(ctrlctx.InformersStarted)

select {
case <-ctrlctx.FeatureGateAccess.InitialFeatureGatesObserved():
features, err := ctrlctx.FeatureGateAccess.CurrentFeatureGates()
if err != nil {
klog.Fatalf("unable to get initial features: %v", err)
}

enabled, disabled := getEnabledDisabledFeatures(features)
klog.Infof("FeatureGates initialized: enabled=%v disabled=%v", enabled, disabled)
case <-time.After(1 * time.Minute):
klog.Errorf("timed out waiting for FeatureGate detection")
os.Exit(1)
}

for _, c := range controllers {
go c.Run(2, ctrlctx.Stop)
}
Expand Down Expand Up @@ -141,9 +123,9 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
ctx.InformerFactory.Machineconfiguration().V1().ControllerConfigs(),
ctx.InformerFactory.Machineconfiguration().V1().MachineConfigs(),
ctx.OpenShiftConfigKubeNamespacedInformerFactory.Core().V1().Secrets(),
ctx.ConfigInformerFactory.Config().V1().FeatureGates(),
ctx.ClientBuilder.KubeClientOrDie("template-controller"),
ctx.ClientBuilder.MachineConfigClientOrDie("template-controller"),
ctx.FeatureGateAccess,
),
// Add all "sub-renderers here"
kubeletconfig.New(
Expand All @@ -157,7 +139,6 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
ctx.ClientBuilder.KubeClientOrDie("kubelet-config-controller"),
ctx.ClientBuilder.MachineConfigClientOrDie("kubelet-config-controller"),
ctx.ClientBuilder.ConfigClientOrDie("kubelet-config-controller"),
ctx.FeatureGateAccess,
),
containerruntimeconfig.New(
rootOpts.templates,
Expand All @@ -172,7 +153,6 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
ctx.ClientBuilder.KubeClientOrDie("container-runtime-config-controller"),
ctx.ClientBuilder.MachineConfigClientOrDie("container-runtime-config-controller"),
ctx.ClientBuilder.ConfigClientOrDie("container-runtime-config-controller"),
ctx.FeatureGateAccess,
),
// The renderer creates "rendered" MCs from the MC fragments generated by
// the above sub-controllers, which are then consumed by the node controller
Expand All @@ -197,18 +177,3 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle

return controllers
}

func getEnabledDisabledFeatures(features featuregates.FeatureGate) ([]string, []string) {
var enabled []string
var disabled []string

for _, feature := range features.KnownFeatures() {
if features.Enabled(feature) {
enabled = append(enabled, string(feature))
} else {
disabled = append(disabled, string(feature))
}
}

return enabled, disabled
}
22 changes: 10 additions & 12 deletions cmd/machine-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bufio"
"context"
"flag"
"fmt"
"io"
Expand Down Expand Up @@ -185,13 +184,12 @@ func runStartCmd(cmd *cobra.Command, args []string) {
}

// This channel is used to ensure all spawned goroutines exit when we exit.
ctx, cancel := context.WithCancel(context.Background())
stopCh := ctx.Done()
defer cancel()
stopCh := make(chan struct{})
defer close(stopCh)

if startOpts.hypershiftDesiredConfigMap != "" {
// This is a hypershift-mode daemon
ctx := ctrlcommon.CreateControllerContext(ctx, cb, componentName)
ctx := ctrlcommon.CreateControllerContext(cb, stopCh, componentName)
err := dn.HypershiftConnect(
startOpts.nodeName,
kubeClient,
Expand All @@ -214,25 +212,25 @@ func runStartCmd(cmd *cobra.Command, args []string) {
// Start local metrics listener
go ctrlcommon.StartMetricsListener(startOpts.promMetricsURL, stopCh, daemon.RegisterMCDMetrics)

ctrlctx := ctrlcommon.CreateControllerContext(ctx, cb, componentName)
ctx := ctrlcommon.CreateControllerContext(cb, stopCh, componentName)
// create the daemon instance. this also initializes kube client items
// which need to come from the container and not the chroot.
err = dn.ClusterConnect(
startOpts.nodeName,
kubeClient,
ctrlctx.InformerFactory.Machineconfiguration().V1().MachineConfigs(),
ctrlctx.KubeInformerFactory.Core().V1().Nodes(),
ctrlctx.InformerFactory.Machineconfiguration().V1().ControllerConfigs(),
ctx.InformerFactory.Machineconfiguration().V1().MachineConfigs(),
ctx.KubeInformerFactory.Core().V1().Nodes(),
ctx.InformerFactory.Machineconfiguration().V1().ControllerConfigs(),
startOpts.kubeletHealthzEnabled,
startOpts.kubeletHealthzEndpoint,
)
if err != nil {
glog.Fatalf("Failed to initialize: %v", err)
}

ctrlctx.KubeInformerFactory.Start(stopCh)
ctrlctx.InformerFactory.Start(stopCh)
close(ctrlctx.InformersStarted)
ctx.KubeInformerFactory.Start(stopCh)
ctx.InformerFactory.Start(stopCh)
close(ctx.InformersStarted)

if err := dn.Run(stopCh, exitCh); err != nil {
ctrlcommon.WriteTerminationError(err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-operator/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func runStartCmd(cmd *cobra.Command, args []string) {
run := func(ctx context.Context) {
go common.SignalHandler(runCancel)

ctrlctx := ctrlcommon.CreateControllerContext(ctx, cb, ctrlcommon.MCONamespace)
ctrlctx := ctrlcommon.CreateControllerContext(cb, ctx.Done(), ctrlcommon.MCONamespace)
controller := operator.New(
ctrlcommon.MCONamespace, componentName,
startOpts.imagesFile,
Expand Down
57 changes: 28 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,35 @@ require (
github.com/coreos/ignition v0.35.0
github.com/coreos/ignition/v2 v2.15.0
github.com/coreos/rpmostree-client-go v0.0.0-20230303152616-d29525c6e333
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/davecgh/go-spew v1.1.1
github.com/fsnotify/fsnotify v1.6.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/ghodss/yaml v1.0.0
github.com/golang/glog v1.0.0
github.com/golangci/golangci-lint v1.49.0
github.com/google/go-cmp v0.5.9
github.com/google/renameio v0.1.0
github.com/imdario/mergo v0.3.13
github.com/opencontainers/go-digest v1.0.0
github.com/openshift/api v0.0.0-20230509100629-894b49f57a15
github.com/openshift/client-go v0.0.0-20230503144108-75015d2347cb
github.com/openshift/cluster-config-operator v0.0.0-alpha.0.0.20230516205036-088c6d48cc1a
github.com/openshift/library-go v0.0.0-20230515175430-c002cf381131
github.com/openshift/api v0.0.0-20230221095031-69130006bb23
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084
github.com/openshift/library-go v0.0.0-20230307165833-3e3a8a28de0c
github.com/openshift/runtime-utils v0.0.0-20220926190846-5c488b20a19f
github.com/prometheus/client_golang v1.14.0
github.com/spf13/cobra v1.6.0
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
github.com/stretchr/testify v1.8.2
github.com/vincent-petithory/dataurl v1.0.0
golang.org/x/net v0.8.0
golang.org/x/net v0.7.0
golang.org/x/time v0.2.0
k8s.io/api v0.27.1
k8s.io/apiextensions-apiserver v0.27.1
k8s.io/apimachinery v0.27.1
k8s.io/client-go v0.27.1
k8s.io/code-generator v0.27.1
k8s.io/component-base v0.27.1
k8s.io/api v0.26.1
k8s.io/apiextensions-apiserver v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/code-generator v0.26.1
k8s.io/component-base v0.26.1
k8s.io/kubectl v0.25.1
k8s.io/kubelet v0.25.1
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d
sigs.k8s.io/controller-runtime v0.13.0
)

Expand All @@ -63,7 +62,6 @@ require (
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/validate v0.22.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/sigstore/fulcio v1.0.0 // indirect
github.com/sigstore/rekor v1.0.1 // indirect
go.mongodb.org/mongo-driver v1.11.1 // indirect
Expand Down Expand Up @@ -112,6 +110,7 @@ require (
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/esimonov/ifshort v1.0.4 // indirect
github.com/ettle/strcase v0.1.1 // indirect
Expand All @@ -125,8 +124,8 @@ require (
github.com/go-critic/go-critic v0.6.4 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-toolsmith/astcast v1.0.0 // indirect
github.com/go-toolsmith/astcopy v1.0.1 // indirect
Expand All @@ -140,7 +139,7 @@ require (
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect
Expand Down Expand Up @@ -203,7 +202,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
Expand Down Expand Up @@ -283,13 +282,13 @@ require (
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc // indirect
google.golang.org/grpc v1.53.0 // indirect
Expand All @@ -300,17 +299,17 @@ require (
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.3.3 // indirect
k8s.io/apiserver v0.27.1 // indirect
k8s.io/apiserver v0.26.1 // indirect
k8s.io/cli-runtime v0.25.1 // indirect
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
k8s.io/klog/v2 v2.90.1
k8s.io/kube-aggregator v0.27.1 // indirect
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-aggregator v0.26.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
mvdan.cc/gofumpt v0.3.1 // indirect
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20220706161116-678bad134442 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/kube-storage-version-migrator v0.0.4 // indirect
sigs.k8s.io/kustomize/api v0.12.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
Expand Down