Rancher Troobleshooting

Rancher Troobleshooting

2024/06/19 07:03:16 [ERROR] error syncing 'p-9858r/creator-project-owner': handler mgmt-auth-prtb-controller: projects.management.cattle.io "c-96kcw/p-9858r" not found, requeuing
Wed, Jun 19 2024 9:03:16 am2024/06/19 07:03:16 [ERROR] error syncing 'p-fsl78/creator-project-owner': handler mgmt-auth-prtb-controller: clusters.management.cattle.io "c-96kcw" not found, requeuing

First step check this documentation:

https://www.suse.com/support/kb/doc/?id=000020788

Some element couldn’t be delete because catch by the weekhook

$kubectl -n c-96kcw patch project.management.cattle.io p-fsl78 -p '{"metadata":{"finalizers":[]}}' --type=merge
project.management.cattle.io/p-fsl78 patched (no change)

$kubectl delete -f delete_obj.json
Error from server (BadRequest): error when deleting "delete_obj.json": admission webhook "rancher.cattle.io.projects.management.cattle.io" denied the request: System Project cannot be deleted


According the webhook code

func (a *admitter) admitDelete(project *v3.Project) (*admissionv1.AdmissionResponse, error) {
	if project.Labels[systemProjectLabel] == "true" {
		return admission.ResponseBadRequest("System Project cannot be deleted"), nil
	}
	return admission.ResponseAllowed(), nil
}


Edit the object and remove the label

kubectl edit -n c-96kcw project.management.cattle.io/p-fsl78

remove this line

"authz.management.cattle.io/system-project": "true"

Exemple

{
    "apiVersion": "management.cattle.io/v3",
    "kind": "Project",
    "metadata": {
        "annotations": {
            "authz.management.cattle.io/creator-role-bindings": "{\"created\":[\"project-owner\"],\"required\":[\"project-owner\"]}",
            "field.cattle.io/creatorId": "user-ffk59",
            "field.cattle.io/systemImageVersion": "{\"alerting\":\"system-library-rancher-monitoring-initializing\",\"logging\":\"system-library-rancher-logging-initializing\",\"pipeline\":\"08e535a\"}",
            "lifecycle.cattle.io/create.mgmt-project-rbac-remove": "true",
            "lifecycle.cattle.io/create.project-namespace-auth_c-96kcw": "true"
        },
        "creationTimestamp": "2023-01-05T10:24:39Z",
        "generateName": "p-",
        "generation": 7,
        "labels": {
            "authz.management.cattle.io/system-project": "true",   <----------- remove this line
            "cattle.io/creator": "norman"
        },
        "name": "p-fsl78",
        "namespace": "c-96kcw",
        "resourceVersion": "267529710",
        "uid": "6ffa76d2-b16d-4ae4-822e-78174802bef6"
    },