-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various S3 fixes around marker file handling: - Deletion and overwrite now also triggers a marker update - Require the protocol in the option's URL
- Loading branch information
Showing
5 changed files
with
144 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package s3 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
) | ||
|
||
// setMarker puts name and etag into the object identified by | ||
// UpdateMarkerFilename. | ||
// An empty etag string means that the object identified by name was deleted. | ||
// | ||
// In case the UseUpdateMarker option is false, this function doesn't do | ||
// anything and returns no error. | ||
func (b *Backend) setMarker(ctx context.Context, name, etag string, isDel bool) error { | ||
if !b.opt.UseUpdateMarker { | ||
return nil | ||
} | ||
nanos := time.Now().UnixNano() | ||
s := fmt.Sprintf("%s:%s:%d:%v", name, etag, nanos, isDel) | ||
_, err := b.doStore(ctx, UpdateMarkerFilename, []byte(s)) | ||
if err != nil { | ||
return err | ||
} | ||
b.mu.Lock() | ||
defer b.mu.Unlock() | ||
b.lastList = nil | ||
b.lastMarker = s | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,33 +3,49 @@ | |
set -e | ||
|
||
# Stop all child processes on exit | ||
trap "pkill -P $$" EXIT | ||
trap cleanup EXIT | ||
|
||
cleanup() { | ||
pkill -P $$ | ||
if [ -n "$tmpdir" ] && [ -d "$tmpdir" ]; then | ||
rm -r "$tmpdir" | ||
fi | ||
} | ||
|
||
export GOBIN="$PWD/bin" | ||
export PATH="$GOBIN:$PATH" | ||
tmpdir= | ||
|
||
mkdir -p "$GOBIN" | ||
|
||
if [ -z "$SIMPLEBLOB_TEST_S3_CONFIG" ]; then | ||
echo "* Using MinIO for S3 tests" | ||
export SIMPLEBLOB_TEST_S3_CONFIG="$PWD/test-minio.json" | ||
|
||
# Check for existing minio | ||
minio=$(which minio || true) | ||
|
||
# Fetch minio if not found | ||
if [ -z "$minio" ]; then | ||
#minioversion="github.com/minio/[email protected]" | ||
#echo "+ go install $minioversion" > /dev/stderr | ||
#go install "$minioversion" | ||
if ! command -v minio >/dev/null; then | ||
source <(go env) | ||
curl -v -o "$GOBIN/minio" "https://dl.min.io/server/minio/release/$GOOS-$GOARCH/minio" | ||
minio=./bin/minio | ||
chmod 6755 "$minio" | ||
dst="$GOBIN/minio" | ||
curl -v -o "$dst" "https://dl.min.io/server/minio/release/$GOOS-$GOARCH/minio" | ||
chmod u+x "$dst" | ||
fi | ||
|
||
# Start MinIO | ||
echo "* Starting $minio on port 34730" | ||
echo "* Starting minio at address 127.0.0.1:34730" | ||
tmpdir=$(mktemp -d -t minio.XXXXXX) | ||
"$minio" server --address 127.0.0.1:34730 --console-address 127.0.0.1:34731 --quiet "$tmpdir" & | ||
sleep 3 | ||
minio server --address 127.0.0.1:34730 --console-address 127.0.0.1:34731 --quiet "$tmpdir" & | ||
# Wait for minio server to be ready | ||
i=0 | ||
while ! curl -s -I "127.0.0.1:34730/minio/health/ready" | grep '200 OK' >/dev/null; do | ||
i=$((i+1)) | ||
if [ "$i" -ge 10 ]; then | ||
# We have been waiting for server to start for 10 seconds | ||
echo "Minio could not start properly" | ||
curl -s -I "127.0.0.1:34730/minio/health/ready" | ||
exit 1 | ||
fi | ||
sleep 1 | ||
done | ||
fi | ||
|
||
echo "* SIMPLEBLOB_TEST_S3_CONFIG=$SIMPLEBLOB_TEST_S3_CONFIG" | ||
|
@@ -39,6 +55,6 @@ set -ex | |
go test -count=1 "$@" ./... | ||
|
||
# Configure linters in .golangci.yml | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 | ||
./bin/golangci-lint run | ||
|
||
expected_version=v1.50.1 | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@"$expected_version" | ||
golangci-lint run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters