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

Ignore chown errors #47

Merged
merged 5 commits into from
Nov 3, 2020
Merged

Conversation

Kidswiss
Copy link
Contributor

@Kidswiss Kidswiss commented Nov 1, 2020

If any files are mounted from k8s secrets the chown commands will fail
due to the fact that these files will only be read-only.

This commit ignores any errors during the chown commands.

If any files are mounted from k8s secrets the chown commands will fail
due to the fact that these files will only be read-only.

This commit ignores any errors during the chown commands.
@cdalvaro cdalvaro added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels Nov 1, 2020
@cdalvaro cdalvaro self-requested a review November 1, 2020 20:32
@cdalvaro cdalvaro self-assigned this Nov 2, 2020
assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Show resolved Hide resolved
assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Show resolved Hide resolved
assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Show resolved Hide resolved
@Kidswiss
Copy link
Contributor Author

Kidswiss commented Nov 3, 2020

Hi @cdalvaro

Thanks for reviewing this. I'll check your suggestions against my setup and see what happens.

@cdalvaro
Copy link
Owner

cdalvaro commented Nov 3, 2020

Hi @Kidswiss, thank you very much for your changes!

Does they work right for your setup? If the image is working properly for you with these changes I'll merge this PR asap.

@Kidswiss
Copy link
Contributor Author

Kidswiss commented Nov 3, 2020

It's running into a chown issue somewhere again:

'/srv' -> '/home/salt/data/srv'
chown: changing ownership of '/home/salt/data/config/vault.conf': Read-only file system
chown: changing ownership of '/home/salt/data/config/api.conf': Read-only file system```

Co-authored-by: Carlos D. Álvaro <[email protected]>
@Kidswiss Kidswiss force-pushed the fix/ignore_chown_errors branch from b8b4987 to ac29208 Compare November 3, 2020 09:27
@cdalvaro
Copy link
Owner

cdalvaro commented Nov 3, 2020

So the issue must be here now:

# Salt configuration directory
if [[ -w "${SALT_CONFS_DIR}" ]]; then
  chown -R "${SALT_USER}": "${SALT_CONFS_DIR}"
else
  echo "${SALT_CONFS_DIR} is mounted as a read-only volume. Ownership won't be changed."
fi

I don't know why [ -w "${SALT_CONFS_DIR}" ] is not detecting ${SALT_CONFS_DIR} as a read-only volume...

Anyway, making this change should fix your issue:

- chown -R "${SALT_USER}": "${SALT_CONFS_DIR}"
+ chown -R "${SALT_USER}": "${SALT_CONFS_DIR}" || log_error "Unable to change '${SALT_CONFS_DIR}' ownership"

We can add this change to SALT_BASE_DIR and SALT_FORMULAS_DIR too.

@Kidswiss
Copy link
Contributor Author

Kidswiss commented Nov 3, 2020

It starts through now:

Configuring directories ...
'/srv' -> '/home/salt/data/srv'
chown: changing ownership of '/home/salt/data/config/vault.conf': Read-only file system
chown: changing ownership of '/home/salt/data/config/api.conf': Read-only file system
ERROR: Unable to change '/home/salt/data/config' ownership
'/var/log/salt' -> '/home/salt/data/logs/salt'
Configuring logrotate ...
Configuring container timezone ...
Setting TimeZone -> UTC ...
Configuring salt-master service ...
Creating 'salt_api' user for salt-api ...
Configuring salt-api service ...
local:
    Created Private Key: "/etc/pki/tls/certs/docker-salt-master.key." Created Certificate:
"/etc/pki/tls/certs/docker-salt-master.crt."
Configuring 3rd-party salt-formulas ...
Setting up salt keys ...
Configuring ssh ...
Starting supervisord ...

Thanks!

@Kidswiss
Copy link
Contributor Author

Kidswiss commented Nov 3, 2020

I assume this snipped doesn't work as it checks the if the folder is read-only and not the files within:
if [[ -w "${SALT_CONFS_DIR}" ]]; then

My case is that single files within the folder are mounted as read-only k8s secrets.

assets/runtime/functions.sh Outdated Show resolved Hide resolved
assets/runtime/functions.sh Outdated Show resolved Hide resolved
Kidswiss and others added 2 commits November 3, 2020 10:52
Co-authored-by: Carlos D. Álvaro <[email protected]>
Co-authored-by: Carlos D. Álvaro <[email protected]>
@cdalvaro cdalvaro merged commit 0bfd361 into cdalvaro:master Nov 3, 2020
@cdalvaro
Copy link
Owner

cdalvaro commented Nov 3, 2020

@Kidswiss - Thank you very much for your contribution!

@Kidswiss
Copy link
Contributor Author

Kidswiss commented Nov 3, 2020

Thank you very much for providing this image!

I just recently found that the official salt images have been archived...

@cdalvaro
Copy link
Owner

cdalvaro commented Nov 3, 2020

I'm very glad that this image is useful for you!

I really appreciate new feature or improvements suggestions for this image!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants