Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Improve resiliency of the dashboard-importer wait-for-endpoint init container. #48

Merged

Conversation

jperville
Copy link
Contributor

I modified the dashboard-importer wait-for-endpoint init container to behave when the kubernetes master output does not list endpoint for grafana service (eg. before the service is available).

This should avoid the following errors in the wait-for-endpoints logs:

waiting...
test: Missing argument at index 2 # <---- avoids this
{
  "kind": "Endpoints",
  "apiVersion": "v1",
  "metadata": {
    "name": "grafana",
    "namespace": "monitoring",
    "selfLink": "/api/v1/namespaces/monitoring/endpoints/grafana",
    "uid": "48e620cf-f2a6-11e6-9cc3-0800278fef23",
    "resourceVersion": "789",
    "creationTimestamp": "2017-02-14T11:11:08Z",
    "labels": {
      "app": "grafana",
      "component": "core"
    }
  },
  "subsets": []
}

Test:

# when unexpected json response
root@1cc818a9f6d1:/# export endpoints='{   "kind": "Status",   "apiVersion": "v1",   "metadata": {},   "status": "Failure",   "message": "User \"system:anonymous\" cannot get endpoints in project \"monitoring\"",   "reason": "Forbidden",   "details": {     "name": "grafana",     "kind": "endpoints"   },   "code": 403 }'
root@1cc818a9f6d1:/#  echo $endpoints | jq -r ".subsets[]?.addresses // [] | length"
0
# when response listing at least an endpoint
root@1cc818a9f6d1:/# endpoints2='{
>   "kind": "Endpoints",
>   "apiVersion": "v1",
>   "metadata": {
>     "name": "grafana",
>     "namespace": "monitoring",
>     "selfLink": "/api/v1/namespaces/monitoring/endpoints/grafana",
>     "uid": "48e620cf-f2a6-11e6-9cc3-0800278fef23",
>     "resourceVersion": "1834",
>     "creationTimestamp": "2017-02-14T11:11:08Z",
>     "labels": {
>       "app": "grafana",
>       "component": "core"
>     }
>   },
>   "subsets": [
>     {
>       "addresses": [
>         {
>           "ip": "10.128.0.14",
>           "nodeName": "master",
>           "targetRef": {
>             "kind": "Pod",
>             "namespace": "monitoring",
>             "name": "grafana-core-1-tbqlt",
>             "uid": "2c3322a9-f2a7-11e6-9cc3-0800278fef23",
>             "resourceVersion": "1831"
>           }
>         }
>       ],
>       "ports": [
>         {
>           "port": 3000,
>           "protocol": "TCP"
>         }
>       ]
>     }
>   ]
> }
> '
root@1cc818a9f6d1:/# echo $endpoints2 | jq -r ".subsets[]?.addresses // [] | length"
1

@mbukosky
Copy link

mbukosky commented Apr 9, 2017

This fix worked great for me. Thanks

@webwurst webwurst merged commit a925188 into giantswarm:master Apr 12, 2017
@webwurst
Copy link
Contributor

@jperville thank you very much \o/

@jperville
Copy link
Contributor Author

Thank you very much @webwurst

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants