Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single cache for all dynamic controllers (i.e. XRs and claims) #5651

Merged
merged 10 commits into from
May 21, 2024
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ jobs:
- environment-configs
- usage
- ssa-claims
- realtime-compositions

steps:
- name: Setup QEMU
Expand Down
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ linters:
# to communicate what the bool means.
- nonamedreturns

# Warns about taking the address of a range variable. This isn't an issue in
# Go v1.22 and above: https://tip.golang.org/doc/go1.22
- exportloopref

linters-settings:
errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
Expand Down Expand Up @@ -224,6 +228,7 @@ issues:
# Excluding generated files.
exclude-files:
- "zz_generated\\..+\\.go$"
- ".+\\.pb.go$"
# Excluding configuration per-path and per-linter.
exclude-rules:
# Exclude some linters from running on tests files.
Expand Down Expand Up @@ -282,6 +287,13 @@ issues:
linters:
- gosec
- gas

# This is about implicit memory aliasing in a range loop.
# This is a false positive with Go v1.22 and above.
- text: "G601:"
linters:
- gosec
- gas

# Some k8s dependencies do not have JSON tags on all fields in structs.
- path: k8s.io/
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ fallthrough: submodules
@make

CRD_DIR = cluster/crds
CRD_PATCH_DIR = cluster/crd-patches

# See patch files for details.
crds.patch: $(KUBECTL)
@$(INFO) patching generated CRDs
@mkdir $(WORK_DIR)/patch
@$(KUBECTL) patch --local --type=json -f $(CRD_DIR)/pkg.crossplane.io_deploymentruntimeconfigs.yaml --patch-file $(CRD_PATCH_DIR)/pkg.crossplane.io_deploymentruntimeconfigs.yaml -o yaml > $(WORK_DIR)/patch/pkg.crossplane.io_deploymentruntimeconfigs.yaml
@mv $(WORK_DIR)/patch/pkg.crossplane.io_deploymentruntimeconfigs.yaml $(CRD_DIR)/pkg.crossplane.io_deploymentruntimeconfigs.yaml
@$(OK) patched generated CRDs

crds.clean:
@$(INFO) cleaning generated CRDs
Expand All @@ -93,7 +102,7 @@ generate.run: gen-kustomize-crds gen-chart-license
gen-chart-license:
@cp -f LICENSE cluster/charts/crossplane/LICENSE

generate.done: crds.clean
generate.done: crds.clean crds.patch

gen-kustomize-crds:
@$(INFO) Adding all CRDs to Kustomize file for local development
Expand Down
2 changes: 0 additions & 2 deletions apis/pkg/v1/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ type PackageRevisionList interface {
func (p *ProviderRevisionList) GetRevisions() []PackageRevision {
prs := make([]PackageRevision, len(p.Items))
for i, r := range p.Items {
r := r // Pin range variable so we can take its address.
prs[i] = &r
}
return prs
Expand All @@ -736,7 +735,6 @@ func (p *ProviderRevisionList) GetRevisions() []PackageRevision {
func (p *ConfigurationRevisionList) GetRevisions() []PackageRevision {
prs := make([]PackageRevision, len(p.Items))
for i, r := range p.Items {
r := r // Pin range variable so we can take its address.
prs[i] = &r
}
return prs
Expand Down
1 change: 0 additions & 1 deletion apis/pkg/v1beta1/function_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ func (r *FunctionRevision) SetCommonLabels(l map[string]string) {
func (p *FunctionRevisionList) GetRevisions() []v1.PackageRevision {
prs := make([]v1.PackageRevision, len(p.Items))
for i, r := range p.Items {
r := r // Pin range variable so we can take its address.
prs[i] = &r
}
return prs
Expand Down
2 changes: 0 additions & 2 deletions apis/pkg/v1beta1/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ type LockPackage struct {
func ToNodes(pkgs ...LockPackage) []dag.Node {
nodes := make([]dag.Node, len(pkgs))
for i, r := range pkgs {
r := r // Pin range variable so we can take its address.
nodes[i] = &r
}
return nodes
Expand All @@ -75,7 +74,6 @@ func (l *LockPackage) Identifier() string {
func (l *LockPackage) Neighbors() []dag.Node {
nodes := make([]dag.Node, len(l.Dependencies))
for i, r := range l.Dependencies {
r := r // Pin range variable so we can take its address.
nodes[i] = &r
}
return nodes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# For reasons that aren't immediately obvious, updating k8s.io/code-generator
# from v0.29.x to v0.30 triggers a variant of the below issue. As far as I can
# tell, this is the only way to work around it. The below fields are list map
# keys, but aren't required in the generated CRD.
# https://github.com/kubernetes-sigs/controller-tools/issues/444

- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/deploymentTemplate/properties/spec/properties/template/properties/spec/properties/hostAliases/items/required
value:
- ip

- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/deploymentTemplate/properties/spec/properties/template/properties/spec/properties/imagePullSecrets/items/required
value:
- name
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
kind:
description: |-
kind is the serialized kind of the resource. It is normally CamelCase and singular.
Expand All @@ -103,6 +104,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
singular:
description: singular is the singular name of the resource. It
must be all lowercase. Defaults to lowercased `kind`.
Expand Down Expand Up @@ -222,6 +224,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- conversionReviewVersions
type: object
Expand Down Expand Up @@ -312,6 +315,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
kind:
description: |-
kind is the serialized kind of the resource. It is normally CamelCase and singular.
Expand All @@ -336,6 +340,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
singular:
description: singular is the singular name of the resource. It
must be all lowercase. Defaults to lowercased `kind`.
Expand Down
5 changes: 5 additions & 0 deletions cluster/crds/pkg.crossplane.io_configurationrevisions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
nonResourceURLs:
description: |-
NonResourceURLs is a set of partial urls that a user should have access to. *s are allowed, but only as the full, final step in the path
Expand All @@ -250,25 +251,29 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
resourceNames:
description: ResourceNames is an optional white list of names
that the rule applies to. An empty set means that everything
is allowed.
items:
type: string
type: array
x-kubernetes-list-type: atomic
resources:
description: Resources is a list of resources this rule applies
to. '*' represents all resources.
items:
type: string
type: array
x-kubernetes-list-type: atomic
verbs:
description: Verbs is a list of Verbs that apply to ALL the
ResourceKinds contained in this rule. '*' represents all verbs.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- verbs
type: object
Expand Down