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

fix: ensure data_volume isn't surrounded by quotes #21473

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Aletor93
Copy link

@Aletor93 Aletor93 commented Jan 31, 2025

Comprehensive Summary of your change

I'm generating harbor.yaml file with erb function to_yaml, where strings containing / are quoted. It can't be configured.

When I run ./install.sh script, it fails on docker volume command due to quotes which aren't removed:

prepare base dir is set to /srv/harbor/install
docker: Error response from daemon: create "/srv/harbor/data": "\"/srv/harbor/data\"" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.

After editing the prepare script to remove quotes on data_volume if present, it works like a charm. The sed is already used in other scripts, it shouldn't be a problem to use it.

Issue being fixed

n/a (no issue opened)

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

Signed-off-by: Alexandre Vallarino <alexandre.vallarino@gandi.net>
@Aletor93 Aletor93 force-pushed the aletor93/fix-data-volume-path-remove-quotes branch from 9e75874 to 22bb9a5 Compare January 31, 2025 09:17
@Vad1mo Vad1mo added the release-note/infra Infra related changes e.g. release, test, ship etc... label Feb 5, 2025
@@ -30,7 +30,7 @@ else
fi
fi

data_path=$(grep '^[^#]*data_volume:' $input_dir/harbor.yml | awk '{print $NF}')
data_path=$(grep '^[^#]*data_volume:' $input_dir/harbor.yml | awk '{print $NF}' | sed 's/"//g')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to remove the quote when there is a quote, sometimes the path may contain space, to remove quote will cause problem?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to remove the quote when there is a quote, sometimes the path may contain space, to remove quote will cause problem?

In my opinion, its already impossible to use a path with spaces due to: | awk '{print $NF}'.

Here is a test:

# grep data_volume harbor.yml
data_volume: "/srv/harbor/data directory with space"

# grep '^[^#]*data_volume:' harbor.yml | awk '{print $NF}'
space"

There is no change to expect about this.

@OrlinVasilev
Copy link
Member

@Aletor93 what shell are you using ?

@Aletor93
Copy link
Author

@Aletor93 what shell are you using ?

For the test made here, I've used bash. It seems to be the shell used inside prepare script.

For a better test case, I've commented my modification on prepare script and added an echo to debug.

data_path=$(grep '^[^#]*data_volume:' $input_dir/harbor.yml | awk '{print $NF}') # | sed 's/"//g')
echo ${data_path}-

Then tested to set data_volume with a path containing spaces: data_volume: "/srv/harbor/data directory with space"

# ./install.sh 
...
[Step 3]: preparing harbor configs ...
prepare base dir is set to /srv/harbor/install
space"-
docker: Error response from daemon: create space": "space\"" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.

I observe that awk get the last part of the string ($NF), using space as its default separator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/infra Infra related changes e.g. release, test, ship etc...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants