5240 Commits

Author SHA1 Message Date
Anish Kachinthaya
3637b1abd9 add bytes of expiring objects to queue entry
The size in bytes from object metadata of expiring objects are stored in
expirey queue entries under the content_type field.

The x-content-type-timestamp take from object metadata is provided along
with the x-content-type update so the container replicator resolves the
latest content-type and ensures eventual consistency.

UpgradeImpact: During rolling upgrades you should expect expirer queue
entries to continue lacking swift_expirer_bytes= annotations until ALL
object servers replicas have been upgraded to new code.

Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>

Change-Id: Ie4b25f1bd16def4069878983049b83de06f68e54
2024-06-13 15:47:51 -05:00
Clay Gerrard
99c629edb8 tests: realistic task_container names
Change-Id: Ie5d8b555489d28c3b901e5bbebdcecbde7bb3367
2024-05-31 14:09:32 -05:00
Clay Gerrard
f3adce1375 expirer: bad config should not loop forever
Change-Id: I9413c72f41465fb8026848f71ec3b39fa990c3b7
2024-05-23 12:50:37 -05:00
Clay Gerrard
a2df74ffe2 tests: new test_config module for utils.config
Drive-by: fix ValueError message for non_negative_int

Change-Id: I06508279d59fa57296dd85548f271a7812aeb45f
2024-05-23 12:50:31 -05:00
Zuul
337079f21f Merge "replicator: Ensure handoffs can clear with large handoff_delete" 2024-05-20 21:41:28 +00:00
Zuul
d5c26bb690 Merge "test: more test for s3api v4 checksum" 2024-05-18 00:34:18 +00:00
Tim Burke
b447234b2f Allow StatsdClients to no-op if no host provided
We've been working toward separating our logger from our statsd client.
This is generally a good idea; it's always been a little weird to have
our special-case loggers that would allow you to *also* increment some
counters.

The end goal is to take a bunch of places that look like

    logger = utils.get_logger(conf)
    ...
    logger.info(...)
    logger.increment(...)

and turn them into something more like

    logger = logs.get_adapted_logger(conf)
    stats = statsd_client.get_statsd_client(conf, logger=logger)
    ...
    logger.info(...)
    stats.increment(...)

Take a lesson from logging: callers don't need to know whether the
log_level is high enough that their message will be logged, or even
whether logging is enabled at all. Code wanting to emit stats shouldn't
need to know whether statsd collection has been configured, either.

Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Change-Id: I6eb5b27a387cc2b7310ee11cc49d38fd2b6cbab8
2024-05-17 13:49:03 -05:00
Zuul
d47811fc3e Merge "make statsd_client more explicit" 2024-05-16 19:39:51 +00:00
Zuul
3ac4030424 Merge "s3api: Improve checksum-mismatch detection" 2024-05-16 17:49:43 +00:00
Clay Gerrard
b40ae84f85 make statsd_client more explicit
Even if stdlib socket is probably patched by the time StatsdClient
creates a socket, we want to import the green socket module explicitly
for better testing.

Move test_statsd.py to test_statsd_client.py so it matches the naming
convention of the rest of our test files.

Fix some patching of utils in test_statsd_client to patch
statsd_client.

Rename some vars in test_statsd_client that shadowed the statsd_client
module name.

Move some utils tests out of test_statsd_client and back into
test_utils.

Related-Change: I4b5b12a3b0288b696a39903264741bc862a94ad7
Change-Id: I3de22b7f15dd386fa9c873587782f0dfc4c42a27
2024-05-16 16:49:54 +00:00
Clay Gerrard
893deca274 test: more test for s3api v4 checksum
Related-Change: I9924ff3b8d7d246631fe61b916823e028e2c01f2
Change-Id: I2a4581e408e3012a44bfb0cd58563b82040e23fc
2024-05-16 10:44:55 -05:00
Zuul
d1aa735a37 Merge "backend ratelimit: support per-method rate limits" 2024-05-13 16:11:19 +00:00
Zuul
bf206ed2fe Merge "backend ratelimit: support reloadable config file" 2024-05-11 20:26:40 +00:00
Zuul
927e75aa4c Merge "Use ClosingMapper to ensure prompt client disconnect logging" 2024-05-09 20:17:42 +00:00
Tim Burke
9ec83c44fd Use ClosingMapper to ensure prompt client disconnect logging
Adds ClosingMapper class which is like map() but closes the
iterable.

Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Change-Id: Idd0ac21b365a138b065f01d05a257af62ea88177
2024-05-07 09:19:33 -07:00
Shreeya Deshpande
9da22bb5fe Move statsd testing to its own module
Change-Id: I4b5b12a3b0288b696a39903264741bc862a94ad7
2024-05-03 15:08:23 -07:00
Tim Burke
38d0b3fabc Clean up watchdog threads
This shouldn't impact real servers, as those processes were about to
wrap up anyway. It *can* cause some confusing behaviors in tests,
though.

Change-Id: Ifd8a64efcd3fc983596ba7cd9fe28eb9663c93d6
2024-05-02 08:30:54 -07:00
Tim Burke
761d919677 tests: Use mock.patch more
Change-Id: I68974338f8e0284ed77960048a83f72855b93348
2024-05-01 17:33:11 -07:00
Tim Burke
b4dddb7406 tests: Use @with_tempdir more
Change-Id: I33e71f6c201bb4f2cf3481afd40cf489eb1fcd1f
2024-05-01 17:30:52 -07:00
Zuul
0a3c46e6c4 Merge "Refactor utils" 2024-05-02 00:27:02 +00:00
Shreeya Deshpande
bc3a59bdd3 Refactor utils
- Move statsd client into it's own module
- Move all logging functions into their own module
- Move all config functions into their own module
- Move all helper functions into their own module

Partial-Bug: #2015274
Change-Id: Ic4b5005e3efffa8dba17d91a41e46d5c68533f9a
2024-04-30 20:27:47 +00:00
Zuul
f7b9a72a6e Merge "object-expirer: test for mix of async and delayed deletes" 2024-04-26 15:04:15 +00:00
Zuul
b6c377e7e5 Merge "support x-open-expired header for expired objects" 2024-04-26 13:07:57 +00:00
Zuul
2e487ba695 Merge "expirer: account and container level delay_reaping" 2024-04-26 10:28:47 +00:00
Clay Gerrard
b490857b47 object-expirer: test for mix of async and delayed deletes
Related-Change: I106103438c4162a561486ac73a09436e998ae1f0
Change-Id: I95606aed5a5bd70424fbc51dd965f238fa7f064f
2024-04-26 10:53:19 +01:00
indianwhocodes
11eb17d3b2 support x-open-expired header for expired objects
If the global configuration option 'enable_open_expired' is set
to true in the config, then the client will be able to make a
request with the header 'x-open-expired' set to true in order
to access an object that has expired, provided it is in its
grace period. If this config flag is set to false, the client
will not be able to access any expired objects, even with the
header, which is the default behavior unless the flag is set.

When a client sets a 'x-open-expired' header to a true value for a
GET/HEAD/POST request the proxy will forward x-backend-open-expired to
storage server. The storage server will allow clients that set
x-backend-open-expired to open and read an object that has not yet
been reaped by the object-expirer, even after the x-delete-at time
has passed.

The header is always ignored when used with temporary URLs.

Co-Authored-By: Anish Kachinthaya <akachinthaya@nvidia.com>
Related-Change: I106103438c4162a561486ac73a09436e998ae1f0
Change-Id: Ibe7dde0e3bf587d77e14808b169c02f8fb3dddb3
2024-04-26 10:13:40 +01:00
Mandell Degerness
5961ba0ca7 expirer: account and container level delay_reaping
The object expirer can be configured to delay the reaping of
objects from disk after their expiration time using account
and container level delay_reaping values. The delay_reaping
value of accounts and containers in seconds is configured in
the object server config. The object expirer references these
configured values to only reap objects from specified accounts
and containers after their corresponding delays.

The goal of the delay_reaping feature is to prevent accidental or
premature data loss if an object marked for deletion with the
'x-delete-at' feature should not be reaped immediately, for
whatever reason.

Configuring the delay_reaping value at a granular account and
container level is beneficial for being able to keep storage
capacity consumption in control while maintaining a desired
data recovery window.

This patch also adds a sample configuration, documentation, and
tests for bad configurations and grace period functionality.

Co-Authored-By: Anish Kachinthaya <akachinthaya@nvidia.com>
Change-Id: I106103438c4162a561486ac73a09436e998ae1f0
2024-04-25 13:59:36 -07:00
Alistair Coles
3d5a97f76b proxy_logging: unit test first-byte.timing metrics
Add some test assertions to cover the first-byte timing metrics
introduced in the related change.

Add ttfb param to log_request docstring.

Change-Id: I530652dd672d7d4e5eac351ccbad318773414f7d
Related-Change: I1611e34846e586703e9d3709fa64e8df41f2d685
2024-04-19 12:33:48 +01:00
Clay Gerrard
d4435e1229 proxy-logging: emit stats more consistently
Change-Id: I526bbcc59c9eb5923c3784d5d06bc38998cb48db
2024-04-03 18:50:04 -05:00
Clay Gerrard
3c449e78e4 test: assert behavior of proxy_logging metrics
Change-Id: I651ddd40e9115a56727096d4a3aa84589146308f
2024-04-03 18:49:13 -05:00
Tim Burke
f5e422eb78 s3api: Improve checksum-mismatch detection
Previously, we relied on raising a swob.HTTPException from within a
wrapped wsgi.input and just hoping that it either

- comes uncaught all the way back through the pipeline, or at least
- gets translated back to a 422 response.

This was brittle, however; if any middleware between s3api and the
proxy took s3api's approach of turning unexpected responses into 500s,
for example, it all breaks down.

Take a cue from eventlet's Timeout and create a new s3api-specific
BaseException (which does *not* inherit from Exception) to improve
our ability to cut through all the layers.

Change-Id: I9924ff3b8d7d246631fe61b916823e028e2c01f2
2024-04-01 20:21:32 +00:00
Zuul
0e5aeb5045 Merge "s3api: Fix handling of non-ascii access keys" 2024-03-25 21:40:58 +00:00
Zuul
cdc4f264d2 Merge "recon-cron: Tolerate missing directories" 2024-03-25 06:45:56 +00:00
Tim Burke
8424b02290 s3api: Fix handling of non-ascii access keys
We stuff the access key into the request path until we get back a
more-authoritative account name from auth. But it needs to be a WSGI
string when we do!

Closes-Bug: #2058748
Change-Id: I34adb8141cc9e62d17a27f01c63f40d1dd25991c
2024-03-22 10:02:39 -07:00
Tim Burke
f31b6f7353 recon-cron: Tolerate missing directories
Any of these directories may get unlinked between when we saw them in
their parent's directory listing and when we go to descend.

Change-Id: I1dfc0ee1d9e70cb0600557cde980bd5880bd40b3
2024-03-21 14:10:14 -07:00
Jianjian Huo
27ef11ea14 test: implement cache expiration time in MockMemcached
Change-Id: I16ec414f87ac1a5e1e87e7560290c5ef0ca4f7cf
2024-03-15 13:50:32 +11:00
Zuul
891d06345e Merge "s3api: Support GET/HEAD request with ?partNumber" 2024-03-13 08:28:03 +00:00
Zuul
60db1f847c Merge "slo: part-number=N query parameter support" 2024-03-13 00:13:45 +00:00
Alistair Coles
3517ca453e backend ratelimit: support per-method rate limits
Add support for config options such as:

  head_requests_per_device_per_second = 100

Change-Id: I2936f799b6112155ff01dcd8e1f985849a1af178
2024-03-12 15:54:54 +00:00
indianwhocodes
46e7da97c6 s3api: Support GET/HEAD request with ?partNumber
Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Closes-Bug: #1735284
Change-Id: Ib396309c706fbc6bc419377fe23fcf5603a89f45
2024-03-12 13:47:55 +00:00
indianwhocodes
6adbeb4036 slo: part-number=N query parameter support
This change allows individual SLO segments to be downloaded by adding
an extra 'part-number' query parameter to the GET request.  You can
also retrieve the Content-Length of an individual segment with a HEAD
request.

Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Change-Id: I7af0dc9898ca35f042b52dd5db000072f2c7512e
2024-03-12 06:47:02 -07:00
Alistair Coles
e9abfd76ee backend ratelimit: support reloadable config file
Add support for a backend_ratelimit_conf_path option in the
[filter:backend_ratelimit] config. If specified then the middleware
will give precedence to config options from that file over config
options from the [filter:backend_ratelimit] section.

The path defaults to /etc/swift/backend-ratelimit.conf.

The config file is periodically reloaded and any changed options are
applied. The middleware will log a warning the first time it fails to
load a config file that had previously been successfully loaded. The
middleware also logs at info level when it first successfully loads a
config file that had previously failed to be loaded. Otherwise, the
middleware will log when a config file is loaded that results in the
config being changed.

Change-Id: I6554e37c6ab5b0a260f99b54169cb90ab5718f81
2024-03-11 18:10:24 +00:00
Matthew Oliver
4135133a63 memcachering: change failed to yield log message
Currently when the memcachering `_get_conns` method runs out of memcached
servers to try and so fails to yield anything we log a:

  All memcached servers error-limited

However, this error message isn't entirely accurate. It can also fail
because it failed to connect all it's memcached servers not just because
they're error limited.
You can disable error-limiting of memcached servers. So in this case
this error message is a red-herring.

Downstream we use a mcrouter client on each node which itself talks to a
bunch of memcache servers. Therefore in swift's memcachering client we
only configure the 1 mcrouter client as a single server in the ring.
Because of this we disable memcached error-limiting.
If the node gets too overloaded we've had timeouts talking to the local
mcrouter client. This fires off error-limitted log messages which can
confuse things.

Because it's possible to turn off error-limiting, the log line isn't
quite adequate anymore. So this patch changes it to:

  No more memcached servers to try

Change-Id: I97fb4f3ee2ac45831aae14a782b2c6dc73e82d85
2024-03-05 14:44:37 +11:00
Zuul
3478803a95 Merge "zero bytes manifests are not legacy" 2024-02-28 17:34:04 +00:00
Zuul
0947e94f66 Merge "staticweb: Work with prefix-based tempurls" 2024-02-28 07:42:52 +00:00
Clay Gerrard
130188b6c0 zero bytes manifests are not legacy
Change-Id: I7c8adb129b8770eee501748a378f3adc42c8cd39
2024-02-27 17:21:00 -06:00
Zuul
4c5f41cc1f Merge "Fix diskfile test failing on macOS" 2024-02-27 21:32:05 +00:00
Zuul
07c8e8bcdc Merge "Object-server: add periodic greenthread yielding during file read." 2024-02-27 04:03:00 +00:00
Jianjian Huo
d5877179a5 Object-server: add periodic greenthread yielding during file read.
Currently, when object-server serves GET request and DiskFile
reader iterate over disk file chunks, there is no explicit
eventlet sleep called. When network outpace the slow disk IO,
it's possible one large and slow GET request could cause
eventlet hub not to schedule any other green threads for a
long period of time. To improve this, this patch add a
configurable sleep parameter into DiskFile reader, which
is 'cooperative_period' with a default value of 0 (disabled).

Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Change-Id: I80b04bad0601b6cd6caef35498f89d4ba70a4fd4
2024-02-27 11:24:41 +11:00
Alistair Coles
2da150b890 Fix diskfile test failing on macOS
The existing test fails on macOS because the value of errno.ENODATA is
platform dependent. On macOS ENODATA is 96:

% man 2 intro|grep ENODATA
     96 ENODATA No message available.

Change-Id: Ibc760e641d4351ed771f2321dba27dc4e5b367c1
2024-02-26 11:12:47 +00:00