knight42 / kubectl-blame

Show who edited resource fields.
MIT License
135 stars 8 forks source link

Cryptic error trying to blame a service #3

Closed alvaroaleman closed 3 years ago

alvaroaleman commented 3 years ago

Hey I am trying to use kubectl-blame for a service and I am getting the following error:

$ k blame service kube-apiserver
Error: unknown element: fieldpath.PathElement{FieldName:(*string)(nil), Key:(*value.FieldList)(nil), Value:(*value.Value)(0xc0000f09a0), Index:(*int)(nil)}

Any idea what the issue could be?

The service looks as follows:

$ k get service kube-apiserver -ojson --show-managed-fields=true
{
    "apiVersion": "v1",
    "kind": "Service",
    "metadata": {
        "creationTimestamp": "2021-10-21T16:13:06Z",
        "finalizers": [
            "service.kubernetes.io/load-balancer-cleanup"
        ],
        "managedFields": [
            {
                "apiVersion": "v1",
                "fieldsType": "FieldsV1",
                "fieldsV1": {
                    "f:metadata": {
                        "f:finalizers": {
                            ".": {},
                            "v:\"service.kubernetes.io/load-balancer-cleanup\"": {}
                        }
                    },
                    "f:status": {
                        "f:loadBalancer": {
                            "f:ingress": {}
                        }
                    }
                },
                "manager": "kube-controller-manager",
                "operation": "Update",
                "time": "2021-10-21T16:13:08Z"
            },
            {
                "apiVersion": "v1",
                "fieldsType": "FieldsV1",
                "fieldsV1": {
                    "f:metadata": {
                        "f:ownerReferences": {
                            ".": {},
                            "k:{\"uid\":\"03ff3876-b743-4302-8969-1cf517062f2b\"}": {
                                ".": {},
                                "f:apiVersion": {},
                                "f:blockOwnerDeletion": {},
                                "f:controller": {},
                                "f:kind": {},
                                "f:name": {},
                                "f:uid": {}
                            }
                        }
                    },
                    "f:spec": {
                        "f:externalTrafficPolicy": {},
                        "f:ports": {
                            ".": {},
                            "k:{\"port\":6443,\"protocol\":\"TCP\"}": {
                                ".": {},
                                "f:port": {},
                                "f:protocol": {},
                                "f:targetPort": {}
                            }
                        },
                        "f:selector": {
                            ".": {},
                            "f:app": {},
                            "f:hypershift.openshift.io/control-plane-component": {},
                            "f:hypershift.openshift.io/hosted-control-plane": {}
                        },
                        "f:sessionAffinity": {},
                        "f:type": {}
                    }
                },
                "manager": "hypershift-controlplane-manager",
                "operation": "Update",
                "time": "2021-10-21T16:51:04Z"
            }
        ],
        "name": "kube-apiserver",
        "namespace": "clusters-alvaro-test",
        "ownerReferences": [
            {
                "apiVersion": "hypershift.openshift.io/v1alpha1",
                "blockOwnerDeletion": true,
                "controller": true,
                "kind": "HostedControlPlane",
                "name": "alvaro-test",
                "uid": "03ff3876-b743-4302-8969-1cf517062f2b"
            }
        ],
        "resourceVersion": "124245",
        "uid": "48b6f513-8d78-4c3e-8382-7f52c0fadd81"
    },
    "spec": {
        "clusterIP": "172.30.2.255",
        "clusterIPs": [
            "172.30.2.255"
        ],
        "externalTrafficPolicy": "Cluster",
        "ipFamilies": [
            "IPv4"
        ],
        "ipFamilyPolicy": "SingleStack",
        "ports": [
            {
                "nodePort": 31556,
                "port": 6443,
                "protocol": "TCP",
                "targetPort": 6443
            }
        ],
        "selector": {
            "app": "kube-apiserver",
            "hypershift.openshift.io/control-plane-component": "kube-apiserver",
            "hypershift.openshift.io/hosted-control-plane": "clusters-alvaro-test"
        },
        "sessionAffinity": "None",
        "type": "LoadBalancer"
    },
    "status": {
        "loadBalancer": {
            "ingress": [
                {
                    "hostname": "<<REDACTED>.elb.amazonaws.com"
                }
            ]
        }
    }
}
alvaroaleman commented 3 years ago

Also btw thanks for the awesome work on this, this plugin is really great :)

knight42 commented 3 years ago

@alvaroaleman Hi! I am glad to hear that you like this plugin! After some debugging on my machine, I believe the root cause is the finalizer field:

"f:finalizers": {
  ".": {},
  "v:\"service.kubernetes.io/load-balancer-cleanup\"": {}
}

My plugin fails to handle it now, I may work out a fix in a few days.

knight42 commented 3 years ago

@alvaroaleman Hi! I have released a new version(0.0.6) to fix this problem, please let me know if this issue is addressed.

alvaroaleman commented 3 years ago

yes v0.0.6 did the trick, thank you very much!