mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-09-08 16:27:17 +00:00
* chore: save progress Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: requests and limit policies Signed-off-by: Oliver Baehler <oliver@sudo-i.net> --------- Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
// Copyright 2020-2026 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package tenant
|
|
|
|
import (
|
|
"context"
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
|
|
|
capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
|
|
"github.com/projectcapsule/capsule/pkg/api/meta"
|
|
)
|
|
|
|
// Sets a label on the Tenant object with it's name.
|
|
func (r *Manager) ensureMetadata(ctx context.Context, tnt *capsulev1beta2.Tenant) (err error) {
|
|
if tnt.Labels == nil {
|
|
tnt.Labels = map[string]string{}
|
|
}
|
|
|
|
if v, ok := tnt.Labels[meta.TenantNameLabel]; !ok || v != tnt.Name {
|
|
tnt.Labels[meta.TenantNameLabel] = tnt.Name
|
|
}
|
|
|
|
// Rule-generated GlobalResourceQuotas are cluster scoped and protected from
|
|
// garbage-collector deletion by the managed-resource webhook. Keep the
|
|
// Tenant around until its controller can explicitly remove those children.
|
|
keepForRuleQuotas := tnt.DeletionTimestamp == nil && hasRuleGlobalResourceQuotas(tnt)
|
|
if len(tnt.Status.Spaces) == 0 && !keepForRuleQuotas {
|
|
controllerutil.RemoveFinalizer(tnt, meta.ControllerFinalizer)
|
|
} else {
|
|
controllerutil.AddFinalizer(tnt, meta.ControllerFinalizer)
|
|
}
|
|
|
|
return nil
|
|
}
|