Improve debug log in webhook-based autoscaling

Adds some helpful debug log messages I have used while verifying #534
This commit is contained in:
Yusuke Kuoka 2021-05-11 06:40:53 +00:00
parent 0510f19607
commit 25f5817a5e
1 changed files with 15 additions and 5 deletions

View File

@ -20,13 +20,14 @@ import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"net/http" "net/http"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"strings" "strings"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"github.com/go-logr/logr" "github.com/go-logr/logr"
gogithub "github.com/google/go-github/v33/github" gogithub "github.com/google/go-github/v33/github"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -330,6 +331,8 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) getScaleTarget(ctx co
return nil, err return nil, err
} }
autoscaler.Log.V(1).Info(fmt.Sprintf("Found %d HRAs by key", len(hras)), "key", name)
targets := autoscaler.searchScaleTargets(hras, f) targets := autoscaler.searchScaleTargets(hras, f)
n := len(targets) n := len(targets)
@ -362,14 +365,16 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) getScaleUpTarget(ctx
repositoryRunnerKey := owner + "/" + repo repositoryRunnerKey := owner + "/" + repo
if target, err := autoscaler.getScaleTarget(ctx, repositoryRunnerKey, f); err != nil { if target, err := autoscaler.getScaleTarget(ctx, repositoryRunnerKey, f); err != nil {
autoscaler.Log.Info("finding repository-wide runner", "repository", repositoryRunnerKey) log.Info("finding repository-wide runner", "repository", repositoryRunnerKey)
return nil, err return nil, err
} else if target != nil { } else if target != nil {
autoscaler.Log.Info("scale up target is repository-wide runners", "repository", repo) log.Info("scale up target is repository-wide runners", "repository", repo)
return target, nil return target, nil
} }
if ownerType == "User" { if ownerType == "User" {
log.V(1).Info("no repository runner found", "organization", owner)
return nil, nil return nil, nil
} }
@ -379,6 +384,11 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) getScaleUpTarget(ctx
} else if target != nil { } else if target != nil {
log.Info("scale up target is organizational runners", "organization", owner) log.Info("scale up target is organizational runners", "organization", owner)
return target, nil return target, nil
} else {
log.V(1).Info("no repository runner or organizational runner found",
"repository", repositoryRunnerKey,
"organization", owner,
)
} }
return nil, nil return nil, nil