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

NVSHAS-7554 - Added a catch to block identical filter paths from bein… #934

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jaimeyu-suse
Copy link
Contributor

…g stored through the REST API.

The REST api will make sure the directory path for filters do not have any collisions. The bug we hit was that if a customer was allowed to add both /tmp/ and /tmp but only one filter would be used. This caused confusion in the expected behaviour.
If the filter has a trailing /, it is meant to be a filter for directories. If it is ommited, it is meant to be a filter for filepaths. When the two are used in conjection, it is confusing because we can only store one filter and the behaviour may not be what the user expects.

Added comments to parseFileFilter so its clear what are the behaviours if you add a trailing /.
I cleaned up getCoreFile() because it had duplicated code.

…g stored through the REST API.

The REST api will make sure the directory path for filters do not have any
collisions. The bug we hit was that if a customer was allowed to add
both `/tmp/` and `/tmp` but only one filter would be used. This caused
confusion in the expected behaviour.
If the filter has a trailing /, it is meant to be a filter for
directories. If it is ommited, it is meant to be a filter for filepaths.
When the two are used in conjection, it is confusing because we can only
store one filter and the behaviour may not be what the user expects.

Added comments to parseFileFilter so its clear what are the behaviours
if you add a trailing /.
I cleaned up getCoreFile() because it had duplicated code.
@jaimeyu-suse jaimeyu-suse reopened this Jul 31, 2023
@jaimeyu-suse jaimeyu-suse marked this pull request as ready for review July 31, 2023 18:02
@@ -227,7 +238,7 @@ func handlerFileMonitorConfig(w http.ResponseWriter, r *http.Request, ps httprou
}

for i, cfilter := range profConf.Filters {
if cfilter.Filter == filter.Filter {
if (cfilter.Filter == filter.Filter) || (cfilter.Path == base) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that Filter is not the path, this is the pseudo regex expression. eg: /tmp/.*

While the additional check if Path is the same as base will throw an error if the path is the same. The reason is that the monitoring logic can only store one filter per directory.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some test cases and make sure this logic does help.

@@ -575,8 +575,7 @@ func (w *FileWatch) getCoreFile(cid string, pid int, profile *share.CLUSFileMoni
dirList := make(map[string]*osutil.FileInfoExt)
singleFiles := make([]*osutil.FileInfoExt, 0)

// get files and dirs from all filters
for _, filter := range profile.Filters {
addFilterFn := func(filter share.CLUSFileMonitorFilter){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is cosmetic to reduce the copy paste code. No changes in the logic was done and will make it easier to make changes in the future.

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.

2 participants