Notifications

25 views

Description

  • On running serverless Kubernetes horizontal discovery,  the nodes section "15.2. forming k8s_nodes data" errors out as below

    "Failed to parse content due to the following error: Failed to parse XML file. Error: Problem with File Structure"





  • The Json file looks like the below and when checked with Json Checker no issues are observed.

    {"kind":"NodeList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/nodes","resourceVersion":"289462"},"items":[{"metadata":{"name":"ip-172-31-30-174","selfLink":"/api/v1/nodes/ip-172-31-30-174","uid":"ba6b725f-7daa-4209-b77e-624c8ce68eed","resourceVersion":"288817","creationTimestamp":"2020-08-04T18:19:43Z","labels":{"beta.kubernetes.io/arch":"amd64","beta.kubernetes.io/os":"linux","kubernetes.io/arch":"amd64","kubernetes.io/hostname":"ip-172-31-30-174","kubernetes.io/os":"linux","node-role.kubernetes.io/master":""},"annotations":{"kubeadm.alpha.kubernetes.io/cri-socket":"/var/run/dockershim.sock","node.alpha.kubernetes.io/ttl":"0","volumes.kubernetes.io/controller-managed-attach-detach":"true"},"managedFields":[{"manager":"kubeadm","operation":"Update","apiVersion":"v1","time":"2020-08-04T18:19:46Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{"f:kubeadm.alpha.kubernetes.io/cri-socket":{}},"f:labels":{"f:node-role.kubernetes.io/master":{}}}}},{"manager":"kube-controller-manager","operation":"Update","apiVersion":"v1","time":"2020-08-05T06:46:38Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{"f:node.alpha.kubernetes.io/ttl":{}}}}},{"manager":"kubelet","operation":"Update","apiVersion":"v1","time":"2020-08-06T05:37:42Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:volumes.kubernetes.io/controller-managed-attach-detach":{}},"f:labels":{".":{},"f:beta.kubernetes.io/arch":{},"f:beta.kubernetes.io/os":{},"f:kubernetes.io/arch":{},"f:kubernetes.io/hostname":{},"f:kubernetes.io/os":{}}},"f:status":{"f:addresses":{".":{},"k:{\"type\":\"Hostname\"}":{".":{},"f:address":{},"f:type":{}},"k:{\"type\":\"InternalIP\"}":{".":{},"f:address":{},"f:type":{}}},"f:allocatable":{".":{},"f:cpu":{},"f:ephemeral-storage":{},"f:hugepages-2Mi":{},"f:memory":{},"f:pods":{}},"f:capacity":{".":{},"f:cpu":{},"f:ephemeral-storage":{},"f:hugepages-2Mi":{},"f:memory":{},"f:pods":{}},"f:conditions":{".":{},"k:{\"type\":\"DiskPressure\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}},"k:{\"type\":\"MemoryPressure\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}},"k:{\"type\":\"PIDPressure\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}},"k:{\"type\":\"Ready\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}}},"f:daemonEndpoints":{"f:kubeletEndpoint":{"f:Port":{}}},"f:images":{},"f:nodeInfo":{"f:architecture":{},"f:bootID":{},"f:containerRuntimeVersion":{},"f:kernelVersion":{},"f:kubeProxyVersion":{},"f:kubeletVersion":{},"f:machineID":{},"f:operatingSystem":{},"f:osImage":{},"f:systemUUID":{}}}}}]},"spec":{},"status":{"capacity":{"cpu":"2","ephemeral-storage":"8065444Ki","hugepages-2Mi":"0","memory":"4044960Ki","pods":"110"},"allocatable":{"cpu":"2","ephemeral-storage":"7433113179","hugepages-2Mi":"0","memory":"3942560Ki","pods":"110"},"conditions":[{"type":"MemoryPressure","status":"False","lastHeartbeatTime":"2020-08-06T05:37:42Z","lastTransitionTime":"2020-08-04T18:19:39Z","reason":"KubeletHasSufficientMemory","message":"kubelet has sufficient memory available"},{"type":"DiskPressure","status":"False","lastHeartbeatTime":"2020-08-06T05:37:42Z","lastTransitionTime":"2020-08-04T18:19:39Z","reason":"KubeletHasNoDiskPressure","message":"kubelet has no disk pressure"},{"type":"PIDPressure","status":"False","lastHeartbeatTime":"2020-08-06T05:37:42Z","lastTransitionTime":"2020-08-04T18:19:39Z","reason":"KubeletHasSufficientPID","message":"kubelet has sufficient PID available"},{"type":"Ready","status":"True","lastHeartbeatTime":"2020-08-06T05:37:42Z","lastTransitionTime":"2020-08-05T06:46:48Z","reason":"KubeletReady","message":"kubelet is posting ready status. AppArmor enabled"}],"addresses":[{"type":"InternalIP","address":"172.31.30.174"},{"type":"Hostname","address":"ip-172-31-30-174"}],"daemonEndpoints":{"kubeletEndpoint":{"Port":10250}},"nodeInfo":{"machineID":"622240fbfdc040b786522fc7d05f4d37","systemUUID":"EC25BB79-9C14-0237-5DDC-14B5A9FF3E70","bootID":"e462276b-f4cb-46ee-b728-3a205a3576b1","kernelVersion":"4.4.0-1111-aws","osImage":"Ubuntu 16.04.6 LTS","containerRuntimeVersion":"docker://18.9.7","kubeletVersion":"v1.18.6","kubeProxyVersion":"v1.18.6","operatingSystem":"linux","architecture":"amd64"},"images":[{"names":["k8s.gcr.io/etcd@sha256:4afb99b4690b418ffc2ceb67e1a17376457e441c1f09ab55447f0aaf992fa646","k8s.gcr.io/etcd:3.4.3-0"],"sizeBytes":288426917},{"names":["k8s.gcr.io/kube-apiserver@sha256:67c8050918d28041163d973fa7cca9a84031a58e28e4ad3eb48a7a05a285520a","k8s.gcr.io/kube-apiserver:v1.18.6"],"sizeBytes":173001499},{"names":["k8s.gcr.io/kube-controller-manager@sha256:976ed781a4ab1f4952367635549aad755e9304047a5418c5901abab39b201617","k8s.gcr.io/kube-controller-manager:v1.18.6"],"sizeBytes":162392859},{"names":["nginx@sha256:c6abe64bc5923b074543c363c27f32f2c817cc02eea5718c3f0046cc1e0cb9b0","nginx:latest"],"sizeBytes":132484488},{"names":["k8s.gcr.io/kube-proxy@sha256:2a76fb7c2b2cafed3e65d9eb63b56b97e386f521739896934e46be3a2d580ce2","k8s.gcr.io/kube-proxy:v1.18.6"],"sizeBytes":117094721},{"names":["k8s.gcr.io/kube-scheduler@sha256:ac67a5c90f2bf3d86e937a9878f561f26801f13c6b30b05197fdc646aa1ac209","k8s.gcr.io/kube-scheduler:v1.18.6"],"sizeBytes":95283995},{"names":["quay.io/coreos/flannel@sha256:6d451d92c921f14bfb38196aacb6e506d4593c5b3c9d40a8b8a2506010dc3e10","quay.io/coreos/flannel:v0.12.0-amd64"],"sizeBytes":52767393},{"names":["k8s.gcr.io/coredns@sha256:2c8d61c46f484d881db43b34d13ca47a269336e576c81cf007ca740fa9ec0800","k8s.gcr.io/coredns:1.6.7"],"sizeBytes":43794147},{"names":["k8s.gcr.io/pause@sha256:927d98197ec1141a368550822d18fa1c60bdae27b78b0c004f705f548c07814f","k8s.gcr.io/pause:3.2"],"sizeBytes":682696}]}},{"metadata":{"name":"ip-172-31-40-63","selfLink":"/api/v1/nodes/ip-172-31-40-63","uid":"502b8a26-53d8-45e3-a51c-35a72a256486","resourceVersion":"289082","creationTimestamp":"2020-08-05T06:20:50Z","labels":{"beta.kubernetes.io/arch":"amd64","beta.kubernetes.io/os":"linux","kubernetes.io/arch":"amd64","kubernetes.io/hostname":"ip-172-31-40-63","kubernetes.io/os":"linux","type":"hdd"},"annotations":{"kubeadm.alpha.kubernetes.io/cri-socket":"/var/run/dockershim.sock","node.alpha.kubernetes.io/ttl":"0","volumes.kubernetes.io/controller-managed-attach-detach":"true"},"managedFields":[{"manager":"kubeadm","operation":"Update","apiVersion":"v1","time":"2020-08-05T06:20:54Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{"f:kubeadm.alpha.kubernetes.io/cri-socket":{}}}}},{"manager":"kubectl","operation":"Update","apiVersion":"v1","time":"2020-08-05T07:21:46Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{"f:type":{}}}}},{"manager":"kube-controller-manager","operation":"Update","apiVersion":"v1","time":"2020-08-05T07:33:37Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{"f:node.alpha.kubernetes.io/ttl":{}}}}},{"manager":"kubelet","operation":"Update","apiVersion":"v1","time":"2020-08-06T05:39:37Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:volumes.kubernetes.io/controller-managed-attach-detach":{}},"f:labels":{".":{},"f:beta.kubernetes.io/arch":{},"f:beta.kubernetes.io/os":{},"f:kubernetes.io/arch":{},"f:kubernetes.io/hostname":{},"f:kubernetes.io/os":{}}},"f:status":{"f:addresses":{".":{},"k:{\"type\":\"Hostname\"}":{".":{},"f:address":{},"f:type":{}},"k:{\"type\":\"InternalIP\"}":{".":{},"f:address":{},"f:type":{}}},"f:allocatable":{".":{},"f:cpu":{},"f:ephemeral-storage":{},"f:hugepages-2Mi":{},"f:memory":{},"f:pods":{}},"f:capacity":{".":{},"f:cpu":{},"f:ephemeral-storage":{},"f:hugepages-2Mi":{},"f:memory":{},"f:pods":{}},"f:conditions":{".":{},"k:{\"type\":\"DiskPressure\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}},"k:{\"type\":\"MemoryPressure\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}},"k:{\"type\":\"PIDPressure\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}},"k:{\"type\":\"Ready\"}":{".":{},"f:lastHeartbeatTime":{},"f:lastTransitionTime":{},"f:message":{},"f:reason":{},"f:status":{},"f:type":{}}},"f:daemonEndpoints":{"f:kubeletEndpoint":{"f:Port":{}}},"f:images":{},"f:nodeInfo":{"f:architecture":{},"f:bootID":{},"f:containerRuntimeVersion":{},"f:kernelVersion":{},"f:kubeProxyVersion":{},"f:kubeletVersion":{},"f:machineID":{},"f:operatingSystem":{},"f:osImage":{},"f:systemUUID":{}}}}}]},"spec":{},"status":{"capacity":{"cpu":"2","ephemeral-storage":"8065444Ki","hugepages-2Mi":"0","memory":"4044972Ki","pods":"110"},"allocatable":{"cpu":"2","ephemeral-storage":"7433113179","hugepages-2Mi":"0","memory":"3942572Ki","pods":"110"},"conditions":[{"type":"MemoryPressure","status":"False","lastHeartbeatTime":"2020-08-06T05:39:37Z","lastTransitionTime":"2020-08-05T06:20:50Z","reason":"KubeletHasSufficientMemory","message":"kubelet has sufficient memory available"},{"type":"DiskPressure","status":"False","lastHeartbeatTime":"2020-08-06T05:39:37Z","lastTransitionTime":"2020-08-05T06:20:50Z","reason":"KubeletHasNoDiskPressure","message":"kubelet has no disk pressure"},{"type":"PIDPressure","status":"False","lastHeartbeatTime":"2020-08-06T05:39:37Z","lastTransitionTime":"2020-08-05T06:20:50Z","reason":"KubeletHasSufficientPID","message":"kubelet has sufficient PID available"},{"type":"Ready","status":"True","lastHeartbeatTime":"2020-08-06T05:39:37Z","lastTransitionTime":"2020-08-05T07:33:37Z","reason":"KubeletReady","message":"kubelet is posting ready status. AppArmor enabled"}],"addresses":[{"type":"InternalIP","address":"172.31.40.63"},{"type":"Hostname","address":"ip-172-31-40-63"}],"daemonEndpoints":{"kubeletEndpoint":{"Port":10250}},"nodeInfo":{"machineID":"662acab651694631900575218846bcf2","systemUUID":"EC243C0A-7BA0-E292-B365-77A5673D7BD3","bootID":"fbd33d1c-63c5-4043-ac29-49dc557dcfe7","kernelVersion":"4.4.0-1109-aws","osImage":"Ubuntu 16.04.6 LTS","containerRuntimeVersion":"docker://18.9.7","kubeletVersion":"v1.18.6","kubeProxyVersion":"v1.18.6","operatingSystem":"linux","architecture":"amd64"},"images":[{"names":["nginx@sha256:36b74457bccb56fbf8b05f79c85569501b721d4db813b684391d63e02287c0b2","nginx:latest"],"sizeBytes":132491506},{"names":["k8s.gcr.io/kube-proxy@sha256:2a76fb7c2b2cafed3e65d9eb63b56b97e386f521739896934e46be3a2d580ce2","k8s.gcr.io/kube-proxy:v1.18.6"],"sizeBytes":117094721},{"names":["k8s.gcr.io/pause@sha256:927d98197ec1141a368550822d18fa1c60bdae27b78b0c004f705f548c07814f","k8s.gcr.io/pause:3.2"],"sizeBytes":682696}]}}]}

Release or Environment

  • All

Resolution

  • As a first step, review if "/root" is added in the "Step 6.5" of the pattern "Kubernetes" in the advanced options per the below article

    https://hi.service-now.com/kb_view.do?sys_kb_id=f7149ee2db17b7005ed4a851ca96196e

  • Add the below steps "6.4. Forming services data failover" and "6.5. Parsing services data" after the step "6.3. forming services data" on the "Kubernetes" pattern as below.

  • 6.4. Forming services data failover



  • The Eval script on the above step 6.4, should be as below

    var rtrn = "";
    var res = ${response};
    var len = res.size();
    var data = "";

    for(i=0;i<len;i++){
       var el = res.get(i);
       var payloadObj = JSON.parse(el);
       if(payloadObj.hasOwnProperty('items')){
          var payVal = payloadObj.items;
          for(k=0;k<payVal.length;k++){
             if(payVal[k].metadata.name){
                data = data+payVal[k].metadata.name+',';
             }
              if(payVal[k].metadata.namespace){
                data = data+payVal[k].metadata.namespace+',';
             }
              if(payVal[k].metadata.uid){
                data = data+payVal[k].metadata.uid+',';
             }
              if(payVal[k].spec.clusterIP){
                data = data+payVal[k].spec.clusterIP+',';
             }
              if(payVal[k].metadata.name){
                data = data+payVal[k].metadata.name+' NEWLINE ';
             }
          }
       }
    }
    rtrn = data;




  • 6.5. Parsing services data



  • Add a step under "Target : $services_selector_label" in the step "6.14. forming services selector/label data" with "Target Field Name as "k8s_uid"", and the eval script as below for populating k8s_uid, so that it is correctly parsed.



    Eval Script

    var rtrn = '';
    var serviceLabel = ${services_selector_label[].services_delimeted};
    var matches = serviceLabel.match(/"uid":\s*\"([\s\S]*?)\"/);
    rtrn = matches ? matches[1] : '';



  • Save and Publish the pattern with the above changes and it should work without any errors.

Article Information

Last Updated:2020-09-21 07:44:40
Published:2020-09-14
Screen Shot 2020-08-10 at 08.30.39 (1).png[View]Screen Shot 2020-08-10 at 08.31.23 (1).png[View]Screen Shot 2020-09-14 at 1.01.08 AM.png[View]Screen Shot 2020-09-14 at 1.03.13 AM.png[View]Screen Shot 2020-09-14 at 1.17.09 AM.png[View]Screen Shot 2020-09-14 at 1.18.37 AM.png[View]Screen Shot 2020-09-14 at 1.18.37 AM.png[View]Screen Shot 2020-09-14 at 12.56.53 AM.png[View]