-
Notifications
You must be signed in to change notification settings - Fork 0
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(probe): add size change detection using sysfs polling #2
Conversation
Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
w.eventChan = make(chan Event) | ||
w.errChan = make(chan error) | ||
w.stopChan = make(chan struct{}) | ||
go func() { |
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 many new go routines are we launching?
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.
one per instance of watchman. Since only sysfs probe is going to use it, we will be launching one go routine
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.
there will be one more go routine in sysfs probe that will be listening for these events. so 2 in total
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.
ok
return ret | ||
} | ||
|
||
func MD5Checksum(f *os.File) (FileData, error) { |
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.
Are we having the separation between files that need to be checksumed and just comparing the contents
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.
Yes. The File struct has a reader field which is used to read the file and return the data which can be anything - the file content, the checksum, or anything else. This field can be configured by passing an option to the NewFile
function.
select { | ||
case event := <-events: | ||
fmt.Println(event) | ||
case err := <-errs: |
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.
Was this introduced so that we get errors though channel instead of logging. Or is there some other purpose for this?
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.
two reasons for having a separate err channel:
- the err channel will be used to detect files that have been removed. this will allow us to remove them from further monitoring
- avoid logging in pkg.
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.
given a few comments
Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
Signed-off-by: Aditya Jain <aditya.jainadityajain.jain@gmail.com>
@@ -163,4 +170,50 @@ func (cp *sysfsProbe) FillBlockDeviceDetails(blockDevice *blockdevice.BlockDevic | |||
klog.V(4).Infof("blockdevice path: %s drive type :%s filled by sysfs probe.", | |||
blockDevice.DevPath, blockDevice.DeviceAttributes.DriveType) | |||
} | |||
|
|||
// check if the device is being monitored by for size changes. |
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.
WHy should this be done in the FIllDevice() method?
events, errs := cp.watchman.Start() | ||
defer cp.watchman.Stop() |
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.
Is this required to be in the go routine?
size change detection using sysfs size file polling.