28 Commits

Author SHA1 Message Date
Stephan Kulow
9f802cc1cd Fix cache handling with osc from git master
osc master no longer wraps urlopen, so use the underlying function
2022-08-08 17:32:18 +02:00
Stephan Kulow
529d1dafae Target E302 - add two comment lines before class 2022-02-18 17:15:48 +01:00
Stephan Kulow
f705a24db1 Only have one statement in a line E701
https://www.flake8rules.com/rules/E701.html
2022-02-18 13:42:57 +01:00
Stephan Kulow
e52dc6ce2b Harmonize imports on using lxml for XML parsing 2022-02-18 11:16:01 +01:00
Stephan Kulow
31ee1047cd Remove dependency from cache to config
Getting the right config depends on too many things that cache.py can't
know - so just rely on environment variables instead

Fixes #2289
2019-11-05 11:29:04 +01:00
Stephan Kulow
a595666eef Remove old python2 code from cache 2019-11-05 11:14:54 +01:00
Jimmy Berry
caabf42f2b osclib/cache: provide osrt.cache.disable config option to disable cache.
Necessary for writing involved tests since the assumptions made by the
cache are violated and thus cause problems.

To keep the tests passing the oscrc intended to be used must be set as
environment variable so when osclib.conf.Config is use the config is not
lost. This would be made simpler without the needless extra config added
by StagingWorkflow.
2019-11-04 14:01:19 -06:00
Jimmy Berry
5c96529c65 osclib/cache: utilize rmtree_nfs_safe(). 2019-09-18 21:37:51 -05:00
Jimmy Berry
8196c34fbe osclib/cache: handle repetative package_source_hash_history() calls. 2019-02-15 14:16:23 -06:00
Jimmy Berry
5ffaf618b0 osclib/cache: remove double comment introduced in #1802. 2018-11-28 19:11:03 -06:00
97e0dec9fb Disable caching project _meta
latest_updated is broken for _meta:
https://github.com/openSUSE/open-build-service/issues/6323
2018-11-21 11:48:57 +01:00
Stephan Kulow
ea9061ccf5 Import urllib2 python agnostic 2018-11-16 09:01:45 +01:00
Stephan Kulow
ac7b288e74 Store data as binary in the cache 2018-11-16 08:56:36 +01:00
Stephan Kulow
24ae4ba819 Port more code to run under python3
(python2 compat kept)
2018-11-16 08:14:56 +01:00
Stephan Kulow
fa1c5c56e2 Caching attributes is not worth it and creates problems
Especially caching the lockedby attribute makes it basically
impossible to work with multiple persons
2018-11-10 10:06:13 +01:00
Jimmy Berry
4c8ade1a93 flake8: utilize raw strings to avoid invalid escape character warnings. 2018-10-24 16:34:16 -05:00
Jimmy Berry
3b8ae3174c osclib/cache: provide mechanism to init multiple times.
Useful for staging plugin to cache the remote config before StagingAPI
is initialized.
2018-09-04 15:19:02 -05:00
Jimmy Berry
c47bb4c902 Utilize CacheManager for all existing caches. 2018-09-04 15:19:02 -05:00
Stephan Kulow
a840f6bf40 Don't store empty config attribute and propose migration 2018-06-15 11:40:02 +02:00
Jimmy Berry
39ef75493d Change references to osc-plugin-factory to openSUSE-release-tools. 2018-03-16 14:58:27 -05:00
Jimmy Berry
b2861ae31a osclib/cycles: only cache target project builddepinfo to avoid excessive cache.
Keep on disk using caching mechanism to avoid keep entire graphs in memory
and expiring via existing code.
2017-11-30 16:30:16 -06:00
Jimmy Berry
31cf49a09e repo_checker: store and compare build hash to skip more aggressively. 2017-10-31 18:51:38 -05:00
Jimmy Berry
7f5fbd5b4b osclib/cache: allow ttl of 0 to prevent caching. 2017-10-24 17:55:32 -05:00
d1c4801578 Another set of low-noise flake8 cleanups 2017-10-20 20:46:44 +02:00
Jimmy Berry
5b6ad33773 cache: unquote() all URLs before processing to ensure correctness.
It seems osc.core and similar generate both quoted and unquoted URLs that
are cached separately. Additionally, urlopen() handles quoted paths
differently from os.path.*() methods which can create issues for quoted
projects.
2017-07-18 23:51:22 -05:00
Jimmy Berry
c505e838cf cache: correction to match all dashboard file requests.
With the query PUTs are not match and thus the local cache is not cleared
until the next statistics/latest_updated call.
2017-05-04 11:13:12 -05:00
Jimmy Berry
f6c31d7f59 cache: include dashboard files. 2017-05-01 17:40:33 -05:00
Jimmy Berry
cff5befed3 Provide cache for expensive and cache-able staging requests.
The two slowest staging API calls are for information that rarely changes.
By caching the result the commands typically execute over twice as fast.
Going further can see improvements of an order of magnitude or more by
caching almost all the GET requests.

In contrast to osclib/memoize.py this cache operates at the HTTP request
level. This has several advantages:

- Caches the expensive part (ie the HTTP request). There are a number of
  functions in osc.core and elsewhere that make the same API request, but
  process the result differently which would require multiple API calls
  using memoize.
- Handles cases were a loader function uses class attributes as input and
  output and thus no relevant method parameters or return. An important
  example is StagingAPI._generate_ring_packages().
- Storage is project aware which allows caches to be deleted when a project
  is known to have changed.
- Due to project awareness, can utilize OBS /statistics/latest_updated API
  call to determine which projects need to be expired.

The cache file structure is as follows:

- hostname(apiurl)
  - project
    - sha1(url)
  - sha1(url)

See Cache.PATTERNS for changing the time to live (ttl) or add patterns to
be cached.
2017-01-11 10:23:54 -06:00