Skip to content

Mount filtering handles job prefix names#174

Merged
aramprice merged 2 commits intomasterfrom
mount-filtering-handles-job-prefix-names
Jul 9, 2024
Merged

Mount filtering handles job prefix names#174
aramprice merged 2 commits intomasterfrom
mount-filtering-handles-job-prefix-names

Conversation

@aramprice
Copy link
Copy Markdown
Member

@aramprice aramprice commented Jul 8, 2024

Check to see whether the "directory parts" of the volume are a sub-set
of and existing BPM-default directory (that will already be mounted) so
that we do not accidentally filter out mounts which have a name that is
a sub-string of the existing job. For example the job service-metrics
should be able to have an unrestricted volume mount of the
service-metrics-adapter job directory.

Specifically a job located at /var/vcap/jobs/service-metrics was
unable to access an "unrestricted volume" located at
/var/vcap/jobs/service-metrics-adapter because the job being
instantiated alreay had default mount which was a (string) prefix of the
job directory it was attempting to mount.

Signed-off-by: Nader Ziada <nader.ziada@broadcom.com>
@MirahImage
Copy link
Copy Markdown
Contributor

The RabbitMQ tile team have tested this branch in a tile build and it solves the problem for us. Thanks!

@aramprice aramprice requested a review from selzoc July 9, 2024 18:58
Copy link
Copy Markdown
Member

@selzoc selzoc left a comment

Choose a reason for hiding this comment

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

I think that this should work, but I'm unsure if the "subset" approach is more valuable than just changing the HasPrefix to be (v.Path, filepath.Join(m.Destination, os.PathSeparator))

// directory (that will already be mounted) so that we do not accidentally filter out mounts which
// have a name that is a sub-string of the existing job. For example the job `service-metrics` should be
// able to have an unrestricted volume mount of the `service-metrics-adapter` job directory.
boshMountDirParts := strings.Split(m.Destination, "/")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be nicer to use filepath, which has knowledge of the separator used so you don't have to hardcode it to /.

Copy link
Copy Markdown
Member Author

@aramprice aramprice Jul 9, 2024

Choose a reason for hiding this comment

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

updated, to use filepath.SplitList filepath.Separator

agree that the subset approach is more code. if feels somehow more "complete" or robust.

Check to see whether the "directory parts" of the volume are a sub-set
of and existing BPM-default directory (that will already be mounted) so
that we do not accidentally filter out mounts which have a name that is
a sub-string of the existing job. For example the job `service-metrics`
should be able to have an unrestricted volume mount of the
`service-metrics-adapter` job directory.

Specifically a job located at `/var/vcap/jobs/service-metrics` was
unable to access an "unrestricted volume" located at
`/var/vcap/jobs/service-metrics-adapter` because the job being
instantiated alreay had default mount which was a (string) prefix of the
job directory it was attempting to mount.

Signed-off-by: Rajath Agasthya <rajath.agasthya@broadcom.com>
Signed-off-by: aram price <aram.price@broadcom.com>
@aramprice aramprice force-pushed the mount-filtering-handles-job-prefix-names branch from d44bb34 to 6a2f85d Compare July 9, 2024 20:59
@aramprice aramprice merged commit 1e53ee5 into master Jul 9, 2024
@aramprice aramprice deleted the mount-filtering-handles-job-prefix-names branch July 9, 2024 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants