Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

applicationID and installationID validation errors are replace with a generic error in GitHub Runner Scaler #6159

Open
swgriffith opened this issue Sep 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@swgriffith
Copy link

Report

The scaled object for the Github runner scaler takes an 'installationID' and 'applicationId' parameter as input, which are both expected to be int. The method that parses those values checks that they are valid integers and will raise an error, however the calling method ignores the detailed error and raises a generic "applicationID, installationID and applicationKey must be given" error message, which is misleading. The values were given, but they were invalid.

Expected Behavior

The detailed parsing error message should be returned from the setupGitHubApp method so that the author has better information to debug their issue.

Actual Behavior

Passing a string to either applicationID or installationID will raise the following error in the operator logs.

"error parsing GitHub Runner metadata: applicationID, installationID and applicationKey must be given"

Steps to Reproduce the Problem

  1. Deploy keda to the cluster
  2. Follow the keda logs: kubectl logs -f -l app=keda-operator -n keda
  3. Create and deploy the following manifest
apiVersion: v1
kind: Namespace
metadata:
  name: github-runner
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: github-auth
  namespace: github-runner
data:
  appKey: REDACTED
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: github-trigger-auth
  namespace: github-runner
spec:
  secretTargetRef:
    - parameter: appKey
      name: github-auth
      key: appKey
---
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
  name: scaledjob-github-runner
  namespace: github-runner
spec:
  jobTargetRef:
    template:
      metadata:
        labels:
          app: scaledjob-github-runner
      spec:
        containers:
        - name: scaledjob-github-runner
          image: myoung34/github-runner:2.302.1-ubuntu-focal
          imagePullPolicy: Always
          env:
          - name: EPHEMERAL
            value: "true"
          - name: DISABLE_RUNNER_UPDATE
            value: "true"
          - name: REPO_URL
            value: "REDACTED"
          - name: RUNNER_SCOPE
            value: "repo"
          - name: LABELS
            value: "test-local-runner"
        restartPolicy: Never
  minReplicaCount: 0
  maxReplicaCount: 20
  pollingInterval: 30
  triggers:
  - type: github-runner
    metadata:
      owner: "REDACTED"
      repos: "github-aca-runner"
      labelsFromEnv: "LABELS"
      runnerScope: "repo"
      applicationID: "fail"
      installationID: "fail"
    authenticationRef:
      name: github-trigger-auth

Logs from KEDA operator

ERROR	Failed to ensure ScaledJob is correctly created	{"controller": "scaledjob", "controllerGroup": "keda.sh", "controllerKind": "ScaledJob", "ScaledJob": {"name":"scaledjob-github-runner","namespace":"github-runner"}, "namespace": "github-runner", "name": "scaledjob-github-runner", "reconcileID": "4c1c09f4-44cb-48eb-8881-6eb2fe8b2f54", "error": "error parsing GitHub Runner metadata: applicationID, installationID and applicationKey must be given"}

KEDA Version

2.15.1

Kubernetes Version

1.29

Platform

Microsoft Azure

Scaler Details

Github Runner Scaler

Anything else?

Code reference:

Parse method does a good job of validating the content and raising an informative error:

func getInt64ValueFromMetaOrEnv(key string, config *scalersconfig.ScalerConfig) (int64, error) {

setupGithubApp method swallows the detailed error and raises a generic error:

func setupGitHubApp(config *scalersconfig.ScalerConfig) (*int64, *int64, *string, error) {

@swgriffith swgriffith added the bug Something isn't working label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To Triage
Development

No branches or pull requests

1 participant