Skip to content

Commit

Permalink
Merge pull request #109 from vshn/fix/quota
Browse files Browse the repository at this point in the history
Fix quota namespace not found
  • Loading branch information
Kidswiss authored Nov 29, 2023
2 parents 97cb069 + 0786141 commit 62b19c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit 62b19c0

Please sign in to comment.