From 85aba207b102b4b766f16388faff4e85b4b5bcaa Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Thu, 30 May 2024 17:00:54 +1000 Subject: [PATCH] fix: update status to check for 2xx and any other 200 http code with regex --- PROJECT | 2 +- build-push.sh | 2 +- controllers/idling_controller.go | 4 +- go.mod | 2 +- handlers/idler/service-kubernetes.go | 2 +- helm-update.sh | 61 ---------------------------- main.go | 10 ++--- 7 files changed, 11 insertions(+), 72 deletions(-) delete mode 100755 helm-update.sh diff --git a/PROJECT b/PROJECT index 378056e..516f048 100644 --- a/PROJECT +++ b/PROJECT @@ -1,3 +1,3 @@ domain: amazee.io -repo: github.com/amazeeio/aergia-controller +repo: github.com/uselagoon/aergia-controller version: "2" diff --git a/build-push.sh b/build-push.sh index 0c0f77c..a129334 100755 --- a/build-push.sh +++ b/build-push.sh @@ -1,5 +1,5 @@ #!/bin/bash -REPO=${2:-amazeeio} +REPO=${2:-uselagoon} TAG=${1:-latest} IMGNAME=${3:-aergia} echo "Creating image for $REPO/${IMGNAME}:$TAG and pushing to docker hub" diff --git a/controllers/idling_controller.go b/controllers/idling_controller.go index ebc4f4c..ca2f682 100644 --- a/controllers/idling_controller.go +++ b/controllers/idling_controller.go @@ -20,9 +20,9 @@ import ( "encoding/json" "fmt" - "github.com/amazeeio/aergia-controller/handlers/idler" - "github.com/amazeeio/aergia-controller/handlers/unidler" "github.com/go-logr/logr" + "github.com/uselagoon/aergia-controller/handlers/idler" + "github.com/uselagoon/aergia-controller/handlers/unidler" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" diff --git a/go.mod b/go.mod index 5c4826c..222d482 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/amazeeio/aergia-controller +module github.com/uselagoon/aergia-controller go 1.21 diff --git a/handlers/idler/service-kubernetes.go b/handlers/idler/service-kubernetes.go index dec18f0..a2a85b7 100644 --- a/handlers/idler/service-kubernetes.go +++ b/handlers/idler/service-kubernetes.go @@ -126,7 +126,7 @@ func (h *Idler) KubernetesServiceIdler(ctx context.Context, opLog logr.Logger, n defer cancel() // get the number of requests to any ingress in the exported namespace by status code promQuery := fmt.Sprintf( - `round(sum(increase(nginx_ingress_controller_requests{exported_namespace="%s",status="200"}[%s])) by (status))`, + `round(sum(increase(nginx_ingress_controller_requests{exported_namespace="%s",status=~"2[0-9x]{2}"}[%s])) by (status))`, namespace.ObjectMeta.Name, prometheusInternalCheck, ) diff --git a/helm-update.sh b/helm-update.sh deleted file mode 100755 index 11a269c..0000000 --- a/helm-update.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# ./helm-update.sh index -# create new index for the chart - -# ./helm-update.sh template -# process the chart to a template - -# ./helm-update.sh delete -# delete the chart from kubernetes - -# ./helm-update.sh install -# install the chart into kubernetes - -# ./helm-update.sh install-tgz -# install the chart from one of the tgz files present locally into kubernetes - -case $1 in - index) - pushd charts - helm package aergia - helm repo index . - popd - ;; - template) - helm template charts/aergia -f charts/aergia/values.yaml - ;; - delete) - helm delete -n aergia aergia - ;; - install) - helm repo add aergia https://raw.githubusercontent.com/amazeeio/unidler/main/charts - helm upgrade --install -n aergia aergia aergia/aergia - ;; - install-tgz) - options=($(ls charts | grep tgz)) - if [ ${#options[@]} -ne 0 ]; then - select chart in "${options[@]}"; - do - case $chart in - "$QUIT") - echo "Unknown option, exiting." - break - ;; - *) - break - ;; - esac - done - if [ "$chart" != "" ]; then - helm upgrade --install --create-namespace -n aergia aergia charts/$chart - fi - else - echo "No chart files, exiting." - fi - ;; - *) - echo "nothing" - ;; -esac - diff --git a/main.go b/main.go index 7888641..a7ffa25 100644 --- a/main.go +++ b/main.go @@ -22,13 +22,13 @@ import ( "os" "time" - "github.com/amazeeio/aergia-controller/controllers" - "github.com/amazeeio/aergia-controller/handlers/idler" - "github.com/amazeeio/aergia-controller/handlers/metrics" - "github.com/amazeeio/aergia-controller/handlers/unidler" - u "github.com/amazeeio/aergia-controller/handlers/unidler" prometheusapi "github.com/prometheus/client_golang/api" "github.com/prometheus/client_golang/prometheus" + "github.com/uselagoon/aergia-controller/controllers" + "github.com/uselagoon/aergia-controller/handlers/idler" + "github.com/uselagoon/aergia-controller/handlers/metrics" + "github.com/uselagoon/aergia-controller/handlers/unidler" + u "github.com/uselagoon/aergia-controller/handlers/unidler" variables "github.com/uselagoon/machinery/utils/variables" "gopkg.in/robfig/cron.v2" "gopkg.in/yaml.v2"