-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Do not change permissions on existing data directory #48
feat: Do not change permissions on existing data directory #48
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Neha! I have a couple of questions
snap/hooks/install
Outdated
mkdir -p $CONF | ||
|
||
# If we just created the directory, we set up permissions | ||
if [ stat -c '%u' "$DATA" == 0 -o ! -d "$DATA" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- how can
! -d "$DATA"
ever evaluate toTrue
given$DATA
was potentially created right before? - we could perhaps defer the creation of
$DATA
and simplify the condition with:
if [ ! -d "${f}" ]; then
mkdir -p "${DATA}"
chmod -R 770 "${SNAP_COMMON}"
chmod 750 "${DATA}"
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed I don't think -d "$DATA"
can be false here indeed.
The important check here is stat -c '%u' "$DATA" == 0
to check the owner.
If root
is the owner, we should update the permissions, otherwise it means we are installing on existing data and we should not change this.
# If we just created the directory, we set up permissions | ||
if [ stat -c '%u' "$DATA" == 0 -o ! -d "$DATA" ]; then | ||
chmod -R 770 "${SNAP_COMMON}" | ||
chmod 750 "${DATA}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be recursive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, as there will be no data in here in case we just created the directory, and we enter this block only if that's the case.
For a bit more exaplanation, there will be a complementary code on the charm side when attaching a storage to grant the right permissions to the attached storage, like they did in kafka operator.
snap/hooks/install
Outdated
fi | ||
|
||
# If we just created the directory, we set up permissions | ||
if [ stat -c '%u' "$LOGS" == 0 -o ! -d "$LOGS" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer as above :)
$DATA
directory already existing, the former version would break when trying to change the permissions of$DATA
.