Skip to content

Storage backends: configuration format #855

Closed

Description

@jrosdahl

As mentioned in #414, it would be great if the configuration of storage backends is not just a large bag of CCACHE_... variables but had some more structure. It should be possible to:

  1. Configure a secondary storage backend in a simple way.
  2. Define an order in which backends are queried.
  3. Configure backend-specific settings such as credentials or modes.

Activity

  1. added
    issue: task
    on Jun 6, 2021
  2. changed the title [-]Storage backend: configuration format[/-] [+]Storage backends: configuration format[/+] on Jun 6, 2021
  3. jrosdahl commented on Jun 10, 2021

    @jrosdahl
    MemberAuthor

    Here's what I got so far:

    Variant 1

    Documentation sketch: 36f48b0

    Main ideas:

    • Add a configuration option called storage which specifies the list of storage backends to query in order. The standard backend has to be part of the list by using the keyword standard (or absent to not use it). Other storage backends are specified by URLs.
    • Storage backends can receive a list of key-value attributes with configuration.
    • It's possible to set a backend to read-only mode using an attribute. Setting the standard backend to read-only has the same effect as memcached_only in Memcached #58. Setting another backend to read-only has the same effect as read_only_memcached in Memcached #58.
    • To make the common use case of just adding a single backend nicer, add a level_2_storage configuration option as a shorthand for setting storage to standard plus another backend.

    Use case #676 looks like this:

    level_2_storage = http://example.com/cache/location
    # Or equivalently:
    storage = standard http://example.com/cache/location
    

    Use case #380 looks like this:

    storage = file:///example/cache/location|read-only standard
    

    Variant 2

    Documentation sketch: 6c80174

    Main ideas:

    • Add two configuration options level_0_storage and level_2_storage. These contains lists of backends to query before and after the standard one.
    • Just as in variant 1, storage backends can receive a list of key-value attributes with configuration.
    • Just as in variant 1, it's possible to set a backend (except the standard one) read-only mode using an attribute.
    • Add a read_only_local configuration option to make it possible to set the standard backend to read-only mode.

    In this variant multiple backends can be "level 0" or "level 2" which maybe is slightly strange but should be OK. (Especially since I guess it's unlikely that somebody wants to specify multiple backends in practice...)

    Use case #676 look like this:

    level_2_storage = http://example.com/cache/location
    

    Use case #380 looks like this:

    level_0_storage = file:///example/cache/location|read-only
    

    Random comments

    • I realize that this may appear slightly overengineered, but I felt that I wanted to try to make the configuration syntax extensible for future use cases.
    • We can start with just implementing support for level_2_storage with a single backend, so we don't have to decide on a variant now. That said, I'm leaning towards variant 2.
    • I didn't want to introduce special configuration files for backends since I see a value in being able to set environment variables instead of requiring configuration files.
    • Similarly, I didn't want to introduce some new generic configuration file syntax since it should be possible to continue using just environment variables with minimal syntactical noise (i.e., no JSON, etc.).
    • I'm not using the term "remote" since alternative file backends don't necessarily have to be on network storage and therefore are not "remote".
    • I chose | as the delimiter for attributes because it's an invalid character in URLs which makes it trivial to parse the configuration. And I think it looks kind of nice. I tried other variations with brackets and braces as well, but I didn't think it looked better at the end.
    • It could be that the use case of Add support for two level cache #380 is not worth the complexity of adding level_0_storage and that it would be OK with just level_2_storage = file:///example/cache/location|read-only.

    @afbjorklund (and others): What do you think about this plan? Comments are welcome.

  4. afbjorklund commented on Jun 12, 2021

    @afbjorklund
    Contributor

    Looks OK. I guess you decide the type of the storage backend by inventing some scheme for it, like redis://localhost:6379 ?

    Using the local storage as temporary files sounds like reasonable workarounds for both memcached_only and level_0_storage. I don't think doing a local copy of the file adds major overhead, compared to the transport from memcached or from nfs (or so) ? Previously we went to great lengths to write directly from memcached results in memory or from the remote file system path. Then again, since the options are here and this is only about configuration - the optimizations can be kept when doing the implementation.

    I think having a single "storage" configuration would be enough, and it seems like it would cover all the different scenarios too ?

    storage = standard

    storage = standard http://example.com/cache/location

  5. jrosdahl commented on Jun 12, 2021

    @jrosdahl
    MemberAuthor

    Looks OK. I guess you decide the type of the storage backend by inventing some scheme for it, like redis://localhost:6379 ?

    Yes, that's the idea.

    Then again, since the options are here and this is only about configuration - the optimizations can be kept when doing the implementation.

    Yep.

    For the record, the API I envisioned (but never got to describe in detail) in #414 had streaming versions of get/put operations. In fact the manifest and result implementations are already prepared (after a small refactoring to work on a new file I/O API instead of directly on FILE*) for consuming or producing streaming data with such a storage API in mind. In other words, they can then be driven by feeding/fetching chunks of data directly from/to a network storage backend without landing the data on disk.

    My plan now is to start with local files as bearer of data in the APIs (similar to #676's API) just to get something going, and then potentially refactor into streaming APIs later.

    I think having a single "storage" configuration would be enough, and it seems like it would cover all the different scenarios too ?

    Right, so your prefer variant 1 without the "level_2_storage" nice to have? Only having storage was what I had initially, but I just felt that for 99% of the cases a user just wants to add another level 2 backend and then having to write (or even know about) the standard keyword feels a bit unfortunate.

  6. jrosdahl commented on Jun 12, 2021

    @jrosdahl
    MemberAuthor

    I've started to look into implementing this and I now realize it's hard to describe the distinction between the standard backend (which has a much richer feature set and API) and other backends. Here's another variant:

    Variant 3

    Documentation sketch: ed1f662

    Main ideas:

    • Add a configuration option called secondary_storage which specifies the list of storage backends to query in order after the primary cache. This makes it possible to describe the difference between the primary and secondary storage APIs and implementations. A future optional replacement of the primary storage could then be primary_storage.
    • Just as in variant 1, storage backends can receive a list of key-value attributes with configuration.
    • Just as in variant 1, it's possible to set a backend (except the standard one) read-only mode using an attribute.
    • Add a read_only_primary configuration option to make it possible to set the primary backend to read-only mode.
    • Add an optional backend attribute for making ccache query that backend before the primary one, maybe prepend or similar.

    Use case #676 looks like this:

    secondary_storage = http://example.com/cache/location
    

    Use case #380 looks like this:

    secondary_storage = file:///example/cache/location|read-only|prepend
    

    Note the prepend attribute.

  7. jrosdahl commented on Jun 27, 2021

    @jrosdahl
    MemberAuthor

    I went with variant 3, see 2b3368c.

  8. added this to the 4.4 milestone on Jun 27, 2021
  9. self-assigned this
    on Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

issue: task

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions