Skip to content

Commit

Permalink
Bump CAPI to v1.6.0-rc.0
Browse files Browse the repository at this point in the history
Signed-off-by: Furkat Gofurov <furkat.gofurov@suse.com>
  • Loading branch information
furkatgofurov7 committed Nov 28, 2023
1 parent d0f318d commit 259e4ae
Show file tree
Hide file tree
Showing 18 changed files with 531 additions and 669 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha2/addonprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type AddonProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []AddonProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &AddonProvider{}, &AddonProviderList{})
}
4 changes: 4 additions & 0 deletions api/v1alpha2/bootstrapprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type BootstrapProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []BootstrapProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &BootstrapProvider{}, &BootstrapProviderList{})
}
4 changes: 4 additions & 0 deletions api/v1alpha2/controlplaneprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type ControlPlaneProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []ControlPlaneProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &ControlPlaneProvider{}, &ControlPlaneProviderList{})
}
4 changes: 4 additions & 0 deletions api/v1alpha2/coreprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type CoreProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []CoreProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &CoreProvider{}, &CoreProviderList{})
}
11 changes: 3 additions & 8 deletions api/v1alpha2/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ var (

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

objectTypes = []runtime.Object{}
)

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&CoreProvider{}, &CoreProviderList{},
&BootstrapProvider{}, &BootstrapProviderList{},
&ControlPlaneProvider{}, &ControlPlaneProviderList{},
&InfrastructureProvider{}, &InfrastructureProviderList{},
&AddonProvider{}, &AddonProviderList{},
)

scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)

return nil
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha2/infrastructureprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type InfrastructureProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []InfrastructureProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &InfrastructureProvider{}, &InfrastructureProviderList{})
}
70 changes: 40 additions & 30 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package main
import (
"flag"
"fmt"
"net/http"
"os"
goruntime "runtime"
"time"

"github.com/spf13/pflag"
Expand All @@ -34,6 +34,7 @@ import (
"sigs.k8s.io/cluster-api-operator/internal/webhook"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
"sigs.k8s.io/cluster-api/util/flags"
"sigs.k8s.io/cluster-api/version"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -51,18 +52,20 @@ var (
setupLog = ctrl.Log.WithName("setup")

// flags.
metricsBindAddr string
enableLeaderElection bool
leaderElectionLeaseDuration time.Duration
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchFilterValue string
watchNamespace string
profilerAddress string
enableContentionProfiling bool
concurrencyNumber int
syncPeriod time.Duration
webhookPort int
webhookCertDir string
healthAddr string
diagnosticsOptions = flags.DiagnosticsOptions{}
)

func init() {
Expand All @@ -78,9 +81,6 @@ func init() {

// InitFlags initializes the flags.
func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&metricsBindAddr, "metrics-bind-addr", ":8080",
"The address the metric endpoint binds to.")

fs.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")

Expand All @@ -96,9 +96,15 @@ func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&watchFilterValue, "watch-filter", "",
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
"Enable block profiling")

fs.IntVar(&concurrencyNumber, "concurrency", 1,
"Number of core resources to process simultaneously")

Expand All @@ -112,45 +118,49 @@ func InitFlags(fs *pflag.FlagSet) {

fs.StringVar(&healthAddr, "health-addr", ":9440",
"The address the health endpoint binds to.")

flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
}

// Add RBAC for the authorized diagnostics endpoint.
// +kubebuilder:rbac:groups=authentication.k8s.io,resources=tokenreviews,verbs=create
// +kubebuilder:rbac:groups=authorization.k8s.io,resources=subjectaccessreviews,verbs=create

func main() {
InitFlags(pflag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()

ctrl.SetLogger(klogr.New())
restConfig := ctrl.GetConfigOrDie()

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)

go func() {
server := &http.Server{
Addr: profilerAddress,
ReadHeaderTimeout: 3 * time.Second,
}
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)

klog.Info(server.ListenAndServe())
}()
if enableContentionProfiling {
goruntime.SetBlockProfileRate(1)
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsBindAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "controller-leader-election-capi-operator",
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
SyncPeriod: &syncPeriod,
ClientDisableCacheFor: []client.Object{
&corev1.ConfigMap{},
&corev1.Secret{},
ctrlOptions := ctrl.Options{
Scheme: scheme,
LeaderElection: enableLeaderElection,
LeaderElectionID: "controller-leader-election-capi-operator",
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
Client: client.Options{
Cache: &client.CacheOptions{
DisableFor: []client.Object{
&corev1.ConfigMap{},
&corev1.Secret{},
},
},
},
Port: webhookPort,
CertDir: webhookCertDir,
HealthProbeBindAddress: healthAddr,
})
PprofBindAddress: profilerAddress,
Metrics: diagnosticsOpts,
}

mgr, err := ctrl.NewManager(restConfig, ctrlOptions)
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
Expand Down
26 changes: 26 additions & 0 deletions cmd/plugin/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ limitations under the License.
package cmd

import (
<<<<<<< HEAD

Check failure on line 20 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 20 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
"errors"
=======

Check failure on line 22 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 22 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
"context"
>>>>>>> 6a77079 (Bump CAPI to v1.6.0-rc.0)

Check failure on line 24 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 24 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
"flag"

Check failure on line 25 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

expected declaration, found "flag" (typecheck)

Check failure on line 25 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

expected declaration, found "flag" (typecheck)
"os"
"strings"
Expand Down Expand Up @@ -83,8 +87,30 @@ func init() {
Title: "Other Commands:",
})

<<<<<<< HEAD

Check failure on line 90 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '<<' (typecheck)

Check failure on line 90 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '<<' (typecheck)
RootCmd.SetHelpCommandGroupID(groupOther)
RootCmd.SetCompletionCommandGroupID(groupOther)
=======
func initConfig() {
// check if the CLUSTERCTL_LOG_LEVEL was set via env var or in the config file
if *verbosity == 0 { //nolint:nestif
configClient, err := configclient.New(context.Background(), cfgFile)
if err == nil {
v, err := configClient.Variables().Get("CLUSTERCTL_LOG_LEVEL")
if err == nil && v != "" {
verbosityFromEnv, err := strconv.Atoi(v)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to convert CLUSTERCTL_LOG_LEVEL string to an int. err=%s\n", err.Error())
os.Exit(1)
}

verbosity = &verbosityFromEnv
}
}
}

logf.SetLogger(logf.NewLogger(logf.WithThreshold(verbosity)))
>>>>>>> 6a77079 (Bump CAPI to v1.6.0-rc.0)

Check failure on line 113 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '>>' (typecheck)

Check failure on line 113 in cmd/plugin/cmd/root.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '>>' (typecheck)
}

const indentation = ` `
Expand Down
Loading

0 comments on commit 259e4ae

Please sign in to comment.