container-updater can't suppress accounts with whitespace in name

Bug #2040332 reported by Tim Burke
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
In Progress
Undecided
Unassigned

Bug Description

The container-updater has a unique account-suppression feature: if it cannot successfully update a quorum of account replicas, it will attempt to suppress further updates to that account for some period of time. Within a single worker handling a single part, this is easy enough. To share state between workers, though, we create a temporary files per-worker [0] which we write to as failures occur [1], and then read back in the manager process [2].

The serialization format is very simple: write out a line like "<account> <next allowed update time>". However, accounts (like all virtual paths in Swift) can contain not just spaces but newlines as well; if such an account is suppressed, it may lead to ValueErrors during unpacking or even cause us to suppress the wrong account.

[0] https://github.com/openstack/swift/blob/2.32.0/swift/container/updater.py#L154-L165
[1] https://github.com/openstack/swift/blob/2.32.0/swift/container/updater.py#L304-L306
[2] https://github.com/openstack/swift/blob/2.32.0/swift/container/updater.py#L117-L128

Revision history for this message
Yihong Jin (yihongjin) wrote (last edit ):

I'm interested in addressing this issue as it seems like a 'good first issue' to me — its modifications won't significantly impact other components. Before beginning, I'd like to propose and discuss a few potential solutions:

1. Manual Escape Mechanism: Implement helper functions which use a backslash (\) or another special character to indicate that the subsequent character is part of the account name, not a delimiter or line break.

Pros: Intuitive.
Cons: Maintenance-heavy and may not cover all edge cases.

2. JSON Serialization: Utilize a JSON file to manage account names and their update times. JSON inherently handles special characters, eliminating the need for an explicit escape mechanism.

Pros: Automatically handles special characters, robust against edge cases, and widely used.
Cons: The codebase of SWIFT doesn't use JSON for local status storing, primarily reserving it for network-related functions. Is this caused by some special reasons?

I look forward to discussing these options and identifying the best approach. Additionally, I'd like to make sure if there are other modules that depend on this file, as this could influence our choice of solution.

UPDATE:
Finally decided to go with URL Encoding provided by urllib as it will be a quick and robust solution. Have committed the change.

Changed in swift:
status: New → In Progress
Yihong Jin (yihongjin)
Changed in swift:
assignee: nobody → Yihong Jin (yihongjin)
Yihong Jin (yihongjin)
Changed in swift:
assignee: Yihong Jin (yihongjin) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/swift/+/905554

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.