Skip to content

Commit

Permalink
commentMonitor: Refactor, cleanup and rename to comment-monitor.
Browse files Browse the repository at this point in the history
Some examples on how old one works (vs the unit test I added): prometheus/prometheus#15487

Signed-off-by: bwplotka <[email protected]>
  • Loading branch information
bwplotka committed Dec 12, 2024
1 parent fddf34c commit 4967bb5
Show file tree
Hide file tree
Showing 19 changed files with 998 additions and 531 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ jobs:
password_variable: DOCKER_PASSWORD
- prometheus/publish_images:
container_image_name: comment-monitor
dockerfile_path: "tools/commentMonitor/Dockerfile"
dockerbuild_context: "tools/commentMonitor/"
dockerfile_path: "tools/comment-monitor/Dockerfile"
dockerbuild_context: "tools/comment-monitor/"
registry: docker.io
organization: "$DOCKER_ORG"
login_variable: DOCKER_LOGIN
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea/
/tools/amGithubNotifier/amGithubNotifier
/tools/commentMonitor/commentMonitor
/tools/comment-monitor/comment-monitor
/tools/fake-webserver/fake-webserver
/tools/scaler/scaler
/infra/infra
Expand Down
4 changes: 2 additions & 2 deletions .promu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ build:
path: ./infra
- name: tools/amGithubNotifier
path: ./tools/amGithubNotifier
- name: tools/commentMonitor
path: ./tools/commentMonitor
- name: tools/comment-monitor
path: ./tools/comment-monitor
- name: tools/fake-webserver
path: ./tools/fake-webserver
- name: tools/scaler
Expand Down
21 changes: 13 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
cloud.google.com/go/container v1.41.0
github.com/aws/aws-sdk-go v1.55.5
github.com/google/go-github/v29 v29.0.3
github.com/nelkinda/health-go v0.0.1
github.com/prometheus/alertmanager v0.27.0
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.60.1
Expand All @@ -18,7 +19,7 @@ require (
k8s.io/apiextensions-apiserver v0.31.2
k8s.io/apimachinery v0.31.2
k8s.io/client-go v0.31.2
k8s.io/cloud-provider-gcp v0.0.0-20231031161848-992c1c33f1be
k8s.io/cloud-provider-gcp v0.0.0-20241115222652-d74b2e1d6653
sigs.k8s.io/aws-iam-authenticator v0.6.27
sigs.k8s.io/kind v0.24.0
)
Expand Down Expand Up @@ -58,6 +59,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mozillazg/go-httpheader v0.2.1 // indirect
github.com/ncw/swift v1.0.53 // indirect
github.com/nelkinda/http-go v0.0.1 // indirect
github.com/oracle/oci-go-sdk/v65 v65.41.1 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/rs/xid v1.5.0 // indirect
Expand Down Expand Up @@ -131,7 +133,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/oklog/run v1.1.0
github.com/oklog/ulid v1.3.1 // indirect
github.com/onsi/gomega v1.33.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
Expand All @@ -149,15 +151,15 @@ require (
github.com/thanos-io/objstore v0.0.0-20240913165201-fd105025a2e5
github.com/x448/float16 v0.8.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sync v0.8.0
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
Expand All @@ -175,3 +177,6 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

// Remove broken version.
exclude k8s.io/cloud-provider-gcp/providers v0.0.0-00010101000000-000000000000
110 changes: 96 additions & 14 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion prombench/design.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,49 @@ metadata:
data:
config.yml: |
prefixes:
- prefix: /prombench
help_template: |
Incorrect prombench syntax, please find [correct syntax here](https://github.com/prometheus/test-infra/tree/master/prombench#trigger-tests-via-a-github-comment).
verify_user: true
events:
- event_type: prombench_start
regex_string: (?mi)^/prombench\s*(?P<RELEASE>master|main|v[0-9]+\.[0-9]+\.[0-9]+\S*)\s*$
label: prombench
- prefix: /prombench
help: |
**Available Commands:**
* To start benchmark: `/prombench <branch or git tag to compare with>`
* To restart benchmark: `/prombench restart <branch or git tag to compare with>`
* To stop benchmark: `/prombench cancel`
* To print help: `/prombench help`
**Example:** `/prombench v3.0.0"
> NOTE: Validation of arguments are on prombench GitHub action time, not webhook time.
verify_user: true
commands:
- name: cancel
event_type: prombench_stop
comment_template: |
⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️
Benchmark cancel is in progress.
**Compared versions:** [**`PR-{{ index . "PR_NUMBER" }}`**](http://{{ index . "DOMAIN_NAME" }}/{{ index . "PR_NUMBER" }}/prometheus-pr) and [**`{{ index . "RELEASE" }}`**](http://{{ index . "DOMAIN_NAME" }}/{{ index . "PR_NUMBER" }}/prometheus-release)
- name: restart
event_type: prombench_restart
args_regex: (?P<RELEASE>master|main|v[0-9]+\.[0-9]+\.[0-9]+\S*)$
comment_template: |
⏱️ Welcome (again) to Prometheus Benchmarking Tool. ⏱️
**Compared versions:** [**`PR-{{ index . "PR_NUMBER" }}`**](http://{{ index . "DOMAIN_NAME" }}/{{ index . "PR_NUMBER" }}/prometheus-pr) and [**`{{ index . "RELEASE" }}`**](http://{{ index . "DOMAIN_NAME" }}/{{ index . "PR_NUMBER" }}/prometheus-release)
After successful deployment, the benchmarking results can be viewed at:
- [Prometheus Meta](http://{{ index . "DOMAIN_NAME" }}/prometheus-meta/graph?g0.expr={namespace%3D"prombench-{{ index . "PR_NUMBER" }}"}&g0.tab=1)
- [Prombench Dashboard](http://{{ index . "DOMAIN_NAME" }}/grafana/d/7gmLoNDmz/prombench?orgId=1&var-pr-number={{ index . "PR_NUMBER" }})
- [Grafana Explorer, Loki logs](http://{{ index . "DOMAIN_NAME" }}/grafana/explore?orgId=1&left=["now-6h","now","loki-meta",{},{"mode":"Logs"},{"ui":[true,true,true,"none"]}])
- [Grafana Exlorer, Loki logs](http://{{ index . "DOMAIN_NAME" }}/grafana/explore?orgId=1&left=["now-6h","now","loki-meta",{},{"mode":"Logs"},{"ui":[true,true,true,"none"]}])
- [Parca profiles (e.g. in-use memory)](http://{{ index . "DOMAIN_NAME" }}/profiles?expression_a=memory%3Ainuse_space%3Abytes%3Aspace%3Abytes%7Bpr_number%3D%22{{ index . "PR_NUMBER" }}%22%7D&time_selection_a=relative:minute|15)
**Other Commands:**
To stop benchmark: `/prombench cancel`
To restart benchmark: `/prombench restart {{ index . "RELEASE" }}`
- event_type: prombench_stop
regex_string: (?mi)^/prombench\s+cancel\s*$
comment_template: |
Benchmark cancel is in progress.
- event_type: noop
regex_string: (?mi)^/prombench\s*$
comment_template: |
Please add the version number to compare against.
Eg. `/prombench main`, `/prombench v2.12.0`
- event_type: prombench_restart
regex_string: (?mi)^/prombench\s+restart\s+(?P<RELEASE>master|main|v[0-9]+\.[0-9]+\.[0-9]+\S*)\s*$
**Available Commands:**
* To restart benchmark: `/prombench restart {{ index . "RELEASE" }}`
* To stop benchmark: `/prombench cancel`
* To print help: `/prombench help`
- name: "" # start is a default (empty command).
event_type: prombench_start
args_regex: (?P<RELEASE>master|main|v[0-9]+\.[0-9]+\.[0-9]+\S*)$
label: prombench
comment_template: |
⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️
Expand All @@ -51,9 +57,11 @@ data:
- [Prometheus Meta](http://{{ index . "DOMAIN_NAME" }}/prometheus-meta/graph?g0.expr={namespace%3D"prombench-{{ index . "PR_NUMBER" }}"}&g0.tab=1)
- [Prombench Dashboard](http://{{ index . "DOMAIN_NAME" }}/grafana/d/7gmLoNDmz/prombench?orgId=1&var-pr-number={{ index . "PR_NUMBER" }})
- [Grafana Exlorer, Loki logs](http://{{ index . "DOMAIN_NAME" }}/grafana/explore?orgId=1&left=["now-6h","now","loki-meta",{},{"mode":"Logs"},{"ui":[true,true,true,"none"]}])
- [Grafana Explorer, Loki logs](http://{{ index . "DOMAIN_NAME" }}/grafana/explore?orgId=1&left=["now-6h","now","loki-meta",{},{"mode":"Logs"},{"ui":[true,true,true,"none"]}])
- [Parca profiles (e.g. in-use memory)](http://{{ index . "DOMAIN_NAME" }}/profiles?expression_a=memory%3Ainuse_space%3Abytes%3Aspace%3Abytes%7Bpr_number%3D%22{{ index . "PR_NUMBER" }}%22%7D&time_selection_a=relative:minute|15)
**Other Commands:**
To stop benchmark: `/prombench cancel`
To restart benchmark: `/prombench restart {{ index . "RELEASE" }}`
**Available Commands:**
* To restart benchmark: `/prombench restart {{ index . "RELEASE" }}`
* To stop benchmark: `/prombench cancel`
* To print help: `/prombench help`
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
imagePullPolicy: Always
args:
- "--config=/etc/cm/config.yml"
- "--webhooksecretfile=/etc/github/whsecret"
- "--whsecret=/etc/github/whsecret"
name: comment-monitor
env:
- name: DOMAIN_NAME
Expand Down
2 changes: 1 addition & 1 deletion scripts/genflagdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SED_BIN=${SED_BIN:-sed}
README_FILES="./tools/*/README.md ./infra/README.md"

primary_tools=("infra")
helper_tools=("amGithubNotifier" "commentMonitor")
helper_tools=("amGithubNotifier" "comment-monitor")

function fetch_embedmd {
pushd ..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM quay.io/prometheus/busybox:latest

LABEL maintainer="The Prometheus Authors <[email protected]>"

COPY ./commentMonitor /bin/commentMonitor
COPY ./comment-monitor /bin/comment-monitor

ENTRYPOINT ["/bin/commentMonitor"]
ENTRYPOINT ["/bin/comment-monitor"]
16 changes: 11 additions & 5 deletions tools/commentMonitor/README.md → tools/comment-monitor/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# commentMonitor
# comment-monitor

A simple webhook server designed to parse GitHub comments and execute actions based on the comment content. Currently, it only supports the [`issue_comment` event](https://developer.github.com/v3/activity/events/types/#issuecommentevent) triggered by pull requests (PRs).
A GitHub webhook that watches GitHub Issue and Pull Request comments for `/prombench <event> [<version>] [<options>]` commands.

On each command it dispatches appropriate [`repository_dispatch` event](https://developer.github.com/v3/repos/#create-a-repository-dispatch-event) to configured repository and notifies the same issue/PR.

See [Prometheus GitHub action that responses to prombench comment-monitor dispatches](https://github.com/prometheus/prometheus/blob/main/.github/workflows/prombench.yml).

Currently, it only supports the [`issue_comment` event](https://developer.github.com/v3/activity/events/types/#issuecommentevent), which can be triggered by either issue or PR.

## Table of Contents

Expand All @@ -19,7 +25,7 @@ A simple webhook server designed to parse GitHub comments and execute actions ba

## Setting Up the Webhook Server

To specify the configuration file for `commentMonitor`, use the `--config` flag.
To specify the configuration file for `comment-monitor`, use the `--config` flag.

### Example `config.yml` File

Expand All @@ -40,7 +46,7 @@ eventmaps:
**How It Works:**
- Comments are first checked to see if they start with any of the prefixes specified in `prefixes`. If not, the request is dropped.
- If the prefix is matched, but the subsequent content does not match the `regex_string`, a comment with the `help_template` for that prefix is posted back to the issue/PR.
- If a comment matches the `regex_string`, `commentMonitor` will trigger a [`repository_dispatch` event](https://developer.github.com/v3/repos/#create-a-repository-dispatch-event) with the specified `event_type`.
- If a comment matches the `regex_string`, `comment-monitor` will trigger a [`repository_dispatch` event](https://developer.github.com/v3/repos/#create-a-repository-dispatch-event) with the specified `event_type`.
- A comment will also be posted to the issue/PR with the `comment_template`.
- Any arguments extracted by the `regex_string` will be passed to the [`client_payload`](https://developer.github.com/v3/repos/#example-5) of the `repository_dispatch` event.

Expand Down Expand Up @@ -84,7 +90,7 @@ Flags:

## Building Docker Image

To build the Docker image for `commentMonitor`:
To build the Docker image for `comment-monitor`:

```bash
docker build -t prominfra/comment-monitor:master .
Expand Down
Loading

0 comments on commit 4967bb5

Please sign in to comment.