mirror of
https://github.com/pgsty/minio.git
synced 2026-12-03 20:36:37 +03:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6133a345c8 | |||
| 5bb817bdf8 | |||
| d159197c74 | |||
| 0e72442427 | |||
| 1203f068c8 | |||
| 5e94a48dcc | |||
| 35e33762cb | |||
| 9acba8560c | |||
| 840615c357 | |||
| 5da5f0a342 | |||
| 30dcc5015c | |||
| c1d0e866d9 |
@@ -14,7 +14,7 @@ RUN mkdir -p /prep/data && chmod 0777 /prep/data
|
||||
# Debian's bundle in distroless still trusts the roots the classic image
|
||||
# blocklists. Build the same bundle as Dockerfile.goreleaser so both variants
|
||||
# trust the same roots; it is architecture-neutral, so build it natively.
|
||||
FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi9/ubi:latest@sha256:8b212f75a0e5a156ac28b1c5c030d2e8a07715254e19d522286118279399af81 AS certs
|
||||
FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi9/ubi:latest@sha256:1e9f0ed9fceafb40878bc1705ff124aa150e3fed873f18c42cdc2dded319e0a8 AS certs
|
||||
# Native root blocklist mitigation: https://access.redhat.com/security/vulnerabilities/RHSB-2026-012
|
||||
RUN dnf -y install ca-certificates && \
|
||||
if [ -d /etc/pki/ca-trust/source/blocklist ]; then \
|
||||
|
||||
@@ -69,7 +69,7 @@ RUN apk add -U --no-cache \
|
||||
mkdir -p /go/share/mcli && \
|
||||
cp /tmp/mcli-extract/LICENSE /tmp/mcli-extract/NOTICE /tmp/mcli-extract/CREDITS /go/share/mcli/
|
||||
|
||||
FROM registry.access.redhat.com/ubi9/ubi:latest@sha256:8b212f75a0e5a156ac28b1c5c030d2e8a07715254e19d522286118279399af81 AS certs
|
||||
FROM registry.access.redhat.com/ubi9/ubi:latest@sha256:1e9f0ed9fceafb40878bc1705ff124aa150e3fed873f18c42cdc2dded319e0a8 AS certs
|
||||
# Native root blocklist mitigation: https://access.redhat.com/security/vulnerabilities/RHSB-2026-012
|
||||
RUN dnf -y install ca-certificates && \
|
||||
if [ -d /etc/pki/ca-trust/source/blocklist ]; then \
|
||||
@@ -88,7 +88,7 @@ RUN dnf -y install ca-certificates && \
|
||||
dnf clean all && \
|
||||
rm -rf /var/cache/dnf
|
||||
|
||||
FROM registry.access.redhat.com/ubi9/ubi-micro:latest@sha256:b59ac4f291d86027c2681f7a7b1cbf7448972fc55a6cb8e25cab5aa5eef5ce5f
|
||||
FROM registry.access.redhat.com/ubi9/ubi-micro:latest@sha256:dbd325b96bcd432dd42816d31412bdf1dc0fb973b79ed310344bc23c76c068db
|
||||
|
||||
LABEL org.opencontainers.image.title="Silo" \
|
||||
org.opencontainers.image.description="S3-Interface Libre Object Storage" \
|
||||
|
||||
@@ -420,6 +420,12 @@ func checkObjectWithAllParts(ctx context.Context, onlineDisks []StorageAPI, part
|
||||
default:
|
||||
verifyResp, verifyErr = onlineDisk.CheckParts(ctx, bucket, object, meta)
|
||||
}
|
||||
if verifyErr == nil && (verifyResp == nil || len(verifyResp.Results) < len(latestMeta.Parts)) {
|
||||
// A drive that returned no usable per-part result cannot vouch
|
||||
// for its parts; treat it like an unreachable drive instead of
|
||||
// dereferencing a nil or short response.
|
||||
verifyErr = errDiskNotFound
|
||||
}
|
||||
|
||||
for p := range latestMeta.Parts {
|
||||
if verifyErr != nil {
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -772,3 +773,55 @@ func TestCommonParities(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// checkPartsResultDisk returns a programmed CheckParts/VerifyFile result.
|
||||
// All other StorageAPI methods are unimplemented and panic if called.
|
||||
type checkPartsResultDisk struct {
|
||||
StorageAPI
|
||||
resp *CheckPartsResp
|
||||
err error
|
||||
}
|
||||
|
||||
func (d *checkPartsResultDisk) CheckParts(context.Context, string, string, FileInfo) (*CheckPartsResp, error) {
|
||||
return d.resp, d.err
|
||||
}
|
||||
|
||||
func (d *checkPartsResultDisk) VerifyFile(context.Context, string, string, FileInfo) (*CheckPartsResp, error) {
|
||||
return d.resp, d.err
|
||||
}
|
||||
|
||||
// A drive whose CheckParts/VerifyFile returns no error but also no (or a
|
||||
// short) per-part result, e.g. a remote stream that ended without a response,
|
||||
// must be reported as unreachable instead of crashing the heal.
|
||||
func TestCheckObjectWithAllPartsMissingResult(t *testing.T) {
|
||||
for _, scanMode := range []madmin.HealScanMode{madmin.HealNormalScan, madmin.HealDeepScan} {
|
||||
t.Run(fmt.Sprintf("scanMode=%d", scanMode), func(t *testing.T) {
|
||||
meta := nativeAuditMetadata()
|
||||
full := &CheckPartsResp{Results: []int{checkPartSuccess, checkPartSuccess}}
|
||||
mixed := &CheckPartsResp{Results: []int{checkPartSuccess, checkPartFileNotFound}}
|
||||
disks := []StorageAPI{
|
||||
&checkPartsResultDisk{resp: nil}, // (nil, nil)
|
||||
&checkPartsResultDisk{resp: &CheckPartsResp{Results: []int{checkPartSuccess}}}, // short result
|
||||
&checkPartsResultDisk{resp: mixed},
|
||||
&checkPartsResultDisk{resp: full},
|
||||
}
|
||||
errs := make([]error, len(disks))
|
||||
|
||||
byDisk, byPart := checkObjectWithAllParts(t.Context(), disks, meta, errs, meta[0],
|
||||
false, "bucket", "object", scanMode)
|
||||
|
||||
unavailable := []int{checkPartDiskNotFound, checkPartDiskNotFound}
|
||||
wantDisks := map[int][]int{0: unavailable, 1: unavailable, 2: mixed.Results, 3: full.Results}
|
||||
if !reflect.DeepEqual(byDisk, wantDisks) {
|
||||
t.Errorf("results by disk: got %v, want %v", byDisk, wantDisks)
|
||||
}
|
||||
wantParts := map[int][]int{
|
||||
0: {checkPartDiskNotFound, checkPartDiskNotFound, checkPartSuccess, checkPartSuccess},
|
||||
1: {checkPartDiskNotFound, checkPartDiskNotFound, checkPartFileNotFound, checkPartSuccess},
|
||||
}
|
||||
if !reflect.DeepEqual(byPart, wantParts) {
|
||||
t.Errorf("results by part: got %v, want %v", byPart, wantParts)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,11 @@ func trimAwsChunkedContentEncoding(contentEnc string) (trimmedContentEnc string)
|
||||
}
|
||||
var newEncs []string
|
||||
for enc := range strings.SplitSeq(contentEnc, ",") {
|
||||
if enc != streamingContentEncoding {
|
||||
// Content-Encoding is a comma separated list with optional
|
||||
// whitespace around each coding, and coding names are
|
||||
// case-insensitive, e.g. "gzip, aws-chunked".
|
||||
enc = strings.TrimSpace(enc)
|
||||
if !strings.EqualFold(enc, streamingContentEncoding) {
|
||||
newEncs = append(newEncs, enc)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,3 +392,30 @@ func TestGetResource(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test trimAwsChunkedContentEncoding() removes the aws-chunked coding wherever
|
||||
// it appears in the Content-Encoding list, regardless of the optional
|
||||
// whitespace after the commas or the case of the coding name.
|
||||
func TestTrimAwsChunkedContentEncoding(t *testing.T) {
|
||||
testCases := []struct {
|
||||
in string
|
||||
expected string
|
||||
}{
|
||||
{"", ""},
|
||||
{"aws-chunked", ""},
|
||||
{"aws-chunked,gzip", "gzip"},
|
||||
{"gzip,aws-chunked", "gzip"},
|
||||
{"aws-chunked, gzip", "gzip"},
|
||||
{"gzip, aws-chunked", "gzip"},
|
||||
{"gzip , aws-chunked", "gzip"},
|
||||
{"AWS-Chunked", ""},
|
||||
{"gzip, AWS-Chunked", "gzip"},
|
||||
{"gzip", "gzip"},
|
||||
{"gzip, br", "gzip,br"},
|
||||
}
|
||||
for i, test := range testCases {
|
||||
if got := trimAwsChunkedContentEncoding(test.in); got != test.expected {
|
||||
t.Errorf("test %d: input %q: expected %q got %q", i+1, test.in, test.expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,8 @@ func TestExtractReplicationMetadataPreservesNormalizedMetadata(t *testing.T) {
|
||||
{name: "gzip", wire: []string{"gzip"}, want: "gzip"},
|
||||
{name: "transport-last", wire: []string{"gzip,aws-chunked"}, want: "gzip"},
|
||||
{name: "multiple-values", wire: []string{"aws-chunked", "gzip"}, want: "gzip"},
|
||||
// Preserve the existing exact-token grammar; whitespace is not normalized here.
|
||||
{name: "space-before-gzip", wire: []string{"aws-chunked, gzip"}, want: " gzip"},
|
||||
{name: "space-before-transport", wire: []string{"gzip, aws-chunked"}, want: "gzip, aws-chunked"},
|
||||
{name: "space-before-gzip", wire: []string{"aws-chunked, gzip"}, want: "gzip"},
|
||||
{name: "space-before-transport", wire: []string{"gzip, aws-chunked"}, want: "gzip"},
|
||||
} {
|
||||
for _, lowercase := range []bool{false, true} {
|
||||
name := tc.name + "/canonical"
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// Copyright (c) 2026 Feng Ruohang
|
||||
//
|
||||
// This file is part of Silo Object Storage.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio/internal/grid"
|
||||
)
|
||||
|
||||
func TestStorageRESTClientCheckPartsCompletion(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
reply []int
|
||||
disconnect bool
|
||||
remoteErr error
|
||||
wantErr error
|
||||
}{
|
||||
{name: "one-response", reply: []int{checkPartSuccess, checkPartFileNotFound}},
|
||||
{name: "zero-parts", reply: []int{}},
|
||||
{name: "empty-completion", wantErr: errDiskNotFound},
|
||||
{name: "disconnect", disconnect: true, wantErr: errDiskNotFound},
|
||||
{name: "storage-error", remoteErr: errFileCorrupt, wantErr: errFileCorrupt},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
g, err := grid.SetupTestGrid(2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(g.Cleanup)
|
||||
const route = "/disk"
|
||||
handled := make(chan error, 1)
|
||||
handle := func(_ context.Context, _ *CheckPartsHandlerParams, _ <-chan grid.NoPayload, out chan<- *CheckPartsResp) *grid.RemoteErr {
|
||||
var closeErr error
|
||||
if tc.reply != nil {
|
||||
out <- &CheckPartsResp{Results: slices.Clone(tc.reply)}
|
||||
}
|
||||
if tc.disconnect {
|
||||
closeErr = g.ClosePeerConnection(1, 0)
|
||||
}
|
||||
handled <- closeErr
|
||||
return grid.NewRemoteErr(tc.remoteErr)
|
||||
}
|
||||
for _, mgr := range g.Managers {
|
||||
if err := storageCheckPartsRPC.Register(mgr, handle, route); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
client := &storageRESTClient{gridConn: g.Managers[0].Connection(g.Hosts[1]).Subroute(route)}
|
||||
client.SetDiskID("synthetic")
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
|
||||
defer cancel()
|
||||
fi := FileInfo{Parts: []ObjectPartInfo{{Number: 1}, {Number: 2}}}
|
||||
if tc.reply != nil && len(tc.reply) == 0 {
|
||||
fi.Parts = nil
|
||||
}
|
||||
resp, err := client.CheckParts(ctx, "bucket", "object", fi)
|
||||
select {
|
||||
case closeErr := <-handled:
|
||||
if closeErr != nil {
|
||||
t.Fatalf("closing peer connection: %v", closeErr)
|
||||
}
|
||||
case <-ctx.Done():
|
||||
t.Fatalf("peer did not complete the handler: %v", ctx.Err())
|
||||
}
|
||||
if ctx.Err() != nil {
|
||||
t.Fatalf("caller context ended: %v", ctx.Err())
|
||||
}
|
||||
if !errors.Is(err, tc.wantErr) {
|
||||
t.Fatalf("CheckParts returned %v, want %v", err, tc.wantErr)
|
||||
}
|
||||
if tc.wantErr != nil {
|
||||
if resp != nil {
|
||||
t.Fatalf("unexpected response on error: %+v", resp)
|
||||
}
|
||||
return
|
||||
}
|
||||
if resp == nil || !slices.Equal(resp.Results, tc.reply) {
|
||||
t.Fatalf("got %+v, want part results %v", resp, tc.reply)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -480,6 +480,12 @@ func (client *storageRESTClient) CheckParts(ctx context.Context, volume string,
|
||||
resp = r
|
||||
return nil
|
||||
})
|
||||
if err == nil && resp == nil {
|
||||
// The stream ended without a response and without an error,
|
||||
// e.g. when the mux was closed during a disconnect. Never
|
||||
// return (nil, nil): callers rely on resp being set on success.
|
||||
err = grid.ErrDisconnected
|
||||
}
|
||||
return resp, toStorageErr(err)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -3366,7 +3366,7 @@ func (s *xlStorage) CleanAbandonedData(ctx context.Context, volume string, path
|
||||
newBuf, err := xl.AppendTo(metaDataPoolGet())
|
||||
if err == nil {
|
||||
defer metaDataPoolPut(newBuf)
|
||||
return s.WriteAll(ctx, volume, pathJoin(path, xlStorageFormatFile), buf)
|
||||
return s.WriteAll(ctx, volume, pathJoin(path, xlStorageFormatFile), newBuf)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1643,6 +1643,81 @@ func TestXLStorageRenameFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestXLStorageCleanAbandonedInlineData(t *testing.T) {
|
||||
disk, _, err := newXLStorageTestSetup(t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer disk.Close()
|
||||
ctx := t.Context()
|
||||
const volume, object = "test-bucket", "inline-object"
|
||||
if err := disk.MakeVol(ctx, volume); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
versions := []struct {
|
||||
id, body string
|
||||
legacy bool
|
||||
}{
|
||||
{nullVersionID, "null version", false},
|
||||
{mustGetUUID(), "named version", false},
|
||||
{mustGetUUID(), "legacy data-dir key", true},
|
||||
}
|
||||
var meta xlMetaV2
|
||||
for _, v := range versions {
|
||||
fi := newFileInfo(object, 2, 2)
|
||||
fi.VersionID = v.id
|
||||
fi.DataDir = mustGetUUID()
|
||||
fi.Erasure.Index = 1
|
||||
fi.ModTime = UTCNow()
|
||||
fi.Data = []byte(v.body)
|
||||
fi.Size = int64(len(fi.Data))
|
||||
fi.AddObjectPart(1, "", fi.Size, fi.Size, fi.ModTime, nil, nil)
|
||||
if !v.legacy {
|
||||
fi.SetInlineData()
|
||||
}
|
||||
if err := meta.AddVersion(fi); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v.legacy && !meta.data.rename(v.id, fi.DataDir) {
|
||||
t.Fatal("failed to store legacy inline data by data directory")
|
||||
}
|
||||
}
|
||||
orphan := mustGetUUID()
|
||||
meta.data.replace(orphan, []byte("abandoned data"))
|
||||
buf, err := meta.AppendTo(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
metaPath := pathJoin(object, xlStorageFormatFile)
|
||||
if err := disk.WriteAll(ctx, volume, metaPath, buf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for pass := 1; pass <= 2; pass++ {
|
||||
if err := disk.CleanAbandonedData(ctx, volume, object); err != nil {
|
||||
t.Fatalf("cleanup %d: %v", pass, err)
|
||||
}
|
||||
raw, err := disk.ReadAll(ctx, volume, metaPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var saved xlMetaV2
|
||||
if err := saved.Load(raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if saved.data.find(orphan) != nil {
|
||||
t.Fatalf("cleanup %d left orphan %s in xl.meta", pass, orphan)
|
||||
}
|
||||
for _, v := range versions {
|
||||
fi, err := disk.ReadVersion(ctx, "", volume, object, v.id, ReadOptions{ReadData: true})
|
||||
if err != nil || string(fi.Data) != v.body {
|
||||
t.Fatalf("after cleanup %d, read version %s: got %q, %v; want %q", pass, v.id, fi.Data, err, v.body)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestXLStorageDeleteVersion will test if version deletes and bulk deletes work as expected.
|
||||
func TestXLStorageDeleteVersion(t *testing.T) {
|
||||
// create xlStorage test setup
|
||||
|
||||
@@ -128,6 +128,22 @@ func (t *TestGrid) Cleanup() {
|
||||
})
|
||||
}
|
||||
|
||||
// ClosePeerConnection closes the live transport at one end of a test grid link.
|
||||
// Both managers stay running, so callers observe a peer disconnect and may reconnect.
|
||||
func (t *TestGrid) ClosePeerConnection(from, to int) error {
|
||||
c := t.Managers[from].Connection(t.Hosts[to])
|
||||
c.connMu.Lock()
|
||||
defer c.connMu.Unlock()
|
||||
peer := c.debugInConn
|
||||
if c.shouldConnect() {
|
||||
peer = c.debugOutConn
|
||||
}
|
||||
if peer == nil {
|
||||
return ErrDisconnected
|
||||
}
|
||||
return peer.Close()
|
||||
}
|
||||
|
||||
// WaitAllConnect will wait for all connections to be established.
|
||||
func (t *TestGrid) WaitAllConnect(ctx context.Context) {
|
||||
for _, manager := range t.Managers {
|
||||
|
||||
Reference in New Issue
Block a user