Skip to content

Commit 259e4ae

Browse files
Bump CAPI to v1.6.0-rc.0
Signed-off-by: Furkat Gofurov <[email protected]>
1 parent d0f318d commit 259e4ae

18 files changed

+531
-669
lines changed

api/v1alpha2/addonprovider_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ type AddonProviderList struct {
5353
metav1.ListMeta `json:"metadata,omitempty"`
5454
Items []AddonProvider `json:"items"`
5555
}
56+
57+
func init() {
58+
objectTypes = append(objectTypes, &AddonProvider{}, &AddonProviderList{})
59+
}

api/v1alpha2/bootstrapprovider_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ type BootstrapProviderList struct {
5353
metav1.ListMeta `json:"metadata,omitempty"`
5454
Items []BootstrapProvider `json:"items"`
5555
}
56+
57+
func init() {
58+
objectTypes = append(objectTypes, &BootstrapProvider{}, &BootstrapProviderList{})
59+
}

api/v1alpha2/controlplaneprovider_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ type ControlPlaneProviderList struct {
5353
metav1.ListMeta `json:"metadata,omitempty"`
5454
Items []ControlPlaneProvider `json:"items"`
5555
}
56+
57+
func init() {
58+
objectTypes = append(objectTypes, &ControlPlaneProvider{}, &ControlPlaneProviderList{})
59+
}

api/v1alpha2/coreprovider_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ type CoreProviderList struct {
5353
metav1.ListMeta `json:"metadata,omitempty"`
5454
Items []CoreProvider `json:"items"`
5555
}
56+
57+
func init() {
58+
objectTypes = append(objectTypes, &CoreProvider{}, &CoreProviderList{})
59+
}

api/v1alpha2/groupversion_info.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,13 @@ var (
3434

3535
// AddToScheme adds the types in this group-version to the given scheme.
3636
AddToScheme = SchemeBuilder.AddToScheme
37+
38+
objectTypes = []runtime.Object{}
3739
)
3840

