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

feat: Do not change permissions on existing data directory #48

Conversation

Gu1nness
Copy link
Contributor

snap/hooks/install Outdated Show resolved Hide resolved
snap/hooks/install Outdated Show resolved Hide resolved
snap/hooks/install Outdated Show resolved Hide resolved
snap/hooks/install Show resolved Hide resolved
Copy link
Contributor

@Mehdi-Bendriss Mehdi-Bendriss left a 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

mkdir -p $CONF

# If we just created the directory, we set up permissions
if [ stat -c '%u' "$DATA" == 0 -o ! -d "$DATA" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. how can ! -d "$DATA" ever evaluate to True given $DATA was potentially created right before?
  2. 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

Copy link
Contributor Author

@Gu1nness Gu1nness Aug 28, 2024

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}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be recursive?

Copy link
Contributor Author

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.

fi

# If we just created the directory, we set up permissions
if [ stat -c '%u' "$LOGS" == 0 -o ! -d "$LOGS" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same answer as above :)

@Gu1nness Gu1nness added this pull request to the merge queue Aug 28, 2024
Merged via the queue into 6/edge with commit ee5a8cf Aug 28, 2024
3 checks passed
@Gu1nness Gu1nness deleted the DPE-5227-mongo-db-vm-re-enable-storage-reuse-tests-unit-volume-from-same-cluster branch August 28, 2024 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants