marmelab / greenframe-cli

Estimate the carbon footprint of a user scenario on a web application
https://greenframe.io
Other
235 stars 12 forks source link

`grep -oP` not working on Alpine Linux / BusyBox #63

Open tchapuis opened 1 year ago

tchapuis commented 1 year ago

Hi all !

I'm trying to run an analysis with Greenframe CLI in a Gitlab CI. It's a fullstack analysis on a Kubernetes cluster. I built a custom Docker image to run it, from Node 16 Alpine, with docker and kubectl installed.

But this analysis failed when try to run the getHostIP.sh script. Grep version is not the same in Alpine Linux and doesn't have the -P option.

Here is the complete output :

$ greenframe --version
greenframe-cli/1.6.8 linux-x64 node-v16.20.2
$ greenframe kube-config
[STARTED] Check configuration file
[SUCCESS] Check configuration file
[STARTED] Intializing kubernetes client
[SUCCESS] Intializing kubernetes client
[STARTED] Creating greenframe namespace
[TITLE] Greenframe namespace already exists
[SUCCESS] Greenframe namespace already exists
[STARTED] Creating greenframe daemonset
[TITLE] Greenframe daemonset already exists
[SUCCESS] Greenframe daemonset already exists
Kubernetes configuration complete !
$ greenframe analyze
[STARTED] Check configuration file
[SUCCESS] Check configuration file
[STARTED] Retrieving Git information
[SUCCESS] Retrieving Git information
[STARTED] Analysis is in progress locally
[STARTED] Detect docker version
[TITLE] Docker version 24.0.6, build ed223bc
[SUCCESS] Docker version 24.0.6, build ed223bc
[STARTED] Initialize Kubernetes client
[SUCCESS] Initialize Kubernetes client
[STARTED] Detect kubernetes version
[TITLE] Kubernetes version 1.24, build v1.24.14-gke.2700, platform linux/amd64
[SUCCESS] Kubernetes version 1.24, build v1.24.14-gke.2700, platform linux/amd64
[STARTED] Running 1 scenario(s)...
[SUCCESS] Running 1 scenario(s)...
[SUCCESS] Analysis is in progress locally
Analysis complete !
Result summary:
❌ main scenario failed
This scenario fail during the execution:
Command failed: /root/.local/lib/greenframe/dist/bash/getHostIP.sh
grep: unrecognized option: P
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.
Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
Search for PATTERN in FILEs (or stdin)
    -H  Add 'filename:' prefix
    -h  Do not add 'filename:' prefix
    -n  Add 'line_no:' prefix
    -l  Show only names of files that match
    -L  Show only names of files that don't match
    -c  Show only count of matching lines
    -o  Show only the matching part of line
    -q  Quiet. Return 0 if PATTERN is found, 1 otherwise
    -v  Select non-matching lines
    -s  Suppress open and read errors
    -r  Recurse
    -R  Recurse and dereference symlinks
    -i  Ignore case
    -w  Match whole words only
    -x  Match whole lines only
    -F  PATTERN is a literal (not regexp)
    -E  PATTERN is an extended regexp
    -m N    Match up to N times per file
    -A N    Print N lines of trailing context
    -B N    Print N lines of leading context
    -C N    Same as '-A N -B N'
    -e PTRN Pattern to match
    -f FILE Read pattern from file
ash: usage: printf FORMAT [ARGUMENT...]
Use greenframe open command to run your scenario in debug mode.