Skip to content

SWIFT: Splitting segment hashes into multiple directories doesn't work as intended #2407

@JamieGarside

Description

@JamieGarside

This is a minor bug we've noticed while trying to chase something else. The SWIFT driver uploads segments of a DLO by first hashing the path, and a bit of random data using SHA1, then uploading to <container>/segments/hash[0:3]/hash[3:]/segment00000XYZ, as done around here: https://github.com/docker/distribution/blob/master/registry/storage/driver/swift/swift.go#L658

Sadly, the usage of the hash is slightly broken, causing all subfolders to end up in a single folder called "2f6". This is because Go's hash summing routines operate by first emitting the input string, followed by the checksum. For this reason, the first three nibbles of the hex output are the same (as the path always starts with /docker).

Go playground example demonstrating the issue: https://play.golang.org/p/MLBR4ggVbf

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions