Skip to content

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

@ashishth09

Description

@ashishth09

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions