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(probe): add size change detection using sysfs polling #2

Closed
wants to merge 7 commits into from

Conversation

z0marlin
Copy link
Owner

size change detection using sysfs size file polling.

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() {

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?

Copy link
Owner Author

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

Copy link
Owner Author

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

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) {

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

Copy link
Owner Author

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:

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?

Copy link
Owner Author

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:

  1. the err channel will be used to detect files that have been removed. this will allow us to remove them from further monitoring
  2. avoid logging in pkg.

Copy link

@akhilerm akhilerm left a 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.

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?

Comment on lines +193 to +194
events, errs := cp.watchman.Start()
defer cp.watchman.Stop()

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?

@z0marlin z0marlin closed this Sep 3, 2021
@z0marlin z0marlin deleted the sizech-poll branch October 12, 2021 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants