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

[release-4.15]: OCPBUGS-30264: Bump Helm & K8s dependencies #79

Merged
Merged
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
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .bingo/Variables.mk
@@ -1,4 +1,4 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT.
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.9. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
GOPATH ?= $(shell go env GOPATH)
Expand Down Expand Up @@ -29,11 +29,11 @@ $(CONTROLLER_GEN): $(BINGO_DIR)/controller-gen.mod
@echo "(re)installing $(GOBIN)/controller-gen-v0.12.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=controller-gen.mod -o=$(GOBIN)/controller-gen-v0.12.0 "sigs.k8s.io/controller-tools/cmd/controller-gen"

GINKGO := $(GOBIN)/ginkgo-v2.13.0
GINKGO := $(GOBIN)/ginkgo-v2.14.0
$(GINKGO): $(BINGO_DIR)/ginkgo.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/ginkgo-v2.13.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=ginkgo.mod -o=$(GOBIN)/ginkgo-v2.13.0 "github.com/onsi/ginkgo/v2/ginkgo"
@echo "(re)installing $(GOBIN)/ginkgo-v2.14.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=ginkgo.mod -o=$(GOBIN)/ginkgo-v2.14.0 "github.com/onsi/ginkgo/v2/ginkgo"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.53.2
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
Expand Down
2 changes: 1 addition & 1 deletion .bingo/ginkgo.mod
Expand Up @@ -2,4 +2,4 @@ module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.20

require github.com/onsi/ginkgo/v2 v2.13.0 // ginkgo
require github.com/onsi/ginkgo/v2 v2.14.0 // ginkgo
4 changes: 4 additions & 0 deletions .bingo/ginkgo.sum
Expand Up @@ -16,6 +16,8 @@ github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI
github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ=
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
github.com/onsi/ginkgo/v2 v2.14.0 h1:vSmGj2Z5YPb9JwCWT6z6ihcUvDhuXLc3sJiqd3jMKAY=
github.com/onsi/ginkgo/v2 v2.14.0/go.mod h1:JkUdW7JkN0V6rFvsHcJ478egV3XH9NxpD27Hal/PhZw=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
Expand All @@ -25,6 +27,8 @@ golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions .bingo/variables.env
@@ -1,4 +1,4 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT.
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.9. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk.
GOBIN=${GOBIN:=$(go env GOBIN)}
Expand All @@ -12,7 +12,7 @@ BINGO="${GOBIN}/bingo-v0.8.0"

CONTROLLER_GEN="${GOBIN}/controller-gen-v0.12.0"

GINKGO="${GOBIN}/ginkgo-v2.13.0"
GINKGO="${GOBIN}/ginkgo-v2.14.0"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.53.2"

