From 64e4f0e0103ab75fb797d3b8873b9d7223fab4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Socho=C5=84?= Date: Fri, 18 Feb 2022 20:08:48 +0100 Subject: [PATCH 1/2] Update how to add new runbook --- content/docs/add-runbook.md | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/content/docs/add-runbook.md b/content/docs/add-runbook.md index 25f0207..b79b0f1 100644 --- a/content/docs/add-runbook.md +++ b/content/docs/add-runbook.md @@ -13,8 +13,9 @@ menu: 2. Open a PR with new file placed in correct component subdirectory. You can use [links below to open a PR directly](#pr-links) 3. Name the new file the same as the alert it describes -4. Fill in the new file following [a template below](#template). -5. Remember to put alert name at the top of the file +4. Ensure the file has `.md` extension +5. Fill in the new file following [a template below](#template). +6. Remember to put alert name at the top of the file ### Finding correct component @@ -37,7 +38,7 @@ For example `KubeStateMetricsListErrors` suggest it is a kube-state-metrics aler Runbook example based on a NodeFilesystemSpaceFillingUp (thanks to @beorn7): -``` +```text # NodeFilesystemSpaceFillingUp ## Meaning @@ -69,8 +70,16 @@ Is this some irregular condition, e.g. a process fails to clean up behind itself +Cross referencing other document: + +See [Node RAID Degraded]({ {< ref "../runbooks/node/NodeRAIDDegraded.md" >} }) +(remove spaces between curly braces, this was added here to avoid auto-parsing) + [1]: https://github.github.com/gfm/#html-block + +(Notice urls are not auto processed yet in Hugo.) + ``` ### Guidelines @@ -83,6 +92,19 @@ The primary target for these runbooks are folks who are novices and don't have m To test your changes locally: -1. Install [Hugo](https://gohugo.io/getting-started/installing/) +1. Install [Hugo](https://gohugo.io/getting-started/installing/), + notice `Extended` version 2. Run `git submodule init` and `git submodule update` to clone the Hugo theme -3. Run `hugo server` and navigate to http://localhost:1313/ in your browser +3. Run `hugo server` for example as container + from the root of the git repo: + + ```shell + docker run --rm -it -v $(pwd):/src -p 1313:1313 klakegg/hugo:ext-alpine server + ``` + + and navigate to [localhost:1313](http://localhost:1313/) in your browser. + +4. extra scripts in `hack/` to check links (linux specific): + + - `check_urls.sh`: git + grep + wget + - `spider.sh`: [linkcheck](https://github.com/tennox/linkcheck) From 6862dc7b6d718f8e116ad6c38e8d83b8f063ab84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Socho=C5=84?= Date: Fri, 18 Feb 2022 20:08:48 +0100 Subject: [PATCH 2/2] Add scripts to check urls --- .gitignore | 2 ++ hack/check_urls.sh | 27 +++++++++++++++++++++++++++ hack/spider.sh | 7 +++++++ 3 files changed, 36 insertions(+) create mode 100755 hack/check_urls.sh create mode 100755 hack/spider.sh diff --git a/.gitignore b/.gitignore index 1c3fa73..60933f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ public/ resources/ .hugo_build.lock +hack/kps/ +hack/run.log diff --git a/hack/check_urls.sh b/hack/check_urls.sh new file mode 100755 index 0000000..de47a6c --- /dev/null +++ b/hack/check_urls.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# check urls via trying to connect to hugo server on localhost:1313 + +rm -rf kps +git clone --depth 1 https://github.com/prometheus-community/helm-charts/ kps + +URL_PATHS=$(grep -R "runbook_url:" kps/charts/kube-prometheus-stack | grep .yaml | awk '{print $5}' | tr -d "}" | sort | uniq) + +ENDPOINT=${ENDPOINT:-"http://localhost:1313/runbooks"} + +exit_code=0 +echo "Checking runbook urls... please wait" + +for runbook in $URL_PATHS; do + if ! curl --output /dev/null --silent --head --fail "${ENDPOINT}${runbook}"; then + rule_file=$(grep -n -R "$runbook" kps/charts/kube-prometheus-stack | awk '{print $1}') + echo -e "Missing ${runbook} \n\t $EDITOR $rule_file" + exit_code=1 + fi +done + +if [ $exit_code == 0 ]; then + echo "Great Success, no issues found!" +else + echo "Oh no, errors!" +fi +exit $exit_code diff --git a/hack/spider.sh b/hack/spider.sh new file mode 100755 index 0000000..c9bf00a --- /dev/null +++ b/hack/spider.sh @@ -0,0 +1,7 @@ +#!/sur/bin/env bash +# +# crawl over all urls +ENDPOINT=${ENDPOINT:-"http://localhost:1313/"} + +echo "Checking all urls... please wait" +docker run --network=host --rm tennox/linkcheck http://localhost:1313