marmelab / marmelab/greenframe-cli

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

Open
#63 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
284
Forks
12
PR merge metrics
No merged PRs in 30d

Description

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.
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the getHostIP.sh script named in the failure and inspect its use of grep -oP. Reproduce the command in the reported Alpine Linux/BusyBox environment, then verify that the script completes without the unsupported option and that the analysis path still retrieves the host IP.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, kubernetes, linux, shell
Domain
cli, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.