Skip to content

Commit

Permalink
Fix resource quota
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 27, 2023
1 parent 2f00766 commit 42c843a
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 34 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ require (
kmodules.xyz/custom-resources v0.25.2
kmodules.xyz/go-containerregistry v0.0.11
kmodules.xyz/monitoring-agent-api v0.25.4
kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce
kmodules.xyz/resource-metrics v0.25.6
kmodules.xyz/resource-metadata v0.17.28
kmodules.xyz/resource-metrics v0.25.7
kmodules.xyz/sets v0.25.0
kubeops.dev/scanner v0.0.15
kubepack.dev/lib-helm v0.7.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2151,10 +2151,10 @@ kmodules.xyz/monitoring-agent-api v0.25.4 h1:OwkvtV23QhUy3f7o9lxPWaAW3jiJMGAMPPR
kmodules.xyz/monitoring-agent-api v0.25.4/go.mod h1:3LhrLDGQKQXhxYcjA/WNaO4HPpopYQzOutsEp2i3008=
kmodules.xyz/offshoot-api v0.25.4 h1:IjJNvkphcdYUG8XO/pBwXpuP8W+jxAWJZ3yH8vgI/as=
kmodules.xyz/offshoot-api v0.25.4/go.mod h1:PUk4EuJFhhyQykCflHj7EgXcljGIqs9vi0IN0RpxtY4=
kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce h1:04+H7IhbihQSxDSoRkD11Hv9tRBZPRJxBKjVZzspRsc=
kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce/go.mod h1:4m4L4/EJ3XasyrN5KFHRJDrWd27WNREeuc3alUKUJ9E=
kmodules.xyz/resource-metrics v0.25.6 h1:zYl49zZ0KBdNPgaLJX1GaL8/lpmyZOshSC5Sg1eXihc=
kmodules.xyz/resource-metrics v0.25.6/go.mod h1:y7pDmTWuVLNGSjwckKCwJFhCgi5fhbwS7PAcH2rmGcY=
kmodules.xyz/resource-metadata v0.17.28 h1:zNCRy8TxuXemsKRiRqOVaCPwRJpAsvNG2KhlMq+cJdU=
kmodules.xyz/resource-metadata v0.17.28/go.mod h1:qA/yeimciDU7szGPyRT3jHDPIvm7uJiVOzcB5tIJgxE=
kmodules.xyz/resource-metrics v0.25.7 h1:ne2cK/dlnfYcuu0+pHX15Y53rcKBQq9DuCtQVcx6rY8=
kmodules.xyz/resource-metrics v0.25.7/go.mod h1:y7pDmTWuVLNGSjwckKCwJFhCgi5fhbwS7PAcH2rmGcY=
kmodules.xyz/sets v0.25.0 h1:belY/3trp/M/CKc1TEteA40jb2uCIdwKHhjpvrIxG+8=
kmodules.xyz/sets v0.25.0/go.mod h1:ICWmplgCsxniWkImSBGlJrLT9npqOXKhX/Bwbc7bmEw=
kubeops.dev/scanner v0.0.15 h1:u9hM2096LEa+BPlI/p7tcqvOv7A9fAFEw8AOEGHP5GY=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
kind: Connection
name: ManagedClusterSets
query:
byLabel: offshoot
byLabel: ocm_bind
type: GraphQL
ref:
group: cluster.open-cluster-management.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ spec:
ref:
group: work.open-cluster-management.io
kind: ManifestWork
- actions:
create: Never
displayMode: List
kind: Connection
name: Placements
query:
byLabel: placed_into
type: GraphQL
ref:
group: cluster.open-cluster-management.io
kind: Placement
resource:
group: work.open-cluster-management.io
kind: ManifestWorkReplicaSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ spec:
apiVersion: work.open-cluster-management.io/v1
kind: ManifestWork
type: MatchSelector
- labels:
- placed_into
references:
- '{range .spec.placementRefs[*]}{.name}{"\n"}{end}'
target:
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
type: MatchRef
resource:
group: work.open-cluster-management.io
kind: ManifestWorkReplicaSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import (
core "k8s.io/api/core/v1"
)

func init() {
RegisterPathMapperPluginMembersWithApiPlugin(OpsResourceCalculator{}.ResourceCalculator())
}

type OpsResourceCalculator struct{}

func (r OpsResourceCalculator) ResourceCalculator() api.ResourceCalculator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&ElasticsearchOpsRequest{})
RegisterOpsPathMapperToPlugins(&ElasticsearchOpsRequest{})
}

type ElasticsearchOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&kafkaOpsRequest{})
RegisterOpsPathMapperToPlugins(&kafkaOpsRequest{})
}

type kafkaOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ type (

var (
PathMapperPlugin = map[schema.GroupVersionKind]OpsPathMapper{}
OpsCalculator = OpsResourceCalculator{}.ResourceCalculator()
lock sync.RWMutex
)

func RegisterToPathMapperPlugin(opsObj OpsPathMapper) {
lock.Lock()
defer lock.Unlock()
PathMapperPlugin[opsObj.GroupVersionKind()] = opsObj
}

func RegisterOpsPathMapperToPlugins(opsObj OpsPathMapper) {
RegisterToPathMapperPlugin(opsObj)
api.Register(opsObj.GroupVersionKind(), OpsCalculator)
}

func LoadOpsPathMapper(opsObj OpsReqObject) (OpsPathMapper, error) {
gvk := getGVK(opsObj)

Expand All @@ -63,11 +67,3 @@ func LoadOpsPathMapper(opsObj OpsReqObject) (OpsPathMapper, error) {

return opsMapperObj, nil
}

func RegisterPathMapperPluginMembersWithApiPlugin(rc api.ResourceCalculator) {
lock.RLock()
defer lock.RUnlock()
for gvk := range PathMapperPlugin {
api.Register(gvk, rc)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&MariaDBOpsRequest{})
RegisterOpsPathMapperToPlugins(&MariaDBOpsRequest{})
}

type MariaDBOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&MemcachedOpsRequest{})
RegisterOpsPathMapperToPlugins(&MemcachedOpsRequest{})
}

type MemcachedOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func init() {
RegisterToPathMapperPlugin(&MongoDBOpsRequest{})
RegisterOpsPathMapperToPlugins(&MongoDBOpsRequest{})
}

type MongoDBOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&MySqlOpsRequest{})
RegisterOpsPathMapperToPlugins(&MySqlOpsRequest{})
}

type MySqlOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&PgBouncerOpsRequest{})
RegisterOpsPathMapperToPlugins(&PgBouncerOpsRequest{})
}

type PgBouncerOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&PostgresOpsRequest{})
RegisterOpsPathMapperToPlugins(&PostgresOpsRequest{})
}

type PostgresOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&ProxySQLOpsRequest{})
RegisterOpsPathMapperToPlugins(&ProxySQLOpsRequest{})
}

type ProxySQLOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&RedisOpsRequest{})
RegisterOpsPathMapperToPlugins(&RedisOpsRequest{})
}

type RedisOpsRequest struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterToPathMapperPlugin(&RedisSentinelOpsRequest{})
RegisterOpsPathMapperToPlugins(&RedisSentinelOpsRequest{})
}

type RedisSentinelOpsRequest struct{}
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ kmodules.xyz/monitoring-agent-api/client
# kmodules.xyz/offshoot-api v0.25.4
## explicit; go 1.18
kmodules.xyz/offshoot-api/api/v1
# kmodules.xyz/resource-metadata v0.17.28-0.20231023062704-59b3555434ce
# kmodules.xyz/resource-metadata v0.17.28
## explicit; go 1.18
kmodules.xyz/resource-metadata/apis/core/install
kmodules.xyz/resource-metadata/apis/core/v1alpha1
Expand All @@ -1866,7 +1866,7 @@ kmodules.xyz/resource-metadata/pkg/layouts
kmodules.xyz/resource-metadata/pkg/tableconvertor
kmodules.xyz/resource-metadata/pkg/tableconvertor/lib
kmodules.xyz/resource-metadata/pkg/tableconvertor/printers
# kmodules.xyz/resource-metrics v0.25.6
# kmodules.xyz/resource-metrics v0.25.7
## explicit; go 1.18
kmodules.xyz/resource-metrics
kmodules.xyz/resource-metrics/api
Expand Down

0 comments on commit 42c843a

Please sign in to comment.