-
Notifications
You must be signed in to change notification settings - Fork 206
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
base: main
Are you sure you want to change the base?
Conversation
…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.
@@ -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) { |
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.
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.
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.
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){ |
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.
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.
…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.