3941
// Adds the list of known types to api.Scheme.
4042
func addKnownTypes(scheme *runtime.Scheme) error {
41-
scheme.AddKnownTypes(GroupVersion,
42-
&CoreProvider{}, &CoreProviderList{},
43-
&BootstrapProvider{}, &BootstrapProviderList{},
44-
&ControlPlaneProvider{}, &ControlPlaneProviderList{},
45-
&InfrastructureProvider{}, &InfrastructureProviderList{},
46-
&AddonProvider{}, &AddonProviderList{},
47-
)
48-
43+
scheme.AddKnownTypes(GroupVersion, objectTypes...)
4944
metav1.AddToGroupVersion(scheme, GroupVersion)
5045

5146
return nil

api/v1alpha2/infrastructureprovider_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ type InfrastructureProviderList struct {
5353
metav1.ListMeta `json:"metadata,omitempty"`
5454
Items []InfrastructureProvider `json:"items"`
5555
}
56+
57+
func init() {
58+
objectTypes = append(objectTypes, &InfrastructureProvider{}, &InfrastructureProviderList{})
59+
}

cmd/main.go

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package main
1919
import (
2020
"flag"
2121
"fmt"
22-
"net/http"
2322
"os"
23+
goruntime "runtime"
2424
"time"
2525

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

5354
// flags.
54-
metricsBindAddr string
5555
enableLeaderElection bool
5656
leaderElectionLeaseDuration time.Duration
5757
leaderElectionRenewDeadline time.Duration
5858
leaderElectionRetryPeriod time.Duration
5959
watchFilterValue string
60+
watchNamespace string
6061
profilerAddress string
62+
enableContentionProfiling bool
6163
concurrencyNumber int
6264
syncPeriod time.Duration
6365
webhookPort int
6466
webhookCertDir string
6567
healthAddr string
68+
diagnosticsOptions = flags.DiagnosticsOptions{}
6669
)
6770

6871
func init() {
@@ -78,9 +81,6 @@ func init() {
7881

7982
// InitFlags initializes the flags.
8083
func InitFlags(fs *pflag.FlagSet) {
81-
fs.StringVar(&metricsBindAddr, "metrics-bind-addr", ":8080",
82-
"The address the metric endpoint binds to.")
83-
8484
fs.BoolVar(&enableLeaderElection, "leader-elect", false,
8585
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
8686

@@ -96,9 +96,15 @@ func InitFlags(fs *pflag.FlagSet) {
9696
fs.StringVar(&watchFilterValue, "watch-filter", "",
9797
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))
9898

99+
fs.StringVar(&watchNamespace, "namespace", "",
100+
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")
101+
99102
fs.StringVar(&profilerAddress, "profiler-address", "",
100103
"Bind address to expose the pprof profiler (e.g. localhost:6060)")
101104

105+
fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
106+
"Enable block profiling")
107+
102108
fs.IntVar(&concurrencyNumber, "concurrency", 1,
103109
"Number of core resources to process simultaneously")
104110

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

113119
fs.StringVar(&healthAddr, "health-addr", ":9440",
114120
"The address the health endpoint binds to.")
121+
122+
flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
115123
}
116124

125+
// Add RBAC for the authorized diagnostics endpoint.
126+
// +kubebuilder:rbac:groups=authentication.k8s.io,resources=tokenreviews,verbs=create
127+
// +kubebuilder:rbac:groups=authorization.k8s.io,resources=subjectaccessreviews,verbs=create
128+
117129
func main() {
118130
InitFlags(pflag.CommandLine)
119131
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
120132
pflag.Parse()
121133

122134
ctrl.SetLogger(klogr.New())
135+
restConfig := ctrl.GetConfigOrDie()
123136

124-
if profilerAddress != "" {
125-
klog.Infof("Profiler listening for requests at %s", profilerAddress)
126-
127-
go func() {
128-
server := &http.Server{
129-
Addr: profilerAddress,
130-
ReadHeaderTimeout: 3 * time.Second,
131-
}
137+
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)
132138

133-
klog.Info(server.ListenAndServe())
134-
}()
139+
if enableContentionProfiling {
140+
goruntime.SetBlockProfileRate(1)
135141
}
136142

137-
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
138-
Scheme: scheme,
139-
MetricsBindAddress: metricsBindAddr,
140-
LeaderElection: enableLeaderElection,
141-
LeaderElectionID: "controller-leader-election-capi-operator",
142-
LeaseDuration: &leaderElectionLeaseDuration,
143-
RenewDeadline: &leaderElectionRenewDeadline,
144-
RetryPeriod: &leaderElectionRetryPeriod,
145-
SyncPeriod: &syncPeriod,
146-
ClientDisableCacheFor: []client.Object{
147-
&corev1.ConfigMap{},
148-
&corev1.Secret{},
143+
ctrlOptions := ctrl.Options{
144+
Scheme: scheme,
145+
LeaderElection: enableLeaderElection,
146+
LeaderElectionID: "controller-leader-election-capi-operator",
147+
LeaseDuration: &leaderElectionLeaseDuration,
148+
RenewDeadline: &leaderElectionRenewDeadline,
149+
RetryPeriod: &leaderElectionRetryPeriod,
150+
Client: client.Options{
151+
Cache: &client.CacheOptions{
152+
DisableFor: []client.Object{
153+
&corev1.ConfigMap{},
154+
&corev1.Secret{},
155+
},
156+
},
149157
},
150-
Port: webhookPort,
151-
CertDir: webhookCertDir,
152158
HealthProbeBindAddress: healthAddr,
153-
})
159+
PprofBindAddress: profilerAddress,
160+
Metrics: diagnosticsOpts,
161+
}
162+
163+
mgr, err := ctrl.NewManager(restConfig, ctrlOptions)
154164
if err != nil {
155165
setupLog.Error(err, "unable to start manager")
156166
os.Exit(1)

cmd/plugin/cmd/root.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ limitations under the License.
1717
package cmd
1818

1919
import (
20+
<<<<<<< HEAD
2021
"errors"
22+
=======
23+
"context"
24+
>>>>>>> 6a77079 (Bump CAPI to v1.6.0-rc.0)
2125
"flag"
2226
"os"
2327
"strings"
@@ -83,8 +87,30 @@ func init() {
8387
Title: "Other Commands:",
8488
})
8589

90+
<<<<<<< HEAD
8691
RootCmd.SetHelpCommandGroupID(groupOther)
8792
RootCmd.SetCompletionCommandGroupID(groupOther)
93+
=======
94+
func initConfig() {
95+
// check if the CLUSTERCTL_LOG_LEVEL was set via env var or in the config file
96+
if *verbosity == 0 { //nolint:nestif
97+
configClient, err := configclient.New(context.Background(), cfgFile)
98+
if err == nil {
99+
v, err := configClient.Variables().Get("CLUSTERCTL_LOG_LEVEL")
100+
if err == nil && v != "" {
101+
verbosityFromEnv, err := strconv.Atoi(v)
102+
if err != nil {
103+
fmt.Fprintf(os.Stderr, "Failed to convert CLUSTERCTL_LOG_LEVEL string to an int. err=%s\n", err.Error())
104+
os.Exit(1)
105+
}
106+
107+
verbosity = &verbosityFromEnv
108+
}
109+
}
110+
}
111+
112+
logf.SetLogger(logf.NewLogger(logf.WithThreshold(verbosity)))
113+
>>>>>>> 6a77079 (Bump CAPI to v1.6.0-rc.0)
88114
}
89115

90116
const indentation = ` `

0 commit comments

Comments
 (0)