Skip to content

[WIP] storage/local notify - #78

Closed
butonic wants to merge 6 commits into
cs3org:masterfrom
owncloud:feature/local-notify
Closed

butonic wants to merge 6 commits into
cs3org:masterfrom
owncloud:feature/local-notify

Conversation

@butonic

@butonic butonic commented May 8, 2019

Copy link
Copy Markdown
Contributor

This is a PoC to make the local storage provider

  • listen for file changes
  • propagate change via mtime updates up to the root (actually up to the subfolder of the root)

Listening for file changes is disabled by default and can be enabled by setting witch = true, eg:

[grpc.services.storageprovidersvc.drivers.local]
root = "/data"
watch = true

Several things I noticed:

  • we should have a way to Close() services, @labkode already implemented the basics, I just added some code to Close storages if they implement the io.Closer interface
  • in New() I see currently no way to get a proper logger. We could either
    • pass the logger in the New function, or
    • pass in a context that has the logger set.
      I prefer the latter.
  • the current propagation implementation could live just fine as a standalone service. I also noticed that an embedded kv store might make sense as a dedicated service. I assume when I start integrating a kv store based filecache with file notifications I will need them in the storage implementation. So maybe not making them standalone services is the right thing to do. The current notification and propagation would work as a bash script just fine ... for the cache I need an entry point to make it update metadata when something changes. Will look into that with s3 tomorrow.
  • sharing, if implemented via acls uses the xattr system namespace. I was wondering if we could store our own arbitrary attributes that the user cannot change himself (eg for system tags) It seems not only the namespace, but also the names you can assign a value are hardcoded. At least with setfattr I could not set a system.mykey as root ... that at least will prevent us from storing system tags in the filesystem. However, anything the user can change could be stored as xattr: user tags, maybe share expiry (might require some clever naming to link it to the share).

return err
}
svcs[svc.Prefix()] = prometheus.InstrumentHandler(svc.Prefix(), svc.Handler())
s.handlers[svc.Prefix()] = prometheus.InstrumentHandler(svc.Prefix(), svc.Handler())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SA1019: prometheus.InstrumentHandler is deprecated: InstrumentHandler has several issues. Use the tooling provided in package promhttp instead. The issues are the following: (1) It uses Summaries rather than Histograms. Summaries are not useful if aggregation across multiple instances is required. (2) It uses microseconds as unit, which is deprecated and should be replaced by seconds. (3) The size of the request is calculated in a separate goroutine. Since this calculator requires access to the request header, it creates a race with any writes to the header performed during request handling. httputil.ReverseProxy is a prominent example for a handler performing such writes. (4) It has additional issues with HTTP/2, cf. prometheus/client_golang#272. (from staticcheck)

@labkode

labkode commented May 9, 2019

Copy link
Copy Markdown
Member

in New() I see currently no way to get a proper logger. We could either

* pass the logger in the New function, or

* pass in a context that has the logger set.
  I prefer the latter.

We are passing the logger on New for clear dependency injection in other modules, let's be consistent. If the dependencies start going big we may consider passing the opaque context.

@labkode labkode changed the title Feature/local notify WIP: storage/local notify May 10, 2019
@labkode labkode added the feature New feature label Aug 14, 2019
@labkode labkode changed the title WIP: storage/local notify [WIP] storage/local notify Jan 10, 2020
@butonic

butonic commented Apr 1, 2020

Copy link
Copy Markdown
Contributor Author
  1. inotify is not the proper mechanism to watch for file changes because it requires 48 bytes of memory per file. This does not scale to millions of files. Furthermore, it does not guarantee that you will be notified for all changes.
  2. the kernel has an audit mechanism which has a proper queue that can be used to audit changes to a file tree
  3. a proper solution should use a file system to cover not only etag propagation and tree size accounting, but also versions and trash bin

@butonic butonic closed this Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants