Skip to content

Commit e1c04ac

Browse files
authored
Merge pull request #3553 from gman0/cachedresources-schema
Add CachedResourceSchemaSource for CachedResource
2 parents c4f16ce + 7a112ac commit e1c04ac

23 files changed

+2584
-122
lines changed

cmd/virtual-workspaces/command/cmd.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ func Run(ctx context.Context, o *options.Options) error {
149149
go http.ListenAndServe(o.ProfilerAddress, nil)
150150
}
151151

152-
// Start the CachedObjects informer against the cache server.
153-
_ = cacheKcpInformers.Cache().V1alpha1().CachedObjects().Informer()
154-
155152
// create apiserver
156153
scheme := runtime.NewScheme()
157154
metav1.AddToGroupVersion(scheme, schema.GroupVersion{Group: "", Version: "v1"})

config/crds/cache.kcp.io_cachedresources.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,42 @@ spec:
216216
- cache
217217
- local
218218
type: object
219+
resourceSchemaSource:
220+
description: ResourceSchemaSource is a reference to the schema object
221+
of the cached resource.
222+
properties:
223+
apiResourceSchema:
224+
description: APIResourceSchema defines an APIResourceSchema as
225+
the source of the schema.
226+
properties:
227+
clusterName:
228+
description: ClusterName is the name of the cluster where
229+
the APIResourceSchema is defined.
230+
minLength: 1
231+
type: string
232+
name:
233+
description: Name is the APIResourceSchema name.
234+
minLength: 1
235+
type: string
236+
required:
237+
- clusterName
238+
- name
239+
type: object
240+
crd:
241+
description: CRD defines a CRD as the source of the schema.
242+
properties:
243+
name:
244+
description: Name is the CRD name.
245+
minLength: 1
246+
type: string
247+
resourceVersion:
248+
description: ResourceVersion is the resource version of the
249+
source CRD object.
250+
type: string
251+
required:
252+
- name
253+
type: object
254+
type: object
219255
type: object
220256
required:
221257
- spec

config/root-phase0/apiexport-cache.kcp.io.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spec:
1212
crd: {}
1313
- group: cache.kcp.io
1414
name: cachedresources
15-
schema: v250523-2b8c1d3c5.cachedresources.cache.kcp.io
15+
schema: v250830-080348246.cachedresources.cache.kcp.io
1616
storage:
1717
crd: {}
1818
status: {}

config/root-phase0/apiresourceschema-cachedresources.cache.kcp.io.yaml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apis.kcp.io/v1alpha1
22
kind: APIResourceSchema
33
metadata:
44
creationTimestamp: null
5-
name: v250523-2b8c1d3c5.cachedresources.cache.kcp.io
5+
name: v250830-080348246.cachedresources.cache.kcp.io
66
spec:
77
group: cache.kcp.io
88
names:
@@ -213,6 +213,42 @@ spec:
213213
- cache
214214
- local
215215
type: object
216+
resourceSchemaSource:
217+
description: ResourceSchemaSource is a reference to the schema object
218+
of the cached resource.
219+
properties:
220+
apiResourceSchema:
221+
description: APIResourceSchema defines an APIResourceSchema as the
222+
source of the schema.
223+
properties:
224+
clusterName:
225+
description: ClusterName is the name of the cluster where the
226+
APIResourceSchema is defined.
227+
minLength: 1
228+
type: string
229+
name:
230+
description: Name is the APIResourceSchema name.
231+
minLength: 1
232+
type: string
233+
required:
234+
- clusterName
235+
- name
236+
type: object
237+
crd:
238+
description: CRD defines a CRD as the source of the schema.
239+
properties:
240+
name:
241+
description: Name is the CRD name.
242+
minLength: 1
243+
type: string
244+
resourceVersion:
245+
description: ResourceVersion is the resource version of the
246+
source CRD object.
247+
type: string
248+
required:
249+
- name
250+
type: object
251+
type: object
216252
type: object
217253
required:
218254
- spec

pkg/cache/server/bootstrap/bootstrap.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func Bootstrap(ctx context.Context, apiExtensionsClusterClient kcpapiextensionsc
5252
{"core.kcp.io", "logicalclusters"},
5353
{"core.kcp.io", "shards"},
5454
{"cache.kcp.io", "cachedobjects"},
55+
{"cache.kcp.io", "cachedresources"},
5556
{"tenancy.kcp.io", "workspacetypes"},
5657
{"rbac.authorization.k8s.io", "roles"},
5758
{"rbac.authorization.k8s.io", "clusterroles"},

pkg/openapi/zz_generated.openapi.go

Lines changed: 95 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/reconciler/apis/apibinding/logical_cluster_lock.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ func UnmarshalResourceBindingsAnnotation(ann string) (ResourceBindingsAnnotation
7575
return rbs, nil
7676
}
7777

78+
// GetResourceBindings reads ResourceBindingsAnnotation from LogicalCluster's annotation.
79+
func GetResourceBindings(lc *corev1alpha1.LogicalCluster) (ResourceBindingsAnnotation, error) {
80+
const jsonEmptyObj = "{}"
81+
82+
ann := lc.Annotations[ResourceBindingsAnnotationKey]
83+
if ann == "" {
84+
ann = jsonEmptyObj
85+
}
86+
87+
return UnmarshalResourceBindingsAnnotation(ann)
88+
}
89+
7890
// WithLockedResources tries to lock the resources for the given binding. It
7991
// returns those resources that got successfully locked. If a resource is already
8092
// locked by another binding, it is skipped and returned in the second return

0 commit comments

Comments
 (0)