From 00425669707fb4ed4e12efebdfd992827805cf7c Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Fri, 5 Jun 2026 08:20:22 +0600 Subject: [PATCH] Remove FerretDB support Signed-off-by: Tamal Saha --- kubedb.com/v1alpha2/constants.go | 1 - kubedb.com/v1alpha2/ferretdb.go | 115 ---------------- kubedb.com/v1alpha2/ferretdb_test.go | 127 ------------------ ops.kubedb.com/v1alpha1/ferretdb_mapping.go | 55 -------- .../kubedb.com/v1alpha2/ferretdb/cluster.yaml | 83 ------------ .../v1alpha2/ferretdb/standalone.yaml | 60 --------- .../resource-metrics/api/constants.go | 6 + .../v1alpha1/ferretdb_mapping.go | 55 -------- 8 files changed, 6 insertions(+), 496 deletions(-) delete mode 100644 kubedb.com/v1alpha2/ferretdb.go delete mode 100644 kubedb.com/v1alpha2/ferretdb_test.go delete mode 100644 ops.kubedb.com/v1alpha1/ferretdb_mapping.go delete mode 100644 testdata/kubedb.com/v1alpha2/ferretdb/cluster.yaml delete mode 100644 testdata/kubedb.com/v1alpha2/ferretdb/standalone.yaml delete mode 100644 utils/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/ferretdb_mapping.go diff --git a/kubedb.com/v1alpha2/constants.go b/kubedb.com/v1alpha2/constants.go index a68a25d1..2d09fc55 100644 --- a/kubedb.com/v1alpha2/constants.go +++ b/kubedb.com/v1alpha2/constants.go @@ -38,7 +38,6 @@ const ( DocumentDBContainerName = "documentdb" HazelcastContainerName = "hazelcast" HanaDBContainerName = "hanadb" - FerretDBContainerName = "ferretdb" IgniteContainerName = "ignite" MilvusContainerName = "milvus" MSSQLServerContainerName = "mssql" diff --git a/kubedb.com/v1alpha2/ferretdb.go b/kubedb.com/v1alpha2/ferretdb.go deleted file mode 100644 index e7d05f8a..00000000 --- a/kubedb.com/v1alpha2/ferretdb.go +++ /dev/null @@ -1,115 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - "fmt" - - "kmodules.xyz/resource-metrics/api" - - core "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -func init() { - api.Register(schema.GroupVersionKind{ - Group: "kubedb.com", - Version: "v1alpha2", - Kind: "FerretDB", - }, FerretDB{}.ResourceCalculator()) - api.Register(schema.GroupVersionKind{ - Group: "gitops.kubedb.com", - Version: "v1alpha1", - Kind: "FerretDB", - }, FerretDB{}.ResourceCalculator()) -} - -type FerretDB struct{} - -func (r FerretDB) ResourceCalculator() api.ResourceCalculator { - return &api.ResourceCalculatorFuncs{ - AppRoles: []api.PodRole{api.PodRolePrimary, api.PodRoleSecondary}, - RuntimeRoles: []api.PodRole{api.PodRolePrimary, api.PodRoleSecondary, api.PodRoleExporter}, - RoleReplicasFn: r.roleReplicasFn, - ModeFn: r.modeFn, - UsesTLSFn: r.usesTLSFn, - RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), - RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), - } -} - -func (r FerretDB) roleReplicasFn(obj map[string]any) (api.ReplicaList, error) { - replicas, found, err := unstructured.NestedInt64(obj, "spec", "server", "primary", "replicas") - if err != nil { - return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) - } - if !found { - return api.ReplicaList{api.PodRolePrimary: 1}, nil - } - - ret := api.ReplicaList{api.PodRolePrimary: replicas} - secRepplicas, found, err := unstructured.NestedInt64(obj, "spec", "server", "secondary", "replicas") - if found && err == nil { - ret[api.PodRoleSecondary] = secRepplicas - } - return ret, nil -} - -func (r FerretDB) modeFn(obj map[string]any) (string, error) { - _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "server", "secondary") - if !found || err != nil { - return DBModePrimaryOnly, nil - } - return DBModeCluster, nil -} - -func (r FerretDB) usesTLSFn(obj map[string]any) (bool, error) { - _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") - return found, err -} - -func (r FerretDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]any) (map[api.PodRole]api.PodInfo, error) { - return func(obj map[string]any) (map[api.PodRole]api.PodInfo, error) { - pc, pr, err := api.AppNodeResourcesV2(obj, fn, FerretDBContainerName, "spec", "server", "primary") - if err != nil { - return nil, err - } - - exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") - if err != nil { - return nil, err - } - - ret := map[api.PodRole]api.PodInfo{ - api.PodRolePrimary: {Resource: pc, Replicas: pr}, - api.PodRoleExporter: {Resource: exporter, Replicas: pr}, - } - - _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "server", "secondary") - if found && err == nil { - sc, sr, err := api.AppNodeResourcesV2(obj, fn, FerretDBContainerName, "spec", "server", "secondary") - if err != nil { - return nil, err - } - sc[core.ResourceStorage] = pc[core.ResourceStorage] - ret[api.PodRoleSecondary] = api.PodInfo{Resource: sc, Replicas: sr} - ret[api.PodRoleExporter] = api.PodInfo{Resource: exporter, Replicas: pr + sr} - } - return ret, nil - } -} diff --git a/kubedb.com/v1alpha2/ferretdb_test.go b/kubedb.com/v1alpha2/ferretdb_test.go deleted file mode 100644 index e09b8f81..00000000 --- a/kubedb.com/v1alpha2/ferretdb_test.go +++ /dev/null @@ -1,127 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - tl "gomodules.xyz/testing" - core "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" -) - -func TestFerretDB(t *testing.T) { - type want struct { - replicas int64 - mode string - appResources core.ResourceRequirements - totalResources core.ResourceRequirements - } - tests := []struct { - name string - want want - }{ - { - name: "testdata/kubedb.com/v1alpha2/ferretdb/standalone.yaml", - want: want{ - replicas: 2, - mode: DBModePrimaryOnly, - totalResources: core.ResourceRequirements{ - Limits: core.ResourceList{ - core.ResourceCPU: resource.MustParse("1050m"), - core.ResourceMemory: resource.MustParse("1050Mi"), - }, - Requests: core.ResourceList{ - core.ResourceCPU: resource.MustParse("900m"), - core.ResourceMemory: resource.MustParse("900Mi"), - }, - }, - appResources: core.ResourceRequirements{ - Limits: core.ResourceList{ - core.ResourceCPU: resource.MustParse("900m"), - core.ResourceMemory: resource.MustParse("900Mi"), - }, - Requests: core.ResourceList{ - core.ResourceCPU: resource.MustParse("800m"), - core.ResourceMemory: resource.MustParse("800Mi"), - }, - }, - }, - }, - { - name: "testdata/kubedb.com/v1alpha2/ferretdb/cluster.yaml", - want: want{ - replicas: 5, - mode: DBModeCluster, - totalResources: core.ResourceRequirements{ - Limits: core.ResourceList{ - core.ResourceCPU: resource.MustParse("2800m"), - core.ResourceMemory: resource.MustParse("2800Mi"), - }, - Requests: core.ResourceList{ - core.ResourceCPU: resource.MustParse("2300m"), - core.ResourceMemory: resource.MustParse("2300Mi"), - }, - }, - appResources: core.ResourceRequirements{ - Limits: core.ResourceList{ - core.ResourceCPU: resource.MustParse("2050m"), - core.ResourceMemory: resource.MustParse("2050Mi"), - }, - Requests: core.ResourceList{ - core.ResourceCPU: resource.MustParse("1800m"), - core.ResourceMemory: resource.MustParse("1800Mi"), - }, - }, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - obj, err := tl.LoadFile(tt.name) - if err != nil { - t.Error(err) - return - } - c := FerretDB{}.ResourceCalculator() - - if got, err := c.Replicas(obj); err != nil { - t.Errorf("Replicas() error = %v", err) - } else if got != tt.want.replicas { - t.Errorf("Replicas found = %v, expected = %v", got, tt.want.replicas) - } - - if got, err := c.Mode(obj); err != nil { - t.Errorf("Mode() error = %v", err) - } else if got != tt.want.mode { - t.Errorf("Mode found = %v, expected = %v", got, tt.want.mode) - } - - if got, err := c.AppResourceLimits(obj); err != nil { - t.Errorf("AppResourceLimits() error = %v", err) - } else if !cmp.Equal(tt.want.appResources.Limits, got) { - t.Errorf("AppResourceLimits() difference = %v", cmp.Diff(tt.want.appResources.Limits, got)) - } - if got, err := c.AppResourceRequests(obj); err != nil { - t.Errorf("AppResourceRequests() error = %v", err) - } else if !cmp.Equal(tt.want.appResources.Requests, got) { - t.Errorf("AppResourceRequests() difference = %v", cmp.Diff(tt.want.appResources.Requests, got)) - } - }) - } -} diff --git a/ops.kubedb.com/v1alpha1/ferretdb_mapping.go b/ops.kubedb.com/v1alpha1/ferretdb_mapping.go deleted file mode 100644 index d32f2edf..00000000 --- a/ops.kubedb.com/v1alpha1/ferretdb_mapping.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import "k8s.io/apimachinery/pkg/runtime/schema" - -func init() { - RegisterOpsPathMapperToPlugins(&FerretDBOpsRequest{}) -} - -type FerretDBOpsRequest struct{} - -var _ OpsPathMapper = (*FerretDBOpsRequest)(nil) - -func (m *FerretDBOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath { - return map[OpsReqPath]ReferencedObjPath{ - "spec.horizontalScaling.node": "spec.replicas", - } -} - -func (m *FerretDBOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath { - return map[OpsReqPath]ReferencedObjPath{ - "spec.verticalScaling.node": "spec.podTemplate.spec.resources", - } -} - -func (m *FerretDBOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath { - return map[OpsReqPath]ReferencedObjPath{} -} - -func (m *FerretDBOpsRequest) GetAppRefPath() []string { - return []string{"spec", "databaseRef"} -} - -func (m *FerretDBOpsRequest) GroupVersionKind() schema.GroupVersionKind { - return schema.GroupVersionKind{ - Group: "ops.kubedb.com", - Version: "v1alpha1", - Kind: "FerretDBOpsRequest", - } -} diff --git a/testdata/kubedb.com/v1alpha2/ferretdb/cluster.yaml b/testdata/kubedb.com/v1alpha2/ferretdb/cluster.yaml deleted file mode 100644 index c2855a07..00000000 --- a/testdata/kubedb.com/v1alpha2/ferretdb/cluster.yaml +++ /dev/null @@ -1,83 +0,0 @@ -apiVersion: kubedb.com/v1alpha2 -kind: FerretDB -metadata: - name: ferretdb - namespace: demo -spec: - version: "1.18.0" - authSecret: - externallyManaged: false - server: - primary: - podTemplate: - spec: - containers: - - name: ferretdb - resources: - limits: - cpu: 450m - memory: 450Mi - requests: - cpu: 400m - memory: 400Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - runAsGroup: 0 - runAsNonRoot: true - runAsUser: 999 - seccompProfile: - type: RuntimeDefault - replicas: 3 - secondary: - podTemplate: - spec: - containers: - - name: ferretdb - resources: - limits: - cpu: 350m - memory: 350Mi - requests: - cpu: 300m - memory: 300Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - runAsGroup: 0 - runAsNonRoot: true - runAsUser: 999 - seccompProfile: - type: RuntimeDefault - replicas: 2 - monitor: - agent: prometheus.io - prometheus: - exporter: - resources: - limits: - cpu: 150m - memory: 150Mi - requests: - cpu: 100m - memory: 100Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - runAsGroup: 0 - runAsNonRoot: true - runAsUser: 999 - seccompProfile: - type: RuntimeDefault - storage: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 2Gi diff --git a/testdata/kubedb.com/v1alpha2/ferretdb/standalone.yaml b/testdata/kubedb.com/v1alpha2/ferretdb/standalone.yaml deleted file mode 100644 index 6bdbd139..00000000 --- a/testdata/kubedb.com/v1alpha2/ferretdb/standalone.yaml +++ /dev/null @@ -1,60 +0,0 @@ -apiVersion: kubedb.com/v1alpha2 -kind: FerretDB -metadata: - name: ferretdb - namespace: demo -spec: - version: "1.18.0" - authSecret: - externallyManaged: false - server: - primary: - podTemplate: - spec: - containers: - - name: ferretdb - resources: - limits: - cpu: 450m - memory: 450Mi - requests: - cpu: 400m - memory: 400Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - runAsGroup: 0 - runAsNonRoot: true - runAsUser: 999 - seccompProfile: - type: RuntimeDefault - replicas: 2 - monitor: - agent: prometheus.io - prometheus: - exporter: - resources: - limits: - cpu: 150m - memory: 150Mi - requests: - cpu: 100m - memory: 100Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - runAsGroup: 0 - runAsNonRoot: true - runAsUser: 999 - seccompProfile: - type: RuntimeDefault - storage: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 2Gi diff --git a/utils/vendor/kmodules.xyz/resource-metrics/api/constants.go b/utils/vendor/kmodules.xyz/resource-metrics/api/constants.go index a8b80040..9c727a68 100644 --- a/utils/vendor/kmodules.xyz/resource-metrics/api/constants.go +++ b/utils/vendor/kmodules.xyz/resource-metrics/api/constants.go @@ -68,6 +68,12 @@ const ( PodRoleHistoricals PodRole = "historicals" PodRoleRouters PodRole = "routers" + PodRoleDataNode PodRole = "datanode" + PodRoleMixCoord PodRole = "mixcoord" + PodRoleProxy PodRole = "proxy" + PodRoleQueryNode PodRole = "querynode" + PodRoleStreamingNode PodRole = "streamingnode" + PodRolePrimary PodRole = "primary" PodRoleSecondary PodRole = "secondary" ) diff --git a/utils/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/ferretdb_mapping.go b/utils/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/ferretdb_mapping.go deleted file mode 100644 index d32f2edf..00000000 --- a/utils/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/ferretdb_mapping.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright AppsCode Inc. and Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import "k8s.io/apimachinery/pkg/runtime/schema" - -func init() { - RegisterOpsPathMapperToPlugins(&FerretDBOpsRequest{}) -} - -type FerretDBOpsRequest struct{} - -var _ OpsPathMapper = (*FerretDBOpsRequest)(nil) - -func (m *FerretDBOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath { - return map[OpsReqPath]ReferencedObjPath{ - "spec.horizontalScaling.node": "spec.replicas", - } -} - -func (m *FerretDBOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath { - return map[OpsReqPath]ReferencedObjPath{ - "spec.verticalScaling.node": "spec.podTemplate.spec.resources", - } -} - -func (m *FerretDBOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath { - return map[OpsReqPath]ReferencedObjPath{} -} - -func (m *FerretDBOpsRequest) GetAppRefPath() []string { - return []string{"spec", "databaseRef"} -} - -func (m *FerretDBOpsRequest) GroupVersionKind() schema.GroupVersionKind { - return schema.GroupVersionKind{ - Group: "ops.kubedb.com", - Version: "v1alpha1", - Kind: "FerretDBOpsRequest", - } -}