Expand Down
120 changes: 70 additions & 50 deletions cmd/core/main.go
Expand Up @@ -35,13 +35,15 @@ import (
"k8s.io/apimachinery/pkg/selection"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/cluster"
"sigs.k8s.io/controller-runtime/pkg/client"
crfinalizer "sigs.k8s.io/controller-runtime/pkg/finalizer"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
"github.com/operator-framework/rukpak/internal/controllers/bundle"
Expand Down Expand Up @@ -128,50 +130,72 @@ func main() {
systemNamespace = util.PodNamespace()
}

systemNsCluster, err := cluster.New(cfg, func(opts *cluster.Options) {
opts.Scheme = scheme
opts.Namespace = systemNamespace
})
storageURL, err := url.Parse(fmt.Sprintf("%s/bundles/", httpExternalAddr))
if err != nil {
setupLog.Error(err, "unable to create system namespace cluster")
setupLog.Error(err, "unable to parse bundle content server URL")
os.Exit(1)
}
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: httpBindAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "core.rukpak.io",
NewCache: cache.BuilderWithOptions(cache.Options{
SelectorsByObject: cache.SelectorsByObject{
&rukpakv1alpha1.BundleDeployment{}: {},
&rukpakv1alpha1.Bundle{}: {},
},
DefaultSelector: cache.ObjectSelector{
Label: dependentSelector,
},
}),
})
if err != nil {
setupLog.Error(err, "unable to create manager")
os.Exit(1)

localStorage := &storage.LocalDirectory{
RootDirectory: provisionerStorageDirectory,
URL: *storageURL,
}

if err := mgr.Add(systemNsCluster); err != nil {
setupLog.Error(err, "unable to add system namespace cluster to manager")
cacheOptions := cache.Options{
Scheme: scheme,
ByObject: map[client.Object]cache.ByObject{
&rukpakv1alpha1.BundleDeployment{}: {},
&rukpakv1alpha1.Bundle{}: {},
},
DefaultNamespaces: map[string]cache.Config{
systemNamespace: {},
cache.AllNamespaces: {LabelSelector: dependentSelector},
},
}
c, err := cache.New(cfg, cacheOptions)
if err != nil {
setupLog.Error(err, "unable to create cache for the manager")
os.Exit(1)
}

storageURL, err := url.Parse(fmt.Sprintf("%s/bundles/", httpExternalAddr))
clientOptions := client.Options{
Scheme: scheme,
Cache: &client.CacheOptions{
Reader: c,
},
}
cl, err := client.New(cfg, clientOptions)
if err != nil {
setupLog.Error(err, "unable to parse bundle content server URL")
setupLog.Error(err, "unable to create client for the manager")
os.Exit(1)
}

localStorage := &storage.LocalDirectory{
RootDirectory: provisionerStorageDirectory,
URL: *storageURL,
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
NewCache: func(_ *rest.Config, _ cache.Options) (cache.Cache, error) {
return c, nil
},
NewClient: func(_ *rest.Config, _ client.Options) (client.Client, error) {
return cl, nil
},
Metrics: server.Options{
BindAddress: httpBindAddr,
ExtraHandlers: map[string]http.Handler{
// NOTE: ExtraHandlers aren't actually metrics-specific. We can run
// whatever handlers we want on the existing webserver that
// controller-runtime runs when MetricsBindAddress is configured on the
// manager.
"/bundles/": httpLogger(localStorage),
"/uploads/": httpLogger(uploadmgr.NewUploadHandler(cl, uploadStorageDirectory)),
},
},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "core.rukpak.io",
})
if err != nil {
setupLog.Error(err, "unable to create manager")
os.Exit(1)
}

var rootCAs *x509.CertPool
Expand All @@ -189,18 +213,6 @@ func main() {
)
bundleStorage := storage.WithFallbackLoader(localStorage, httpLoader)

// NOTE: AddMetricsExtraHandler isn't actually metrics-specific. We can run
// whatever handlers we want on the existing webserver that
// controller-runtime runs when MetricsBindAddress is configured on the
// manager.
if err := mgr.AddMetricsExtraHandler("/bundles/", httpLogger(localStorage)); err != nil {
setupLog.Error(err, "unable to add bundles http handler to manager")
os.Exit(1)
}
if err := mgr.AddMetricsExtraHandler("/uploads/", httpLogger(uploadmgr.NewUploadHandler(mgr.GetClient(), uploadStorageDirectory))); err != nil {
setupLog.Error(err, "unable to add uploads http handler to manager")
os.Exit(1)
}
if err := mgr.Add(uploadmgr.NewBundleGC(mgr.GetCache(), uploadStorageDirectory, uploadStorageSyncInterval)); err != nil {
setupLog.Error(err, "unable to add bundle garbage collector to manager")
os.Exit(1)
Expand All @@ -225,7 +237,7 @@ func main() {
os.Exit(1)
}

unpacker, err := source.NewDefaultUnpacker(systemNsCluster, systemNamespace, unpackImage, baseUploadManagerURL, rootCAs)
unpacker, err := source.NewDefaultUnpacker(mgr, systemNamespace, unpackImage, baseUploadManagerURL, rootCAs)
if err != nil {
setupLog.Error(err, "unable to setup bundle unpacker")
os.Exit(1)
Expand All @@ -237,15 +249,23 @@ func main() {
bundle.WithStorage(bundleStorage),
}

cfgGetter := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(), mgr.GetLogger())
acg := helmclient.NewActionClientGetter(cfgGetter)
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(), mgr.GetLogger())
if err != nil {
setupLog.Error(err, "unable to create action config getter")
os.Exit(1)
}
acg, err := helmclient.NewActionClientGetter(cfgGetter)
if err != nil {
setupLog.Error(err, "unable to create action client getter")
os.Exit(1)
}
commonBDProvisionerOptions := []bundledeployment.Option{
bundledeployment.WithReleaseNamespace(systemNamespace),
bundledeployment.WithActionClientGetter(acg),
bundledeployment.WithStorage(bundleStorage),
}

if err := bundle.SetupWithManager(mgr, systemNsCluster.GetCache(), systemNamespace, append(
if err := bundle.SetupWithManager(mgr, systemNamespace, append(
commonBundleProvisionerOptions,
bundle.WithProvisionerID(plain.ProvisionerID),
bundle.WithHandler(bundle.HandlerFunc(plain.HandleBundle)),
Expand All @@ -254,7 +274,7 @@ func main() {
os.Exit(1)
}

if err := bundle.SetupWithManager(mgr, systemNsCluster.GetCache(), systemNamespace, append(
if err := bundle.SetupWithManager(mgr, systemNamespace, append(
commonBundleProvisionerOptions,
bundle.WithProvisionerID(registry.ProvisionerID),
bundle.WithHandler(bundle.HandlerFunc(registry.HandleBundle)),
Expand Down
11 changes: 3 additions & 8 deletions cmd/crdvalidator/handlers/crd.go
Expand Up @@ -42,8 +42,9 @@ type CrdValidator struct {

func NewCrdValidator(log logr.Logger, client client.Client) CrdValidator {
return CrdValidator{
log: log.V(1).WithName("crdhandler"), // Default to non-verbose logs
client: client,
log: log.V(1).WithName("crdhandler"), // Default to non-verbose logs
client: client,
decoder: admission.NewDecoder(client.Scheme()),
}
}

Expand Down Expand Up @@ -74,12 +75,6 @@ func (cv *CrdValidator) Handle(ctx context.Context, req admission.Request) admis
return admission.Allowed("")
}

// InjectDecoder injects a decoder for the CrdValidator.
func (cv *CrdValidator) InjectDecoder(d *admission.Decoder) error {
cv.decoder = d
return nil
}

// disabled takes a CRD and checks its content to see crdvalidator
// is disabled explicitly
func disabled(crd *apiextensionsv1.CustomResourceDefinition) bool {
Expand Down
19 changes: 13 additions & 6 deletions cmd/crdvalidator/main.go
Expand Up @@ -23,8 +23,10 @@ import (

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand All @@ -48,9 +50,16 @@ func init() {

func main() {
var enableHTTP2 bool

flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the webhook servers.")

opts := zap.Options{
Development: true,
}
opts.BindFlags(flag.CommandLine)

flag.Parse()
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

// Setup webhook options
disableHTTP2 := func(c *tls.Config) {
if enableHTTP2 {
Expand All @@ -59,9 +68,10 @@ func main() {
c.NextProtos = []string{"http/1.1"}
}

webhookServer := &webhook.Server{
webhookServer := webhook.NewServer(webhook.Options{
TLSOpts: []func(config *tls.Config){disableHTTP2},
}
CertDir: defaultCertDir,
})

entryLog.Info("setting up manager")
mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{Scheme: scheme, WebhookServer: webhookServer})
Expand All @@ -73,9 +83,6 @@ func main() {
entryLog.Info("setting up webhook server")
hookServer := mgr.GetWebhookServer()

// Point to where cert-mgr is placing the cert
hookServer.CertDir = defaultCertDir

// Register CRD validation handler
entryLog.Info("registering webhooks to the webhook server")
crdValidatorHandler := handlers.NewCrdValidator(entryLog, mgr.GetClient())
Expand Down