mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
Refactor version/feature/cmd packages (#148)
Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
goflag "flag"
|
goflag "flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"open-cluster-management.io/ocm/pkg/cmd/hub"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,8 +14,7 @@ import (
|
|||||||
utilflag "k8s.io/component-base/cli/flag"
|
utilflag "k8s.io/component-base/cli/flag"
|
||||||
"k8s.io/component-base/logs"
|
"k8s.io/component-base/logs"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/placement/cmd/hub"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
"open-cluster-management.io/ocm/pkg/placement/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -49,7 +49,7 @@ func newPlacementCommand() *cobra.Command {
|
|||||||
cmd.Version = v
|
cmd.Version = v
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(hub.NewController())
|
cmd.AddCommand(hub.NewPlacementController())
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
goflag "flag"
|
goflag "flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"open-cluster-management.io/ocm/pkg/cmd/hub"
|
||||||
|
"open-cluster-management.io/ocm/pkg/cmd/spoke"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,8 +15,7 @@ import (
|
|||||||
utilflag "k8s.io/component-base/cli/flag"
|
utilflag "k8s.io/component-base/cli/flag"
|
||||||
"k8s.io/component-base/logs"
|
"k8s.io/component-base/logs"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration-operator/cmd/operator"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
"open-cluster-management.io/ocm/pkg/registration-operator/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -50,8 +51,8 @@ func newNucleusCommand() *cobra.Command {
|
|||||||
cmd.Version = v
|
cmd.Version = v
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(operator.NewHubOperatorCmd())
|
cmd.AddCommand(hub.NewHubOperatorCmd())
|
||||||
cmd.AddCommand(operator.NewKlusterletOperatorCmd())
|
cmd.AddCommand(spoke.NewKlusterletOperatorCmd())
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
goflag "flag"
|
goflag "flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"open-cluster-management.io/ocm/pkg/cmd/hub"
|
||||||
|
"open-cluster-management.io/ocm/pkg/cmd/spoke"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,10 +15,8 @@ import (
|
|||||||
utilflag "k8s.io/component-base/cli/flag"
|
utilflag "k8s.io/component-base/cli/flag"
|
||||||
"k8s.io/component-base/logs"
|
"k8s.io/component-base/logs"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/cmd/hub"
|
"open-cluster-management.io/ocm/pkg/cmd/webhook"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/cmd/spoke"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/cmd/webhook"
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The registration binary contains both the hub-side controllers for the
|
// The registration binary contains both the hub-side controllers for the
|
||||||
@@ -57,8 +57,8 @@ func newRegistrationCommand() *cobra.Command {
|
|||||||
cmd.Version = v
|
cmd.Version = v
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(hub.NewController())
|
cmd.AddCommand(hub.NewRegistrationController())
|
||||||
cmd.AddCommand(spoke.NewAgent())
|
cmd.AddCommand(spoke.NewRegistrationAgent())
|
||||||
cmd.AddCommand(webhook.NewWebhook())
|
cmd.AddCommand(webhook.NewRegistrationWebhook())
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
goflag "flag"
|
goflag "flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"open-cluster-management.io/ocm/pkg/cmd/hub"
|
||||||
|
"open-cluster-management.io/ocm/pkg/cmd/spoke"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,10 +15,8 @@ import (
|
|||||||
utilflag "k8s.io/component-base/cli/flag"
|
utilflag "k8s.io/component-base/cli/flag"
|
||||||
"k8s.io/component-base/logs"
|
"k8s.io/component-base/logs"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/cmd/hub"
|
"open-cluster-management.io/ocm/pkg/cmd/webhook"
|
||||||
"open-cluster-management.io/ocm/pkg/work/cmd/spoke"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
"open-cluster-management.io/ocm/pkg/work/cmd/webhook"
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -52,8 +52,8 @@ func newWorkCommand() *cobra.Command {
|
|||||||
cmd.Version = v
|
cmd.Version = v
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(spoke.NewWorkloadAgent())
|
cmd.AddCommand(spoke.NewWorkAgent())
|
||||||
cmd.AddCommand(webhook.NewWebhook())
|
cmd.AddCommand(webhook.NewWorkWebhook())
|
||||||
cmd.AddCommand(hub.NewHubManager())
|
cmd.AddCommand(hub.NewWorkController())
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package operator
|
package hub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration-operator/operators/clustermanager"
|
"open-cluster-management.io/ocm/pkg/registration-operator/operators/clustermanager"
|
||||||
"open-cluster-management.io/ocm/pkg/registration-operator/version"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewHubOperatorCmd generatee a command to start hub operator
|
// NewHubOperatorCmd generatee a command to start hub operator
|
||||||
@@ -6,10 +6,10 @@ import (
|
|||||||
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
||||||
|
|
||||||
controllers "open-cluster-management.io/ocm/pkg/placement/controllers"
|
controllers "open-cluster-management.io/ocm/pkg/placement/controllers"
|
||||||
"open-cluster-management.io/ocm/pkg/placement/version"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewController() *cobra.Command {
|
func NewPlacementController() *cobra.Command {
|
||||||
cmd := controllercmd.
|
cmd := controllercmd.
|
||||||
NewControllerCommandConfig("placement", version.Get(), controllers.RunControllerManager).
|
NewControllerCommandConfig("placement", version.Get(), controllers.RunControllerManager).
|
||||||
NewCommand()
|
NewCommand()
|
||||||
@@ -8,10 +8,10 @@ import (
|
|||||||
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/hub"
|
"open-cluster-management.io/ocm/pkg/registration/hub"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/version"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewController() *cobra.Command {
|
func NewRegistrationController() *cobra.Command {
|
||||||
manager := hub.NewHubManagerOptions()
|
manager := hub.NewHubManagerOptions()
|
||||||
cmdConfig := controllercmd.
|
cmdConfig := controllercmd.
|
||||||
NewControllerCommandConfig("registration-controller", version.Get(), manager.RunControllerManager)
|
NewControllerCommandConfig("registration-controller", version.Get(), manager.RunControllerManager)
|
||||||
@@ -5,12 +5,12 @@ import (
|
|||||||
|
|
||||||
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
||||||
|
|
||||||
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
"open-cluster-management.io/ocm/pkg/work/hub"
|
"open-cluster-management.io/ocm/pkg/work/hub"
|
||||||
"open-cluster-management.io/ocm/pkg/work/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewHubManager generates a command to start hub manager
|
// NewHubManager generates a command to start hub manager
|
||||||
func NewHubManager() *cobra.Command {
|
func NewWorkController() *cobra.Command {
|
||||||
cmdConfig := controllercmd.
|
cmdConfig := controllercmd.
|
||||||
NewControllerCommandConfig("work-manager", version.Get(), hub.RunWorkHubManager)
|
NewControllerCommandConfig("work-manager", version.Get(), hub.RunWorkHubManager)
|
||||||
cmd := cmdConfig.NewCommand()
|
cmd := cmdConfig.NewCommand()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package operator
|
package spoke
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration-operator/operators/klusterlet"
|
"open-cluster-management.io/ocm/pkg/registration-operator/operators/klusterlet"
|
||||||
"open-cluster-management.io/ocm/pkg/registration-operator/version"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewKlusterletOperatorCmd generatee a command to start klusterlet operator
|
// NewKlusterletOperatorCmd generatee a command to start klusterlet operator
|
||||||
@@ -6,10 +6,10 @@ import (
|
|||||||
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/version"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewAgent() *cobra.Command {
|
func NewRegistrationAgent() *cobra.Command {
|
||||||
agentOptions := spoke.NewSpokeAgentOptions()
|
agentOptions := spoke.NewSpokeAgentOptions()
|
||||||
cmdConfig := controllercmd.
|
cmdConfig := controllercmd.
|
||||||
NewControllerCommandConfig("registration-agent", version.Get(), agentOptions.RunSpokeAgent)
|
NewControllerCommandConfig("registration-agent", version.Get(), agentOptions.RunSpokeAgent)
|
||||||
@@ -5,12 +5,12 @@ import (
|
|||||||
|
|
||||||
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
||||||
|
|
||||||
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
"open-cluster-management.io/ocm/pkg/work/spoke"
|
"open-cluster-management.io/ocm/pkg/work/spoke"
|
||||||
"open-cluster-management.io/ocm/pkg/work/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewWorkloadAgent generates a command to start workload agent
|
// NewWorkAgent generates a command to start work agent
|
||||||
func NewWorkloadAgent() *cobra.Command {
|
func NewWorkAgent() *cobra.Command {
|
||||||
o := spoke.NewWorkloadAgentOptions()
|
o := spoke.NewWorkloadAgentOptions()
|
||||||
cmdConfig := controllercmd.
|
cmdConfig := controllercmd.
|
||||||
NewControllerCommandConfig("work-agent", version.Get(), o.RunWorkloadAgent)
|
NewControllerCommandConfig("work-agent", version.Get(), o.RunWorkloadAgent)
|
||||||
25
pkg/cmd/webhook/registration.go
Normal file
25
pkg/cmd/webhook/registration.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
|
"open-cluster-management.io/ocm/pkg/registration/webhook"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewRegistrationWebhook() *cobra.Command {
|
||||||
|
ops := webhook.NewOptions()
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "webhook-server",
|
||||||
|
Short: "Start the registration webhook server",
|
||||||
|
RunE: func(c *cobra.Command, args []string) error {
|
||||||
|
err := ops.RunWebhookServer()
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags := cmd.Flags()
|
||||||
|
ops.AddFlags(flags)
|
||||||
|
|
||||||
|
features.DefaultHubRegistrationMutableFeatureGate.AddFlag(flags)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
27
pkg/cmd/webhook/work.go
Normal file
27
pkg/cmd/webhook/work.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
|
_ "open-cluster-management.io/ocm/pkg/features"
|
||||||
|
"open-cluster-management.io/ocm/pkg/work/webhook"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewWorkWebhook() *cobra.Command {
|
||||||
|
ops := webhook.NewOptions()
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "webhook-server",
|
||||||
|
Short: "Start the work webhook server",
|
||||||
|
RunE: func(c *cobra.Command, args []string) error {
|
||||||
|
err := ops.RunWebhookServer()
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags := cmd.Flags()
|
||||||
|
ops.AddFlags(flags)
|
||||||
|
|
||||||
|
features.DefaultHubWorkMutableFeatureGate.AddFlag(flags)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
31
pkg/features/feature.go
Normal file
31
pkg/features/feature.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (c) Red Hat, Inc.
|
||||||
|
// Copyright Contributors to the Open Cluster Management project
|
||||||
|
|
||||||
|
package features
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/util/runtime"
|
||||||
|
"k8s.io/component-base/featuregate"
|
||||||
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultHubWorkMutableFeatureGate is made up of multiple mutable feature-gates for work controller
|
||||||
|
DefaultHubWorkMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
|
||||||
|
|
||||||
|
// DefaultSpokeWorkMutableFeatureGate is made up of multiple mutable feature-gates for work agent.
|
||||||
|
DefaultSpokeWorkMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
|
||||||
|
|
||||||
|
// DefaultSpokeRegistrationMutableFeatureGate is made up of multiple mutable feature-gates for registration agent.
|
||||||
|
DefaultSpokeRegistrationMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
|
||||||
|
|
||||||
|
// DefaultHubRegistrationMutableFeatureGate made up of multiple mutable feature-gates for registration hub controller.
|
||||||
|
DefaultHubRegistrationMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
runtime.Must(DefaultHubWorkMutableFeatureGate.Add(ocmfeature.DefaultHubWorkFeatureGates))
|
||||||
|
runtime.Must(DefaultSpokeWorkMutableFeatureGate.Add(ocmfeature.DefaultSpokeWorkFeatureGates))
|
||||||
|
runtime.Must(DefaultSpokeRegistrationMutableFeatureGate.Add(ocmfeature.DefaultSpokeRegistrationFeatureGates))
|
||||||
|
runtime.Must(DefaultHubRegistrationMutableFeatureGate.Add(ocmfeature.DefaultHubRegistrationFeatureGates))
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
//go:build tools
|
|
||||||
// +build tools
|
|
||||||
|
|
||||||
// go mod won't pull in code that isn't depended upon, but we have some code we don't depend on from code that must be included
|
|
||||||
// for our build to work.
|
|
||||||
package dependencymagnet
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "github.com/openshift/build-machinery-go"
|
|
||||||
)
|
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
versionutil "k8s.io/apimachinery/pkg/util/version"
|
versionutil "k8s.io/apimachinery/pkg/util/version"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"open-cluster-management.io/ocm/pkg/registration-operator/version"
|
"open-cluster-management.io/ocm/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// versionAnnotationKey is an annotation key on crd resources to mark the ocm version of the crds.
|
// versionAnnotationKey is an annotation key on crd resources to mark the ocm version of the crds.
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package version
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/version"
|
|
||||||
"k8s.io/component-base/metrics"
|
|
||||||
"k8s.io/component-base/metrics/legacyregistry"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// commitFromGit is a constant representing the source version that
|
|
||||||
// generated this build. It should be set during build via -ldflags.
|
|
||||||
commitFromGit string
|
|
||||||
// versionFromGit is a constant representing the version tag that
|
|
||||||
// generated this build. It should be set during build via -ldflags.
|
|
||||||
versionFromGit string
|
|
||||||
// major version
|
|
||||||
majorFromGit string
|
|
||||||
// minor version
|
|
||||||
minorFromGit string
|
|
||||||
// build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
||||||
buildDate string
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get returns the overall codebase version. It's for detecting
|
|
||||||
// what code a binary was built from.
|
|
||||||
func Get() version.Info {
|
|
||||||
return version.Info{
|
|
||||||
Major: majorFromGit,
|
|
||||||
Minor: minorFromGit,
|
|
||||||
GitCommit: commitFromGit,
|
|
||||||
GitVersion: versionFromGit,
|
|
||||||
BuildDate: buildDate,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
buildInfo := metrics.NewGaugeVec(
|
|
||||||
&metrics.GaugeOpts{
|
|
||||||
Name: "open_cluster_management_registration_build_info",
|
|
||||||
Help: "A metric with a constant '1' value labeled by major, minor, git commit & git version from which Open Cluster Management Registration was built.",
|
|
||||||
},
|
|
||||||
[]string{"major", "minor", "gitCommit", "gitVersion"},
|
|
||||||
)
|
|
||||||
buildInfo.WithLabelValues(majorFromGit, minorFromGit, commitFromGit, versionFromGit).Set(1)
|
|
||||||
|
|
||||||
legacyregistry.MustRegister(buildInfo)
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
certutil "k8s.io/client-go/util/cert"
|
certutil "k8s.io/client-go/util/cert"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ func (v *v1CSRControl) get(name string) (metav1.Object, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewCSRControl(hubCSRInformer certificatesinformers.Interface, hubKubeClient kubernetes.Interface) (CSRControl, error) {
|
func NewCSRControl(hubCSRInformer certificatesinformers.Interface, hubKubeClient kubernetes.Interface) (CSRControl, error) {
|
||||||
if features.DefaultSpokeMutableFeatureGate.Enabled(ocmfeature.V1beta1CSRAPICompatibility) {
|
if features.DefaultSpokeRegistrationMutableFeatureGate.Enabled(ocmfeature.V1beta1CSRAPICompatibility) {
|
||||||
v1CSRSupported, v1beta1CSRSupported, err := helpers.IsCSRSupported(hubKubeClient)
|
v1CSRSupported, v1beta1CSRSupported, err := helpers.IsCSRSupported(hubKubeClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package webhook
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewWebhook() *cobra.Command {
|
|
||||||
ops := NewOptions()
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "webhook-server",
|
|
||||||
Short: "Start the webhook server",
|
|
||||||
RunE: func(c *cobra.Command, args []string) error {
|
|
||||||
err := ops.RunWebhookServer()
|
|
||||||
return err
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
flags := cmd.Flags()
|
|
||||||
ops.AddFlags(flags)
|
|
||||||
|
|
||||||
features.DefaultHubMutableFeatureGate.AddFlag(flags)
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package features
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/util/runtime"
|
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
"k8s.io/component-base/featuregate"
|
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// DefaultSpokeMutableFeatureGate is made up of multiple mutable feature-gates for registration agent.
|
|
||||||
DefaultSpokeMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
|
|
||||||
|
|
||||||
// DefaultHubMutableFeatureGate made up of multiple mutable feature-gates for registration hub controller.
|
|
||||||
DefaultHubMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
runtime.Must(DefaultSpokeMutableFeatureGate.Add(ocmfeature.DefaultSpokeRegistrationFeatureGates))
|
|
||||||
runtime.Must(DefaultHubMutableFeatureGate.Add(ocmfeature.DefaultHubRegistrationFeatureGates))
|
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(ocmfeature.DefaultHubRegistrationFeatureGates))
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/hub/managedclustersetbinding"
|
"open-cluster-management.io/ocm/pkg/registration/hub/managedclustersetbinding"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/hub/taint"
|
"open-cluster-management.io/ocm/pkg/registration/hub/taint"
|
||||||
@@ -53,7 +53,7 @@ func NewHubManagerOptions() *HubManagerOptions {
|
|||||||
|
|
||||||
// AddFlags registers flags for manager
|
// AddFlags registers flags for manager
|
||||||
func (m *HubManagerOptions) AddFlags(fs *pflag.FlagSet) {
|
func (m *HubManagerOptions) AddFlags(fs *pflag.FlagSet) {
|
||||||
features.DefaultHubMutableFeatureGate.AddFlag(fs)
|
features.DefaultHubRegistrationMutableFeatureGate.AddFlag(fs)
|
||||||
fs.StringSliceVar(&m.ClusterAutoApprovalUsers, "cluster-auto-approval-users", m.ClusterAutoApprovalUsers,
|
fs.StringSliceVar(&m.ClusterAutoApprovalUsers, "cluster-auto-approval-users", m.ClusterAutoApprovalUsers,
|
||||||
"A bootstrap user list whose cluster registration requests can be automatically approved.")
|
"A bootstrap user list whose cluster registration requests can be automatically approved.")
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ func (m *HubManagerOptions) RunControllerManager(ctx context.Context, controller
|
|||||||
)
|
)
|
||||||
|
|
||||||
csrReconciles := []csr.Reconciler{csr.NewCSRRenewalReconciler(kubeClient, controllerContext.EventRecorder)}
|
csrReconciles := []csr.Reconciler{csr.NewCSRRenewalReconciler(kubeClient, controllerContext.EventRecorder)}
|
||||||
if features.DefaultHubMutableFeatureGate.Enabled(ocmfeature.ManagedClusterAutoApproval) {
|
if features.DefaultHubRegistrationMutableFeatureGate.Enabled(ocmfeature.ManagedClusterAutoApproval) {
|
||||||
csrReconciles = append(csrReconciles, csr.NewCSRBootstrapReconciler(
|
csrReconciles = append(csrReconciles, csr.NewCSRBootstrapReconciler(
|
||||||
kubeClient,
|
kubeClient,
|
||||||
clusterClient,
|
clusterClient,
|
||||||
@@ -120,7 +120,7 @@ func (m *HubManagerOptions) RunControllerManager(ctx context.Context, controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
var csrController factory.Controller
|
var csrController factory.Controller
|
||||||
if features.DefaultHubMutableFeatureGate.Enabled(ocmfeature.V1beta1CSRAPICompatibility) {
|
if features.DefaultHubRegistrationMutableFeatureGate.Enabled(ocmfeature.V1beta1CSRAPICompatibility) {
|
||||||
v1CSRSupported, v1beta1CSRSupported, err := helpers.IsCSRSupported(kubeClient)
|
v1CSRSupported, v1beta1CSRSupported, err := helpers.IsCSRSupported(kubeClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed CSR api discovery")
|
return errors.Wrapf(err, "failed CSR api discovery")
|
||||||
@@ -201,7 +201,7 @@ func (m *HubManagerOptions) RunControllerManager(ctx context.Context, controller
|
|||||||
)
|
)
|
||||||
|
|
||||||
var defaultManagedClusterSetController, globalManagedClusterSetController factory.Controller
|
var defaultManagedClusterSetController, globalManagedClusterSetController factory.Controller
|
||||||
if features.DefaultHubMutableFeatureGate.Enabled(ocmfeature.DefaultClusterSet) {
|
if features.DefaultHubRegistrationMutableFeatureGate.Enabled(ocmfeature.DefaultClusterSet) {
|
||||||
defaultManagedClusterSetController = managedclusterset.NewDefaultManagedClusterSetController(
|
defaultManagedClusterSetController = managedclusterset.NewDefaultManagedClusterSetController(
|
||||||
clusterClient.ClusterV1beta2(),
|
clusterClient.ClusterV1beta2(),
|
||||||
clusterInformers.Cluster().V1beta2().ManagedClusterSets(),
|
clusterInformers.Cluster().V1beta2().ManagedClusterSets(),
|
||||||
@@ -229,7 +229,7 @@ func (m *HubManagerOptions) RunControllerManager(ctx context.Context, controller
|
|||||||
go clusterroleController.Run(ctx, 1)
|
go clusterroleController.Run(ctx, 1)
|
||||||
go addOnHealthCheckController.Run(ctx, 1)
|
go addOnHealthCheckController.Run(ctx, 1)
|
||||||
go addOnFeatureDiscoveryController.Run(ctx, 1)
|
go addOnFeatureDiscoveryController.Run(ctx, 1)
|
||||||
if features.DefaultHubMutableFeatureGate.Enabled(ocmfeature.DefaultClusterSet) {
|
if features.DefaultHubRegistrationMutableFeatureGate.Enabled(ocmfeature.DefaultClusterSet) {
|
||||||
go defaultManagedClusterSetController.Run(ctx, 1)
|
go defaultManagedClusterSetController.Run(ctx, 1)
|
||||||
go globalManagedClusterSetController.Run(ctx, 1)
|
go globalManagedClusterSetController.Run(ctx, 1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import (
|
|||||||
addoninformers "open-cluster-management.io/api/client/addon/informers/externalversions"
|
addoninformers "open-cluster-management.io/api/client/addon/informers/externalversions"
|
||||||
clusterv1client "open-cluster-management.io/api/client/cluster/clientset/versioned"
|
clusterv1client "open-cluster-management.io/api/client/cluster/clientset/versioned"
|
||||||
clusterv1informers "open-cluster-management.io/api/client/cluster/informers/externalversions"
|
clusterv1informers "open-cluster-management.io/api/client/cluster/informers/externalversions"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke/addon"
|
"open-cluster-management.io/ocm/pkg/registration/spoke/addon"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke/managedcluster"
|
"open-cluster-management.io/ocm/pkg/registration/spoke/managedcluster"
|
||||||
@@ -347,7 +347,7 @@ func (o *SpokeAgentOptions) RunSpokeAgent(ctx context.Context, controllerContext
|
|||||||
spokeClusterInformerFactory := clusterv1informers.NewSharedInformerFactory(spokeClusterClient, 10*time.Minute)
|
spokeClusterInformerFactory := clusterv1informers.NewSharedInformerFactory(spokeClusterClient, 10*time.Minute)
|
||||||
|
|
||||||
var managedClusterClaimController factory.Controller
|
var managedClusterClaimController factory.Controller
|
||||||
if features.DefaultSpokeMutableFeatureGate.Enabled(ocmfeature.ClusterClaim) {
|
if features.DefaultSpokeRegistrationMutableFeatureGate.Enabled(ocmfeature.ClusterClaim) {
|
||||||
// create managedClusterClaimController to sync cluster claims
|
// create managedClusterClaimController to sync cluster claims
|
||||||
managedClusterClaimController = managedcluster.NewManagedClusterClaimController(
|
managedClusterClaimController = managedcluster.NewManagedClusterClaimController(
|
||||||
o.ClusterName,
|
o.ClusterName,
|
||||||
@@ -361,7 +361,7 @@ func (o *SpokeAgentOptions) RunSpokeAgent(ctx context.Context, controllerContext
|
|||||||
|
|
||||||
var addOnLeaseController factory.Controller
|
var addOnLeaseController factory.Controller
|
||||||
var addOnRegistrationController factory.Controller
|
var addOnRegistrationController factory.Controller
|
||||||
if features.DefaultSpokeMutableFeatureGate.Enabled(ocmfeature.AddonManagement) {
|
if features.DefaultSpokeRegistrationMutableFeatureGate.Enabled(ocmfeature.AddonManagement) {
|
||||||
addOnLeaseController = addon.NewManagedClusterAddOnLeaseController(
|
addOnLeaseController = addon.NewManagedClusterAddOnLeaseController(
|
||||||
o.ClusterName,
|
o.ClusterName,
|
||||||
addOnClient,
|
addOnClient,
|
||||||
@@ -397,10 +397,10 @@ func (o *SpokeAgentOptions) RunSpokeAgent(ctx context.Context, controllerContext
|
|||||||
go managedClusterJoiningController.Run(ctx, 1)
|
go managedClusterJoiningController.Run(ctx, 1)
|
||||||
go managedClusterLeaseController.Run(ctx, 1)
|
go managedClusterLeaseController.Run(ctx, 1)
|
||||||
go managedClusterHealthCheckController.Run(ctx, 1)
|
go managedClusterHealthCheckController.Run(ctx, 1)
|
||||||
if features.DefaultSpokeMutableFeatureGate.Enabled(ocmfeature.ClusterClaim) {
|
if features.DefaultSpokeRegistrationMutableFeatureGate.Enabled(ocmfeature.ClusterClaim) {
|
||||||
go managedClusterClaimController.Run(ctx, 1)
|
go managedClusterClaimController.Run(ctx, 1)
|
||||||
}
|
}
|
||||||
if features.DefaultSpokeMutableFeatureGate.Enabled(ocmfeature.AddonManagement) {
|
if features.DefaultSpokeRegistrationMutableFeatureGate.Enabled(ocmfeature.AddonManagement) {
|
||||||
go addOnLeaseController.Run(ctx, 1)
|
go addOnLeaseController.Run(ctx, 1)
|
||||||
go addOnRegistrationController.Run(ctx, 1)
|
go addOnRegistrationController.Run(ctx, 1)
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ func (o *SpokeAgentOptions) RunSpokeAgent(ctx context.Context, controllerContext
|
|||||||
|
|
||||||
// AddFlags registers flags for Agent
|
// AddFlags registers flags for Agent
|
||||||
func (o *SpokeAgentOptions) AddFlags(fs *pflag.FlagSet) {
|
func (o *SpokeAgentOptions) AddFlags(fs *pflag.FlagSet) {
|
||||||
features.DefaultSpokeMutableFeatureGate.AddFlag(fs)
|
features.DefaultSpokeRegistrationMutableFeatureGate.AddFlag(fs)
|
||||||
fs.StringVar(&o.ClusterName, "cluster-name", o.ClusterName,
|
fs.StringVar(&o.ClusterName, "cluster-name", o.ClusterName,
|
||||||
"If non-empty, will use as cluster name instead of generated random name.")
|
"If non-empty, will use as cluster name instead of generated random name.")
|
||||||
fs.StringVar(&o.BootstrapKubeconfig, "bootstrap-kubeconfig", o.BootstrapKubeconfig,
|
fs.StringVar(&o.BootstrapKubeconfig, "bootstrap-kubeconfig", o.BootstrapKubeconfig,
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package version
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/version"
|
|
||||||
"k8s.io/component-base/metrics"
|
|
||||||
"k8s.io/component-base/metrics/legacyregistry"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// commitFromGit is a constant representing the source version that
|
|
||||||
// generated this build. It should be set during build via -ldflags.
|
|
||||||
commitFromGit string
|
|
||||||
// versionFromGit is a constant representing the version tag that
|
|
||||||
// generated this build. It should be set during build via -ldflags.
|
|
||||||
versionFromGit string
|
|
||||||
// major version
|
|
||||||
majorFromGit string
|
|
||||||
// minor version
|
|
||||||
minorFromGit string
|
|
||||||
// build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
||||||
buildDate string
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get returns the overall codebase version. It's for detecting
|
|
||||||
// what code a binary was built from.
|
|
||||||
func Get() version.Info {
|
|
||||||
return version.Info{
|
|
||||||
Major: majorFromGit,
|
|
||||||
Minor: minorFromGit,
|
|
||||||
GitCommit: commitFromGit,
|
|
||||||
GitVersion: versionFromGit,
|
|
||||||
BuildDate: buildDate,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
buildInfo := metrics.NewGaugeVec(
|
|
||||||
&metrics.GaugeOpts{
|
|
||||||
Name: "open_cluster_management_registration_build_info",
|
|
||||||
Help: "A metric with a constant '1' value labeled by major, minor, git commit & git version from which Open Cluster Management Registration was built.",
|
|
||||||
},
|
|
||||||
[]string{"major", "minor", "gitCommit", "gitVersion"},
|
|
||||||
)
|
|
||||||
buildInfo.WithLabelValues(majorFromGit, minorFromGit, commitFromGit, versionFromGit).Set(1)
|
|
||||||
|
|
||||||
legacyregistry.MustRegister(buildInfo)
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
||||||
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
|
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
"open-cluster-management.io/ocm/pkg/registration/helpers"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||||
@@ -52,7 +52,7 @@ func (r *ManagedClusterWebhook) Default(ctx context.Context, obj runtime.Object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Set default clusterset label
|
//Set default clusterset label
|
||||||
if features.DefaultHubMutableFeatureGate.Enabled(ocmfeature.DefaultClusterSet) {
|
if features.DefaultHubRegistrationMutableFeatureGate.Enabled(ocmfeature.DefaultClusterSet) {
|
||||||
r.addDefaultClusterSetLabel(managedCluster)
|
r.addDefaultClusterSetLabel(managedCluster)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/runtime"
|
"k8s.io/apimachinery/pkg/util/runtime"
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
|
|
||||||
admissionv1 "k8s.io/api/admission/v1"
|
admissionv1 "k8s.io/api/admission/v1"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||||
@@ -447,8 +447,8 @@ func TestDefault(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
runtime.Must(features.DefaultHubMutableFeatureGate.Add(ocmfeature.DefaultHubRegistrationFeatureGates))
|
runtime.Must(features.DefaultHubRegistrationMutableFeatureGate.Add(ocmfeature.DefaultHubRegistrationFeatureGates))
|
||||||
if err := features.DefaultHubMutableFeatureGate.Set(fmt.Sprintf("%s=true", string(ocmfeature.DefaultClusterSet))); err != nil {
|
if err := features.DefaultHubRegistrationMutableFeatureGate.Set(fmt.Sprintf("%s=true", string(ocmfeature.DefaultClusterSet))); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ func Get() version.Info {
|
|||||||
func init() {
|
func init() {
|
||||||
buildInfo := metrics.NewGaugeVec(
|
buildInfo := metrics.NewGaugeVec(
|
||||||
&metrics.GaugeOpts{
|
&metrics.GaugeOpts{
|
||||||
Name: "open_cluster_management_placement_build_info",
|
Name: "open_cluster_management_build_info",
|
||||||
Help: "A metric with a constant '1' value labeled by major, minor, git commit & git version from which Open Cluster Management Placement was built.",
|
Help: "A metric with a constant '1' value labeled by major, minor, git commit & git version from which Open Cluster Management was built.",
|
||||||
},
|
},
|
||||||
[]string{"major", "minor", "gitCommit", "gitVersion"},
|
[]string{"major", "minor", "gitCommit", "gitVersion"},
|
||||||
)
|
)
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package webhook
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
_ "open-cluster-management.io/ocm/pkg/work/features"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewWebhook() *cobra.Command {
|
|
||||||
ops := NewOptions()
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "webhook-server",
|
|
||||||
Short: "Start the webhook server",
|
|
||||||
RunE: func(c *cobra.Command, args []string) error {
|
|
||||||
err := ops.RunWebhookServer()
|
|
||||||
return err
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
flags := cmd.Flags()
|
|
||||||
ops.AddFlags(flags)
|
|
||||||
featureGate := utilfeature.DefaultMutableFeatureGate
|
|
||||||
featureGate.AddFlag(flags)
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
//go:build tools
|
|
||||||
// +build tools
|
|
||||||
|
|
||||||
// go mod won't pull in code that isn't depended upon, but we have some code we don't depend on from code that must be included
|
|
||||||
// for our build to work.
|
|
||||||
package dependencymagnet
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "github.com/openshift/build-machinery-go"
|
|
||||||
)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
// Copyright (c) Red Hat, Inc.
|
|
||||||
// Copyright Contributors to the Open Cluster Management project
|
|
||||||
|
|
||||||
package features
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/util/runtime"
|
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
"k8s.io/component-base/featuregate"
|
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// DefaultSpokeMutableFeatureGate is made up of multiple mutable feature-gates for work agent.
|
|
||||||
DefaultSpokeMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
runtime.Must(DefaultSpokeMutableFeatureGate.Add(ocmfeature.DefaultSpokeWorkFeatureGates))
|
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(ocmfeature.DefaultHubWorkFeatureGates))
|
|
||||||
}
|
|
||||||
@@ -3,12 +3,12 @@ package spoke
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
workclientset "open-cluster-management.io/api/client/work/clientset/versioned"
|
workclientset "open-cluster-management.io/api/client/work/clientset/versioned"
|
||||||
workinformers "open-cluster-management.io/api/client/work/informers/externalversions"
|
workinformers "open-cluster-management.io/api/client/work/informers/externalversions"
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
"open-cluster-management.io/ocm/pkg/work/features"
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/helper"
|
"open-cluster-management.io/ocm/pkg/work/helper"
|
||||||
"open-cluster-management.io/ocm/pkg/work/spoke/auth"
|
"open-cluster-management.io/ocm/pkg/work/spoke/auth"
|
||||||
"open-cluster-management.io/ocm/pkg/work/spoke/controllers/appliedmanifestcontroller"
|
"open-cluster-management.io/ocm/pkg/work/spoke/controllers/appliedmanifestcontroller"
|
||||||
@@ -63,7 +63,7 @@ func NewWorkloadAgentOptions() *WorkloadAgentOptions {
|
|||||||
// AddFlags register and binds the default flags
|
// AddFlags register and binds the default flags
|
||||||
func (o *WorkloadAgentOptions) AddFlags(cmd *cobra.Command) {
|
func (o *WorkloadAgentOptions) AddFlags(cmd *cobra.Command) {
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
features.DefaultSpokeMutableFeatureGate.AddFlag(flags)
|
features.DefaultSpokeWorkMutableFeatureGate.AddFlag(flags)
|
||||||
// This command only supports reading from config
|
// This command only supports reading from config
|
||||||
flags.StringVar(&o.HubKubeconfigFile, "hub-kubeconfig", o.HubKubeconfigFile, "Location of kubeconfig file to connect to hub cluster.")
|
flags.StringVar(&o.HubKubeconfigFile, "hub-kubeconfig", o.HubKubeconfigFile, "Location of kubeconfig file to connect to hub cluster.")
|
||||||
flags.StringVar(&o.SpokeKubeconfigFile, "spoke-kubeconfig", o.SpokeKubeconfigFile,
|
flags.StringVar(&o.SpokeKubeconfigFile, "spoke-kubeconfig", o.SpokeKubeconfigFile,
|
||||||
@@ -135,7 +135,7 @@ func (o *WorkloadAgentOptions) RunWorkloadAgent(ctx context.Context, controllerC
|
|||||||
o.SpokeClusterName,
|
o.SpokeClusterName,
|
||||||
controllerContext.EventRecorder,
|
controllerContext.EventRecorder,
|
||||||
restMapper,
|
restMapper,
|
||||||
).NewExecutorValidator(ctx, features.DefaultSpokeMutableFeatureGate.Enabled(ocmfeature.ExecutorValidatingCaches))
|
).NewExecutorValidator(ctx, features.DefaultSpokeWorkMutableFeatureGate.Enabled(ocmfeature.ExecutorValidatingCaches))
|
||||||
|
|
||||||
manifestWorkController := manifestcontroller.NewManifestWorkController(
|
manifestWorkController := manifestcontroller.NewManifestWorkController(
|
||||||
controllerContext.EventRecorder,
|
controllerContext.EventRecorder,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package statusfeedback
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
@@ -12,7 +13,6 @@ import (
|
|||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
"k8s.io/client-go/util/jsonpath"
|
"k8s.io/client-go/util/jsonpath"
|
||||||
workapiv1 "open-cluster-management.io/api/work/v1"
|
workapiv1 "open-cluster-management.io/api/work/v1"
|
||||||
"open-cluster-management.io/ocm/pkg/work/features"
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/spoke/statusfeedback/rules"
|
"open-cluster-management.io/ocm/pkg/work/spoke/statusfeedback/rules"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ func getValueByJsonPath(name, path string, obj *unstructured.Unstructured) (*wor
|
|||||||
Value: fieldValue,
|
Value: fieldValue,
|
||||||
}, nil
|
}, nil
|
||||||
default:
|
default:
|
||||||
if features.DefaultSpokeMutableFeatureGate.Enabled(ocmfeature.RawFeedbackJsonString) {
|
if features.DefaultSpokeWorkMutableFeatureGate.Enabled(ocmfeature.RawFeedbackJsonString) {
|
||||||
jsonRaw, err := json.Marshal(&t)
|
jsonRaw, err := json.Marshal(&t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse the resource to json string for name %s: %v", name, err)
|
return nil, fmt.Errorf("failed to parse the resource to json string for name %s: %v", name, err)
|
||||||
|
|||||||
@@ -2,14 +2,13 @@ package statusfeedback
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/utils/pointer"
|
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/features"
|
|
||||||
|
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
|
"k8s.io/utils/pointer"
|
||||||
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
workapiv1 "open-cluster-management.io/api/work/v1"
|
workapiv1 "open-cluster-management.io/api/work/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -286,7 +285,7 @@ func TestStatusReader(t *testing.T) {
|
|||||||
reader := NewStatusReader()
|
reader := NewStatusReader()
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
err := features.DefaultSpokeMutableFeatureGate.Set(fmt.Sprintf("%s=%t", ocmfeature.RawFeedbackJsonString, c.enableRaw))
|
err := features.DefaultSpokeWorkMutableFeatureGate.Set(fmt.Sprintf("%s=%t", ocmfeature.RawFeedbackJsonString, c.enableRaw))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package version
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/version"
|
|
||||||
"k8s.io/component-base/metrics"
|
|
||||||
"k8s.io/component-base/metrics/legacyregistry"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// commitFromGit is a constant representing the source version that
|
|
||||||
// generated this build. It should be set during build via -ldflags.
|
|
||||||
commitFromGit string
|
|
||||||
// versionFromGit is a constant representing the version tag that
|
|
||||||
// generated this build. It should be set during build via -ldflags.
|
|
||||||
versionFromGit string
|
|
||||||
// major version
|
|
||||||
majorFromGit string
|
|
||||||
// minor version
|
|
||||||
minorFromGit string
|
|
||||||
// build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
||||||
buildDate string
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get returns the overall codebase version. It's for detecting
|
|
||||||
// what code a binary was built from.
|
|
||||||
func Get() version.Info {
|
|
||||||
return version.Info{
|
|
||||||
Major: majorFromGit,
|
|
||||||
Minor: minorFromGit,
|
|
||||||
GitCommit: commitFromGit,
|
|
||||||
GitVersion: versionFromGit,
|
|
||||||
BuildDate: buildDate,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
buildInfo := metrics.NewGaugeVec(
|
|
||||||
&metrics.GaugeOpts{
|
|
||||||
Name: "open_cluster_management_registration_build_info",
|
|
||||||
Help: "A metric with a constant '1' value labeled by major, minor, git commit & git version from which Open Cluster Management Registration was built.",
|
|
||||||
},
|
|
||||||
[]string{"major", "minor", "gitCommit", "gitVersion"},
|
|
||||||
)
|
|
||||||
buildInfo.WithLabelValues(majorFromGit, minorFromGit, commitFromGit, versionFromGit).Set(1)
|
|
||||||
|
|
||||||
legacyregistry.MustRegister(buildInfo)
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@ package v1
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/webhook/common"
|
"open-cluster-management.io/ocm/pkg/work/webhook/common"
|
||||||
@@ -12,7 +13,6 @@ import (
|
|||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
workv1 "open-cluster-management.io/api/work/v1"
|
workv1 "open-cluster-management.io/api/work/v1"
|
||||||
@@ -75,7 +75,7 @@ func (r *ManifestWorkWebhook) validateRequest(newWork, oldWork *workv1.ManifestW
|
|||||||
|
|
||||||
func validateExecutor(kubeClient kubernetes.Interface, work *workv1.ManifestWork, userInfo authenticationv1.UserInfo) error {
|
func validateExecutor(kubeClient kubernetes.Interface, work *workv1.ManifestWork, userInfo authenticationv1.UserInfo) error {
|
||||||
executor := work.Spec.Executor
|
executor := work.Spec.Executor
|
||||||
if !utilfeature.DefaultMutableFeatureGate.Enabled(ocmfeature.NilExecutorValidating) {
|
if !features.DefaultHubWorkMutableFeatureGate.Enabled(ocmfeature.NilExecutorValidating) {
|
||||||
if executor == nil {
|
if executor == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ import (
|
|||||||
|
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
|
|
||||||
_ "open-cluster-management.io/ocm/pkg/work/features"
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
|
|
||||||
admissionv1 "k8s.io/api/admission/v1"
|
admissionv1 "k8s.io/api/admission/v1"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
|
|
||||||
clienttesting "k8s.io/client-go/testing"
|
clienttesting "k8s.io/client-go/testing"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||||
|
|
||||||
@@ -254,7 +252,7 @@ func TestManifestWorkExecutorValidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
utilruntime.Must(utilfeature.DefaultMutableFeatureGate.Set(
|
utilruntime.Must(features.DefaultHubWorkMutableFeatureGate.Set(
|
||||||
fmt.Sprintf("%s=true", ocmfeature.NilExecutorValidating),
|
fmt.Sprintf("%s=true", ocmfeature.NilExecutorValidating),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
|
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
|
||||||
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
||||||
"open-cluster-management.io/ocm/test/registration/integration/util"
|
"open-cluster-management.io/ocm/test/registration/integration/util"
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ var _ = ginkgo.Describe("Addon Lease Resync", func() {
|
|||||||
hubKubeconfigDir = path.Join(util.TestDir, fmt.Sprintf("addontest-%s", suffix), "hub-kubeconfig")
|
hubKubeconfigDir = path.Join(util.TestDir, fmt.Sprintf("addontest-%s", suffix), "hub-kubeconfig")
|
||||||
addOnName = fmt.Sprintf("addon-%s", suffix)
|
addOnName = fmt.Sprintf("addon-%s", suffix)
|
||||||
|
|
||||||
err := features.DefaultSpokeMutableFeatureGate.Set("AddonManagement=true")
|
err := features.DefaultSpokeRegistrationMutableFeatureGate.Set("AddonManagement=true")
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
|
||||||
agentOptions := spoke.SpokeAgentOptions{
|
agentOptions := spoke.SpokeAgentOptions{
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
|
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
|
||||||
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
||||||
"open-cluster-management.io/ocm/test/registration/integration/util"
|
"open-cluster-management.io/ocm/test/registration/integration/util"
|
||||||
)
|
)
|
||||||
@@ -37,7 +37,7 @@ var _ = ginkgo.Describe("Addon Registration", func() {
|
|||||||
hubKubeconfigDir = path.Join(util.TestDir, fmt.Sprintf("addontest-%s", suffix), "hub-kubeconfig")
|
hubKubeconfigDir = path.Join(util.TestDir, fmt.Sprintf("addontest-%s", suffix), "hub-kubeconfig")
|
||||||
addOnName = fmt.Sprintf("addon-%s", suffix)
|
addOnName = fmt.Sprintf("addon-%s", suffix)
|
||||||
|
|
||||||
err := features.DefaultSpokeMutableFeatureGate.Set("AddonManagement=true")
|
err := features.DefaultSpokeRegistrationMutableFeatureGate.Set("AddonManagement=true")
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
|
||||||
agentOptions := spoke.SpokeAgentOptions{
|
agentOptions := spoke.SpokeAgentOptions{
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import (
|
|||||||
addonclientset "open-cluster-management.io/api/client/addon/clientset/versioned"
|
addonclientset "open-cluster-management.io/api/client/addon/clientset/versioned"
|
||||||
clusterclientset "open-cluster-management.io/api/client/cluster/clientset/versioned"
|
clusterclientset "open-cluster-management.io/api/client/cluster/clientset/versioned"
|
||||||
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/hub"
|
"open-cluster-management.io/ocm/pkg/registration/hub"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
||||||
"open-cluster-management.io/ocm/test/registration/integration/util"
|
"open-cluster-management.io/ocm/test/registration/integration/util"
|
||||||
@@ -88,7 +88,7 @@ var _ = ginkgo.Describe("Disaster Recovery", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startRegistrationAgent := func(managedClusterName, bootstrapKubeConfigFile, hubKubeconfigSecret, hubKubeconfigDir string) context.CancelFunc {
|
startRegistrationAgent := func(managedClusterName, bootstrapKubeConfigFile, hubKubeconfigSecret, hubKubeconfigDir string) context.CancelFunc {
|
||||||
err := features.DefaultSpokeMutableFeatureGate.Set("AddonManagement=true")
|
err := features.DefaultSpokeRegistrationMutableFeatureGate.Set("AddonManagement=true")
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
|
||||||
agentOptions := spoke.SpokeAgentOptions{
|
agentOptions := spoke.SpokeAgentOptions{
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import (
|
|||||||
clusterclientset "open-cluster-management.io/api/client/cluster/clientset/versioned"
|
clusterclientset "open-cluster-management.io/api/client/cluster/clientset/versioned"
|
||||||
workclientset "open-cluster-management.io/api/client/work/clientset/versioned"
|
workclientset "open-cluster-management.io/api/client/work/clientset/versioned"
|
||||||
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
clusterv1 "open-cluster-management.io/api/cluster/v1"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
"open-cluster-management.io/ocm/pkg/registration/clientcert"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/features"
|
|
||||||
"open-cluster-management.io/ocm/pkg/registration/hub"
|
"open-cluster-management.io/ocm/pkg/registration/hub"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
||||||
"open-cluster-management.io/ocm/pkg/registration/spoke/addon"
|
"open-cluster-management.io/ocm/pkg/registration/spoke/addon"
|
||||||
@@ -157,11 +157,11 @@ var _ = ginkgo.BeforeSuite(func() {
|
|||||||
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
||||||
|
|
||||||
// enable DefaultClusterSet feature gate
|
// enable DefaultClusterSet feature gate
|
||||||
err = features.DefaultHubMutableFeatureGate.Set("DefaultClusterSet=true")
|
err = features.DefaultHubRegistrationMutableFeatureGate.Set("DefaultClusterSet=true")
|
||||||
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
||||||
|
|
||||||
// enable ManagedClusterAutoApproval feature gate
|
// enable ManagedClusterAutoApproval feature gate
|
||||||
err = features.DefaultHubMutableFeatureGate.Set("ManagedClusterAutoApproval=true")
|
err = features.DefaultHubRegistrationMutableFeatureGate.Set("ManagedClusterAutoApproval=true")
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
|
||||||
// start hub controller
|
// start hub controller
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jsonpatch "github.com/evanphx/json-patch"
|
jsonpatch "github.com/evanphx/json-patch"
|
||||||
@@ -15,7 +16,6 @@ import (
|
|||||||
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
||||||
workclientset "open-cluster-management.io/api/client/work/clientset/versioned"
|
workclientset "open-cluster-management.io/api/client/work/clientset/versioned"
|
||||||
workapiv1 "open-cluster-management.io/api/work/v1"
|
workapiv1 "open-cluster-management.io/api/work/v1"
|
||||||
"open-cluster-management.io/ocm/pkg/work/features"
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/spoke"
|
"open-cluster-management.io/ocm/pkg/work/spoke"
|
||||||
"open-cluster-management.io/ocm/test/work/integration/util"
|
"open-cluster-management.io/ocm/test/work/integration/util"
|
||||||
)
|
)
|
||||||
@@ -35,7 +35,7 @@ var _ = ginkgo.Describe("ManifestWork Executor Subject", func() {
|
|||||||
o.HubKubeconfigFile = hubKubeconfigFileName
|
o.HubKubeconfigFile = hubKubeconfigFileName
|
||||||
o.SpokeClusterName = utilrand.String(5)
|
o.SpokeClusterName = utilrand.String(5)
|
||||||
o.StatusSyncInterval = 3 * time.Second
|
o.StatusSyncInterval = 3 * time.Second
|
||||||
err := features.DefaultSpokeMutableFeatureGate.Set("ExecutorValidatingCaches=true")
|
err := features.DefaultSpokeWorkMutableFeatureGate.Set("ExecutorValidatingCaches=true")
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
|
||||||
ns := &corev1.Namespace{}
|
ns := &corev1.Namespace{}
|
||||||
|
|||||||
@@ -3,12 +3,9 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"open-cluster-management.io/ocm/pkg/features"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/utils/pointer"
|
|
||||||
ocmfeature "open-cluster-management.io/api/feature"
|
|
||||||
"open-cluster-management.io/ocm/pkg/work/features"
|
|
||||||
|
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
@@ -16,6 +13,8 @@ import (
|
|||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
||||||
|
"k8s.io/utils/pointer"
|
||||||
|
ocmfeature "open-cluster-management.io/api/feature"
|
||||||
workapiv1 "open-cluster-management.io/api/work/v1"
|
workapiv1 "open-cluster-management.io/api/work/v1"
|
||||||
"open-cluster-management.io/ocm/pkg/work/spoke"
|
"open-cluster-management.io/ocm/pkg/work/spoke"
|
||||||
"open-cluster-management.io/ocm/test/work/integration/util"
|
"open-cluster-management.io/ocm/test/work/integration/util"
|
||||||
@@ -455,7 +454,7 @@ var _ = ginkgo.Describe("ManifestWork Status Feedback", func() {
|
|||||||
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
||||||
manifests = append(manifests, util.ToManifest(u))
|
manifests = append(manifests, util.ToManifest(u))
|
||||||
|
|
||||||
err = features.DefaultSpokeMutableFeatureGate.Set(fmt.Sprintf("%s=true", ocmfeature.RawFeedbackJsonString))
|
err = features.DefaultSpokeWorkMutableFeatureGate.Set(fmt.Sprintf("%s=true", ocmfeature.RawFeedbackJsonString))
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
var ctx context.Context
|
var ctx context.Context
|
||||||
ctx, cancel = context.WithCancel(context.Background())
|
ctx, cancel = context.WithCancel(context.Background())
|
||||||
|
|||||||
Reference in New Issue
Block a user