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

Fix quota namespace not found #109

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package-function: docker-build
yq e '.spec.image="${GHCR_IMG}"' package/crossplane.yaml.template > package/crossplane.yaml
rm -f package/*.xpkg
go run github.com/crossplane/crossplane/cmd/crank xpkg build -f package --verbose --embed-runtime-image=${GHCR_IMG} -o package/package-function-appcat.xpkg
git checkout package/crossplane.yaml

.PHONY: install-proxy
install-proxy:
Expand Down
8 changes: 6 additions & 2 deletions pkg/comp-functions/functions/common/namespace-quotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ func AddInitialNamespaceQuotas(namespaceKon string) func(context.Context, *runti
err := svc.GetObservedKubeObject(ns, namespaceKon)
if err != nil {
if err == runtime.ErrNotFound {
err = svc.GetObservedKubeObject(ns, namespaceKon)
err = svc.GetDesiredKubeObject(ns, namespaceKon)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("cannot get namespace: %w", err))
}
// Make sure we don't touch this, if there's no name in the namespace.
if ns.GetName() == "" {
return runtime.NewWarningResult("namespace doesn't yet have a name")
}
} else {
return runtime.NewFatalResult(fmt.Errorf("cannot get namespace: %w", err))
}
Expand Down Expand Up @@ -67,7 +71,7 @@ func AddInitialNamespaceQuotas(namespaceKon string) func(context.Context, *runti
// We only act if either the quotas were missing or the organization label is not on the
// namespace. Otherwise we ignore updates. This is to prevent any unwanted overwriting.
if quotas.AddInitalNamespaceQuotas(ctx, ns, s, objectMeta.TypeMeta.Kind) || orgAdded {
err = svc.SetDesiredKubeObject(ns, namespaceKon)
err = svc.SetDesiredKubeObjectWithName(ns, ns.GetName(), namespaceKon)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("cannot save namespace quotas: %w", err))
}
Expand Down