diff --git a/config/crd/bases/toolchain.dev.openshift.com_toolchainconfigs.yaml b/config/crd/bases/toolchain.dev.openshift.com_toolchainconfigs.yaml index b21b922d6..f1d1360bd 100644 --- a/config/crd/bases/toolchain.dev.openshift.com_toolchainconfigs.yaml +++ b/config/crd/bases/toolchain.dev.openshift.com_toolchainconfigs.yaml @@ -52,37 +52,6 @@ spec: or not type: boolean type: object - capacityThresholds: - description: 'Keeps parameters necessary for configuring capacity - limits Deprecated: This is no longer used for anything.' - properties: - maxNumberOfSpacesPerMemberCluster: - additionalProperties: - type: integer - description: 'Contains a map of maximal number of spaces that - can be provisioned per member cluster mapped by the cluster - name Deprecated: This is no longer used for anything.' - type: object - x-kubernetes-map-type: atomic - resourceCapacityThreshold: - description: 'Contains capacity threshold configuration Deprecated: - This is no longer used for anything.' - properties: - defaultThreshold: - description: It is the default capacity threshold (in - percentage of usage) to be used for all member clusters - if no special threshold is defined - type: integer - specificPerMemberCluster: - additionalProperties: - type: integer - description: Contains a map of specific capacity thresholds - (in percentage of usage) for particular member clusters - mapped by their names - type: object - x-kubernetes-map-type: atomic - type: object - type: object deactivation: description: Keeps parameters concerned with user deactivation properties: diff --git a/controllers/toolchainconfig/configuration.go b/controllers/toolchainconfig/configuration.go index 921901668..35d4d3e68 100644 --- a/controllers/toolchainconfig/configuration.go +++ b/controllers/toolchainconfig/configuration.go @@ -92,11 +92,6 @@ func (c *ToolchainConfig) AutomaticApproval() AutoApprovalConfig { return AutoApprovalConfig{c.cfg.Host.AutomaticApproval} } -// Deprecated: This is no longer used for anything. -func (c *ToolchainConfig) CapacityThresholds() CapacityThresholdsConfig { - return CapacityThresholdsConfig{c.cfg.Host.CapacityThresholds} -} - func (c *ToolchainConfig) SpaceConfig() SpaceConfig { return SpaceConfig{c.cfg.Host.SpaceConfig} } @@ -152,26 +147,6 @@ func (s SpaceConfig) SpaceBindingRequestIsEnabled() bool { return commonconfig.GetBool(s.spaceConfig.SpaceBindingRequestEnabled, false) } -// Deprecated: This is no longer used for anything. -type CapacityThresholdsConfig struct { - capacityThresholds toolchainv1alpha1.CapacityThresholds -} - -// Deprecated: This is no longer used for anything. -func (c CapacityThresholdsConfig) MaxNumberOfSpacesSpecificPerMemberCluster() map[string]int { - return c.capacityThresholds.MaxNumberOfSpacesPerMemberCluster -} - -// Deprecated: This is no longer used for anything. -func (c CapacityThresholdsConfig) ResourceCapacityThresholdDefault() int { - return commonconfig.GetInt(c.capacityThresholds.ResourceCapacityThreshold.DefaultThreshold, 80) -} - -// Deprecated: This is no longer used for anything. -func (c CapacityThresholdsConfig) ResourceCapacityThresholdSpecificPerMemberCluster() map[string]int { - return c.capacityThresholds.ResourceCapacityThreshold.SpecificPerMemberCluster -} - type DeactivationConfig struct { dctv toolchainv1alpha1.DeactivationConfig } diff --git a/controllers/toolchainconfig/configuration_test.go b/controllers/toolchainconfig/configuration_test.go index 0c3a57340..ddd093098 100644 --- a/controllers/toolchainconfig/configuration_test.go +++ b/controllers/toolchainconfig/configuration_test.go @@ -249,25 +249,6 @@ func TestAutomaticApprovalConfig(t *testing.T) { }) } -func TestCapacityThresholdsConfig(t *testing.T) { - t.Run("default", func(t *testing.T) { - cfg := commonconfig.NewToolchainConfigObjWithReset(t) - toolchainCfg := newToolchainConfig(cfg, map[string]map[string]string{}) - - assert.Empty(t, toolchainCfg.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) - assert.Equal(t, 80, toolchainCfg.CapacityThresholds().ResourceCapacityThresholdDefault()) - assert.Empty(t, toolchainCfg.CapacityThresholds().ResourceCapacityThresholdSpecificPerMemberCluster()) - }) - t.Run("non-default", func(t *testing.T) { - cfg := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)).ResourceCapacityThreshold(456, testconfig.PerMemberCluster("member1", 654))) //nolint:staticcheck // this will be removed once we also remove the deprecated method - toolchainCfg := newToolchainConfig(cfg, map[string]map[string]string{}) - - assert.Equal(t, cfg.Spec.Host.CapacityThresholds.MaxNumberOfSpacesPerMemberCluster, toolchainCfg.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) - assert.Equal(t, 456, toolchainCfg.CapacityThresholds().ResourceCapacityThresholdDefault()) - assert.Equal(t, cfg.Spec.Host.CapacityThresholds.ResourceCapacityThreshold.SpecificPerMemberCluster, toolchainCfg.CapacityThresholds().ResourceCapacityThresholdSpecificPerMemberCluster()) - }) -} - func TestDeactivationConfig(t *testing.T) { t.Run("default", func(t *testing.T) { cfg := commonconfig.NewToolchainConfigObjWithReset(t) diff --git a/controllers/toolchainconfig/toolchainconfig_controller_test.go b/controllers/toolchainconfig/toolchainconfig_controller_test.go index 7197a8771..80571f480 100644 --- a/controllers/toolchainconfig/toolchainconfig_controller_test.go +++ b/controllers/toolchainconfig/toolchainconfig_controller_test.go @@ -65,7 +65,6 @@ func TestReconcile(t *testing.T) { t.Run("config exists", func(t *testing.T) { config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), //nolint:staticcheck // this will be removed once we also remove the deprecated method testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("member1", specificMemberConfig.Spec)) hostCl := test.NewFakeClient(t, config) @@ -83,7 +82,6 @@ func TestReconcile(t *testing.T) { actual, err := toolchainconfig.GetToolchainConfig(hostCl) require.NoError(t, err) assert.True(t, actual.AutomaticApproval().IsEnabled()) - assert.Equal(t, config.Spec.Host.CapacityThresholds.MaxNumberOfSpacesPerMemberCluster, actual.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) testconfig.AssertThatToolchainConfig(t, test.HostOperatorNs, hostCl). Exists(). HasConditions( @@ -105,8 +103,6 @@ func TestReconcile(t *testing.T) { // given err := hostCl.Get(context.TODO(), types.NamespacedName{Name: config.Name, Namespace: config.Namespace}, config) require.NoError(t, err) - threshold := 100 - config.Spec.Host.CapacityThresholds.ResourceCapacityThreshold.DefaultThreshold = &threshold newRefreshPeriod := "20s" config.Spec.Members.Default.MemberStatus.RefreshPeriod = &newRefreshPeriod err = hostCl.Update(context.TODO(), config) @@ -121,8 +117,6 @@ func TestReconcile(t *testing.T) { actual, err := toolchainconfig.GetToolchainConfig(hostCl) require.NoError(t, err) assert.True(t, actual.AutomaticApproval().IsEnabled()) - assert.Equal(t, config.Spec.Host.CapacityThresholds.MaxNumberOfSpacesPerMemberCluster, actual.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) - assert.Equal(t, 100, actual.CapacityThresholds().ResourceCapacityThresholdDefault()) testconfig.AssertThatToolchainConfig(t, test.HostOperatorNs, hostCl). Exists(). HasConditions( @@ -145,8 +139,6 @@ func TestReconcile(t *testing.T) { // given err := hostCl.Get(context.TODO(), types.NamespacedName{Name: config.Name, Namespace: config.Namespace}, config) require.NoError(t, err) - threshold := 100 - config.Spec.Host.CapacityThresholds.ResourceCapacityThreshold.DefaultThreshold = &threshold err = hostCl.Update(context.TODO(), config) require.NoError(t, err) hostCl.MockGet = func(ctx context.Context, key types.NamespacedName, obj runtimeclient.Object, opts ...runtimeclient.GetOption) error { @@ -162,8 +154,6 @@ func TestReconcile(t *testing.T) { actual, err := toolchainconfig.GetToolchainConfig(hostCl) require.NoError(t, err) assert.True(t, actual.AutomaticApproval().IsEnabled()) - assert.Equal(t, config.Spec.Host.CapacityThresholds.MaxNumberOfSpacesPerMemberCluster, actual.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) - assert.Equal(t, 100, actual.CapacityThresholds().ResourceCapacityThresholdDefault()) // check member1 config is unchanged member1Cfg, err := getMemberConfig(member1) @@ -183,7 +173,6 @@ func TestReconcile(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), //nolint:staticcheck // this will be removed once we also remove the deprecated method testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("member1", specificMemberConfig.Spec)) hostCl := test.NewFakeClient(t, config) @@ -212,7 +201,6 @@ func TestReconcile(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), //nolint:staticcheck // this will be removed once we also remove the deprecated method testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("member1", specificMemberConfig.Spec)) hostCl := test.NewFakeClient(t, config) @@ -243,8 +231,7 @@ func TestReconcile(t *testing.T) { t.Run("reg service deploy failed", func(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, - testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) //nolint:staticcheck // this will be removed once we also remove the deprecated method + testconfig.AutomaticApproval().Enabled(true)) hostCl := test.NewFakeClient(t, config) hostCl.MockCreate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.CreateOption) error { return fmt.Errorf("create error") @@ -260,8 +247,6 @@ func TestReconcile(t *testing.T) { actual, err := toolchainconfig.GetToolchainConfig(hostCl) require.NoError(t, err) assert.True(t, actual.AutomaticApproval().IsEnabled()) - assert.Equal(t, config.Spec.Host.CapacityThresholds.MaxNumberOfSpacesPerMemberCluster, actual.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) - assert.Equal(t, 80, actual.CapacityThresholds().ResourceCapacityThresholdDefault()) testconfig.AssertThatToolchainConfig(t, test.HostOperatorNs, hostCl). Exists(). HasConditions( @@ -271,8 +256,7 @@ func TestReconcile(t *testing.T) { t.Run("sync failed", func(t *testing.T) { // given - config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("missing-member", specificMemberConfig.Spec), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) //nolint:staticcheck // this will be removed once we also remove the deprecated method + config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("missing-member", specificMemberConfig.Spec)) hostCl := test.NewFakeClient(t, config) members := NewGetMemberClusters(NewMemberClusterWithTenantRole(t, "member1", corev1.ConditionTrue), NewMemberClusterWithTenantRole(t, "member2", corev1.ConditionTrue)) controller := newController(t, hostCl, members) @@ -286,8 +270,6 @@ func TestReconcile(t *testing.T) { actual, err := toolchainconfig.GetToolchainConfig(hostCl) require.NoError(t, err) assert.True(t, actual.AutomaticApproval().IsEnabled()) - assert.Equal(t, config.Spec.Host.CapacityThresholds.MaxNumberOfSpacesPerMemberCluster, actual.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) - assert.Equal(t, 80, actual.CapacityThresholds().ResourceCapacityThresholdDefault()) testconfig.AssertThatToolchainConfig(t, test.HostOperatorNs, hostCl). Exists(). HasConditions( @@ -300,8 +282,7 @@ func TestReconcile(t *testing.T) { func TestWrapErrorWithUpdateStatus(t *testing.T) { // given - config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) //nolint:staticcheck // this will be removed once we also remove the deprecated method + config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true)) hostCl := test.NewFakeClient(t, config) members := NewGetMemberClusters(NewMemberClusterWithTenantRole(t, "member1", corev1.ConditionTrue), NewMemberClusterWithTenantRole(t, "member2", corev1.ConditionTrue)) controller := newController(t, hostCl, members) @@ -353,9 +334,6 @@ func newRequest() reconcile.Request { func matchesDefaultConfig(t *testing.T, actual toolchainconfig.ToolchainConfig) { assert.False(t, actual.AutomaticApproval().IsEnabled()) - assert.Empty(t, actual.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) - assert.Equal(t, 80, actual.CapacityThresholds().ResourceCapacityThresholdDefault()) - assert.Empty(t, actual.CapacityThresholds().ResourceCapacityThresholdSpecificPerMemberCluster()) assert.Equal(t, 3, actual.Deactivation().DeactivatingNotificationDays()) } diff --git a/go.mod b/go.mod index 2358d81ec..c4295bad6 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/codeready-toolchain/host-operator require ( - github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9 - github.com/codeready-toolchain/toolchain-common v0.0.0-20240422084400-e6d41ea74313 + github.com/codeready-toolchain/api v0.0.0-20240424103940-03edc96d88fb + github.com/codeready-toolchain/toolchain-common v0.0.0-20240424171146-581ea6502cad github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-bindata/go-bindata v3.1.2+incompatible github.com/go-logr/logr v1.2.3 diff --git a/go.sum b/go.sum index adf87b39e..7c93de562 100644 --- a/go.sum +++ b/go.sum @@ -136,10 +136,10 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9 h1:Lm7bFLrzfJzrUiRGVqtsSaZMpj+akLiR/fvAFjjE9gM= -github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9/go.mod h1:cfNN6YPX4TORvhhZXMSjSPesqAHlB3nD/WAfGe4WLKQ= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240422084400-e6d41ea74313 h1:UuLjLbn8Rh1QX8jyLipAtaZ3o25Ard33B2+DCcmJLsQ= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240422084400-e6d41ea74313/go.mod h1:rfVQhC9ctteNi2vbg300fgD0zgTfk/h3qjW9nsCayFs= +github.com/codeready-toolchain/api v0.0.0-20240424103940-03edc96d88fb h1:YvEVAetaNYLAyuwO8AmKTtWD9M7SZPhbBzTVMXhrGas= +github.com/codeready-toolchain/api v0.0.0-20240424103940-03edc96d88fb/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E= +github.com/codeready-toolchain/toolchain-common v0.0.0-20240424171146-581ea6502cad h1:ka0mIrFO8+0H4uIgfhgCGh1lmRjGndRUYNEEV8O7fkQ= +github.com/codeready-toolchain/toolchain-common v0.0.0-20240424171146-581ea6502cad/go.mod h1:4BqdcAO16K/+YmPbn5XmTKOU4UUyuQPlge7ms9F1NsU= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=