draios / draios/sysdig-cloud-scripts

install-agent-k8s.sh gives a very cryptic error when `sysdig_instance_name` has spaces in it

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

Nobody has claimed this yet.

Dominant language
Shell
Stars
83
Forks
105
Avg merge
3h 53m
Merged PRs (30d)
1

Description

By sheer coincidence my script declared SYSDIG_INSTANCE_NAME and it has spaces in it. For example - My Sysdig Instance. I never passed any value to sysdig_instance_name

But the script used it anyway :) https://github.com/draios/sysdig-cloud-scripts/blob/master/agent_deploy/IBMCloud-Kubernetes-Service/install-agent-k8s.sh#L422

https://github.com/draios/sysdig-cloud-scripts/blob/master/agent_deploy/IBMCloud-Kubernetes-Service/install-agent-k8s.sh#L284 choked with error as

sed: -e expression #1, char 45: unterminated s' command`

Since sysdig_instance_name is expected to be used as K8s labels, it can't have any spaces..

A valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?') 

We should use the regex to validate the value to avoid throwing error at later stages and make it clear in documentation

If we don't want to keep up with K8s changes, we should simply let user pass whatever he wishes to and get that correctly sed'ed, actual error about spaces etc will eventually be thrown by K8s API

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 agent_deploy/IBMCloud-Kubernetes-Service/install-agent-k8s.sh at the referenced lines 284 and 422. Reproduce the failure using a sysdig_instance_name containing spaces, then inspect how the value reaches sed and Kubernetes labels. Done means the script reports or handles invalid values clearly without the cryptic sed error, with the supported value rules documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, shell
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.