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

Popeye fails with error while running with spinach.yaml file #308

Open
babuga365 opened this issue Apr 26, 2024 · 3 comments
Open

Popeye fails with error while running with spinach.yaml file #308

babuga365 opened this issue Apr 26, 2024 · 3 comments
Labels
question Further information is requested

Comments

@babuga365
Copy link




Describe the bug
Im using this task in azure devops to run a popeye against my AKS cluster.

- task: AzureCLI@2
  displayName: 'Run Popeye Audit Script'
  inputs:
    azureSubscription: ${{ parameters.AZURE_SERVICE_CONNECTION_NAME }}
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: |
      set -feuo pipefail
      set -x

      # Validate parameters
      : "${RESOURCE_GROUP:?Need to set RESOURCE_GROUP environment variable}"
      : "${CLUSTER_NAME:?Need to set CLUSTER_NAME environment variable}"
      : "${POPEYE_VERSION:?Need to set POPEYE_VERSION environment variable}"
      : "${KUBELOGIN_VERSION:?Need to set KUBELOGIN_VERSION environment variable}"

      SUBSCRIPTION_ID=${SUBSCRIPTION_ID:-""}
      
      # Getting KubeConfig
      az aks get-credentials -n "${CLUSTER_NAME}" -g "${RESOURCE_GROUP}" --overwrite-existing

      # Download Kubelogin
      curl -LO "https://github.com/Azure/kubelogin/releases/download/${KUBELOGIN_VERSION}/kubelogin-linux-amd64.zip"
      unzip kubelogin-linux-amd64.zip
      sudo mv bin/linux_amd64/kubelogin /usr/bin/kubelogin

      # Convert to non-interactive
      kubelogin convert-kubeconfig -l azurecli

      echo "Download POPEYE..."

      curl -LO "https://github.com/derailed/popeye/releases/download/${POPEYE_VERSION}/popeye_Linux_amd64.tar.gz"
      tar xzvpf "popeye_Linux_amd64.tar.gz" popeye
      mv popeye /tmp/popeye

      # Construct SPINACH path
      SPINACH="$(System.DefaultWorkingDirectory)/terraform/playgrounds/babu/popeye/spinach.yml"
      POPEYE=${POPEYE:-/tmp/popeye}

      # Create output directory for Popeye HTML report
      POPEYE_REPORT_DIR=$(System.DefaultWorkingDirectory)
      # Run Popeye and save the output to a file
      "$POPEYE" --save --out html --output-file report.html -A -f "$SPINACH"
      
  env:
    RESOURCE_GROUP: ${{ parameters.RESOURCE_GROUP }}
    CLUSTER_NAME: ${{ parameters.CLUSTER_NAME }}
    POPEYE_VERSION: ${{ parameters.POPEYE_VERSION }}
    KUBELOGIN_VERSION: ${{ parameters.KUBELOGIN_VERSION }}

Popeye is running fine and I got error: ##[error]Script failed with exit code: 1
in the pipeline without saving output as html file. I used below command to run popeye with spinach configuration
/tmp/popeye -A -f /home/vsts/work/1/s/terraform/playgrounds/babu/popeye/spinach.yml

If I try to save output file as HTML format and my pipeline is throwing error as below
/tmp/popeye --save --out html --output-file report.html -A -f /home/vsts/work/1/s/terraform/playgrounds/babu/popeye/spinach.yml

`+ echo 'Download POPEYE...'
Download POPEYE...

19 17.2M 19 3501k 0 0 3673k 0 0:00:04 --:--:-- 0:00:04 3673k
100 17.2M 100 17.2M 0 0 13.7M 0 0:00:01 0:00:01 --:--:-- 45.9M

  • tar xzvpf popeye_Linux_amd64.tar.gz popeye
    popeye
  • mv popeye /tmp/popeye
  • SPINACH=/home/vsts/work/1/s/terraform/playgrounds/babu/popeye/spinach.yml
  • POPEYE=/tmp/popeye
  • POPEYE_REPORT_DIR=/home/vsts/work/1/s
  • /tmp/popeye --save --out html --output-file report.html -A -f /home/vsts/work/1/s/terraform/playgrounds/babu/popeye/spinach.yml
    ___ ___ _____ _____ D .-'-.
    | _ _| _ \ \ \ / / | O | K \ | _/ _ \ _/ _| \ V /| _| H -,---._
    |_| _/| || || || [] .->' X |-' Biffsem and Buffsem! =/ (
    /_ /
    _, _) ----; |

Boom! 💥 open /tmp/popeye/BABUZ-AKSCluster00/BABUZ-AKSCluster00/report.html: not a directory
(see logs)

##[error]Script failed with exit code: 1`

Expected behavior
Popeye should run without any error and It should generate HTML file correctly,

Versions (please complete the following information):

  • OS: [Azure DevOps Linux Agent]
  • Popeye [0.21.3]
  • K8s [1.27.7]

Additional context
I'm using this spinach.yaml configuration: https://github.com/derailed/popeye/blob/master/spinach-examples/spinach_aks.yml for my test

@derailed
Copy link
Owner

@babuga365 Could you include the popeye's logs?

@derailed derailed added the question Further information is requested label Apr 27, 2024
@babuga365
Copy link
Author

babuga365 commented Apr 29, 2024

Hi @derailed , I have added two log files for your reference.
popeye_logs1.txt
poeye_logs.txt

Did you had a chance to check these logs? please help me as soon as possible

@babuga365
Copy link
Author

babuga365 commented May 10, 2024

@derailed, please help me on this issue to fix it or do I have any workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants