From c387fe957b1be5342e2188bf258c440815fb98d0 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 11 Nov 2021 16:08:41 +0900 Subject: [PATCH 01/23] Unused parameter removed. --- weed/shell/command_volume_configure_replication.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/shell/command_volume_configure_replication.go b/weed/shell/command_volume_configure_replication.go index 5640e58bb..00eab2c85 100644 --- a/weed/shell/command_volume_configure_replication.go +++ b/weed/shell/command_volume_configure_replication.go @@ -34,7 +34,7 @@ func (c *commandVolumeConfigureReplication) Help() string { ` } -func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { +func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *CommandEnv, _ io.Writer) (err error) { configureReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) volumeIdInt := configureReplicationCommand.Int("volumeId", 0, "the volume id") From dbb8003ce3cb0891eb78c117ad1e7d64dc7f5e4d Mon Sep 17 00:00:00 2001 From: user Date: Thu, 11 Nov 2021 17:36:26 +0900 Subject: [PATCH 02/23] Volume filter function added. --- weed/shell/command_volume_configure_replication.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/weed/shell/command_volume_configure_replication.go b/weed/shell/command_volume_configure_replication.go index 00eab2c85..591e88b45 100644 --- a/weed/shell/command_volume_configure_replication.go +++ b/weed/shell/command_volume_configure_replication.go @@ -55,7 +55,6 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman if err != nil { return fmt.Errorf("replication format: %v", err) } - replicaPlacementInt32 := uint32(replicaPlacement.Byte()) // collect topology information topologyInfo, _, err := collectTopologyInfo(commandEnv) @@ -64,6 +63,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman } vid := needle.VolumeId(*volumeIdInt) + volumeFilter := getVolumeFilter(replicaPlacement, uint32(vid)) // find all data nodes with volumes that needs replication change var allLocations []location @@ -71,7 +71,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman loc := newLocation(dc, string(rack), dn) for _, diskInfo := range dn.DiskInfos { for _, v := range diskInfo.VolumeInfos { - if v.Id == uint32(vid) && v.ReplicaPlacement != replicaPlacementInt32 { + if volumeFilter(v) { allLocations = append(allLocations, loc) continue } @@ -106,3 +106,10 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman return nil } + +func getVolumeFilter(replicaPlacement *super_block.ReplicaPlacement, volumeId uint32) func(message *master_pb.VolumeInformationMessage) bool { + replicaPlacementInt32 := uint32(replicaPlacement.Byte()) + return func(v *master_pb.VolumeInformationMessage) bool { + return v.Id == volumeId && v.ReplicaPlacement != replicaPlacementInt32 + } +} From 563a74a9eb050730ee16e3510ca95d0c36d13fdb Mon Sep 17 00:00:00 2001 From: user Date: Thu, 11 Nov 2021 18:01:47 +0900 Subject: [PATCH 03/23] Volume filter by collection pattern added. --- .../shell/command_volume_configure_replication.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/weed/shell/command_volume_configure_replication.go b/weed/shell/command_volume_configure_replication.go index 591e88b45..fe4eab22a 100644 --- a/weed/shell/command_volume_configure_replication.go +++ b/weed/shell/command_volume_configure_replication.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/chrislusf/seaweedfs/weed/pb" "io" + "path/filepath" "github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/pb/master_pb" @@ -39,6 +40,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman configureReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) volumeIdInt := configureReplicationCommand.Int("volumeId", 0, "the volume id") replicationString := configureReplicationCommand.String("replication", "", "the intended replication value") + collectionPattern := configureReplicationCommand.String("collectionPattern", "", "match with wildcard characters '*' and '?'") if err = configureReplicationCommand.Parse(args); err != nil { return nil } @@ -63,7 +65,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman } vid := needle.VolumeId(*volumeIdInt) - volumeFilter := getVolumeFilter(replicaPlacement, uint32(vid)) + volumeFilter := getVolumeFilter(replicaPlacement, uint32(vid), *collectionPattern) // find all data nodes with volumes that needs replication change var allLocations []location @@ -107,8 +109,17 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman return nil } -func getVolumeFilter(replicaPlacement *super_block.ReplicaPlacement, volumeId uint32) func(message *master_pb.VolumeInformationMessage) bool { +func getVolumeFilter(replicaPlacement *super_block.ReplicaPlacement, volumeId uint32, collectionPattern string) func(message *master_pb.VolumeInformationMessage) bool { replicaPlacementInt32 := uint32(replicaPlacement.Byte()) + if collectionPattern != "" { + return func(v *master_pb.VolumeInformationMessage) bool { + matched, err := filepath.Match(collectionPattern, v.Collection) + if err != nil { + return false + } + return matched + } + } return func(v *master_pb.VolumeInformationMessage) bool { return v.Id == volumeId && v.ReplicaPlacement != replicaPlacementInt32 } From 9668b15f3868b5084961a27fb79588b01ae9a91e Mon Sep 17 00:00:00 2001 From: user Date: Thu, 11 Nov 2021 18:18:56 +0900 Subject: [PATCH 04/23] Filtering by volume id is prioritized. --- weed/shell/command_volume_configure_replication.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/weed/shell/command_volume_configure_replication.go b/weed/shell/command_volume_configure_replication.go index fe4eab22a..7e9627b40 100644 --- a/weed/shell/command_volume_configure_replication.go +++ b/weed/shell/command_volume_configure_replication.go @@ -111,16 +111,16 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman func getVolumeFilter(replicaPlacement *super_block.ReplicaPlacement, volumeId uint32, collectionPattern string) func(message *master_pb.VolumeInformationMessage) bool { replicaPlacementInt32 := uint32(replicaPlacement.Byte()) - if collectionPattern != "" { + if volumeId > 0 { return func(v *master_pb.VolumeInformationMessage) bool { - matched, err := filepath.Match(collectionPattern, v.Collection) - if err != nil { - return false - } - return matched + return v.Id == volumeId && v.ReplicaPlacement != replicaPlacementInt32 } } return func(v *master_pb.VolumeInformationMessage) bool { - return v.Id == volumeId && v.ReplicaPlacement != replicaPlacementInt32 + matched, err := filepath.Match(collectionPattern, v.Collection) + if err != nil { + return false + } + return matched } } From 12d9108bb4047e52defdaf545de211cda81e0e10 Mon Sep 17 00:00:00 2001 From: Jay Zhang Date: Thu, 11 Nov 2021 19:59:12 +0800 Subject: [PATCH 05/23] chore: disable http2 in go-release-action --- .github/workflows/binaries_dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index 49bd27411..99f5d3e65 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -38,8 +38,8 @@ jobs: - name: Set BUILD_TIME env run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV} - - name: disable http2 env - run: export GODEBUG=http2client=0 + #- name: disable http2 env + # run: export GODEBUG=http2client=0 - name: Go Release Binaries Large Disk uses: wangyoucao577/go-release-action@bugfix/upload-fail @@ -49,7 +49,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` From 79a1903021189b02ca1abb2489ce24edd60f9220 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 11 Nov 2021 11:53:47 -0800 Subject: [PATCH 06/23] Update binaries_dev.yml --- .github/workflows/binaries_dev.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index 49bd27411..a3a912595 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -38,9 +38,6 @@ jobs: - name: Set BUILD_TIME env run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV} - - name: disable http2 env - run: export GODEBUG=http2client=0 - - name: Go Release Binaries Large Disk uses: wangyoucao577/go-release-action@bugfix/upload-fail with: @@ -49,7 +46,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -65,7 +62,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed @@ -96,7 +93,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -112,7 +109,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed From 5eb905a5d14bb2864a2d141dc875da06f3344cd0 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 11 Nov 2021 12:05:23 -0800 Subject: [PATCH 07/23] Update binaries_dev.yml --- .github/workflows/binaries_dev.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index a3a912595..74f09f617 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -3,8 +3,6 @@ name: "go: build dev binaries" on: push: branches: [ master ] - pull_request: - branches: [ master ] jobs: From 4d388b97826eae62874cbde013d30886a23689e1 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 11 Nov 2021 18:37:38 -0800 Subject: [PATCH 08/23] Update binaries_dev.yml --- .github/workflows/binaries_dev.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index 74f09f617..2fa4cbfee 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -44,7 +44,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -60,7 +60,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed @@ -91,7 +91,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -107,7 +107,7 @@ jobs: goarch: ${{ matrix.goarch }} release_tag: dev overwrite: true - pre_command: export CGO_ENABLED=0 && GODEBUG=http2client=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed From 177129013ca7e753ae17507da9a03b23be0d687b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 11 Nov 2021 21:28:06 -0800 Subject: [PATCH 09/23] releases in github actions disable http2client --- .github/workflows/binaries_release0.yml | 4 ++-- .github/workflows/binaries_release1.yml | 4 ++-- .github/workflows/binaries_release2.yml | 4 ++-- .github/workflows/binaries_release3.yml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/binaries_release0.yml b/.github/workflows/binaries_release0.yml index 622fe5dd6..e485c8785 100644 --- a/.github/workflows/binaries_release0.yml +++ b/.github/workflows/binaries_release0.yml @@ -31,7 +31,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -45,7 +45,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` diff --git a/.github/workflows/binaries_release1.yml b/.github/workflows/binaries_release1.yml index a0cc2c74c..ad546c3b4 100644 --- a/.github/workflows/binaries_release1.yml +++ b/.github/workflows/binaries_release1.yml @@ -31,7 +31,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -45,7 +45,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` diff --git a/.github/workflows/binaries_release2.yml b/.github/workflows/binaries_release2.yml index 95cde0fdd..8428a92f8 100644 --- a/.github/workflows/binaries_release2.yml +++ b/.github/workflows/binaries_release2.yml @@ -31,7 +31,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -45,7 +45,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` diff --git a/.github/workflows/binaries_release3.yml b/.github/workflows/binaries_release3.yml index 0bbfa3953..2ae2d9fee 100644 --- a/.github/workflows/binaries_release3.yml +++ b/.github/workflows/binaries_release3.yml @@ -31,7 +31,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` @@ -45,7 +45,7 @@ jobs: goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} overwrite: true - pre_command: export CGO_ENABLED=0 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` From 3abbaccb70f6b36cbb8f5499cbca52ff5770803a Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 11 Nov 2021 22:27:13 -0800 Subject: [PATCH 10/23] filer: fix mysql command to upsert --- weed/command/scaffold/filer.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/command/scaffold/filer.toml b/weed/command/scaffold/filer.toml index aec409408..e26aaa1c7 100644 --- a/weed/command/scaffold/filer.toml +++ b/weed/command/scaffold/filer.toml @@ -61,7 +61,7 @@ connection_max_lifetime_seconds = 0 interpolateParams = false # if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax: enableUpsert = true -upsertQuery = """INSERT INTO ` + "`%s`" + ` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)""" +upsertQuery = """INSERT INTO `%s` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)""" [mysql2] # or memsql, tidb enabled = false @@ -85,7 +85,7 @@ connection_max_lifetime_seconds = 0 interpolateParams = false # if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax: enableUpsert = true -upsertQuery = """INSERT INTO ` + "`%s`" + ` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)""" +upsertQuery = """INSERT INTO `%s` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)""" [postgres] # or cockroachdb, YugabyteDB # CREATE TABLE IF NOT EXISTS filemeta ( From 1f75f1f9dc19f74a76028420a724a4ab984c4b3d Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 11 Nov 2021 22:28:28 -0800 Subject: [PATCH 11/23] filer: fix mysql2 SQL template --- weed/command/scaffold/filer.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/command/scaffold/filer.toml b/weed/command/scaffold/filer.toml index e26aaa1c7..a56251ae7 100644 --- a/weed/command/scaffold/filer.toml +++ b/weed/command/scaffold/filer.toml @@ -66,7 +66,7 @@ upsertQuery = """INSERT INTO `%s` (dirhash,name,directory,meta) VALUES(?,?,?,?) [mysql2] # or memsql, tidb enabled = false createTable = """ - CREATE TABLE IF NOT EXISTS ` + "`%s`" + ` ( + CREATE TABLE IF NOT EXISTS `%s` ( dirhash BIGINT, name VARCHAR(1000) BINARY, directory TEXT BINARY, From 7bf891c00a8258ee40db46d302b0be1cc5a1d7d4 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 12 Nov 2021 11:30:11 -0800 Subject: [PATCH 12/23] randomize same-dc servers and other-dc servers --- weed/filer/filechunk_manifest.go | 4 ---- weed/wdclient/vid_map.go | 13 +++++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/weed/filer/filechunk_manifest.go b/weed/filer/filechunk_manifest.go index 023d9e04a..32008271b 100644 --- a/weed/filer/filechunk_manifest.go +++ b/weed/filer/filechunk_manifest.go @@ -6,7 +6,6 @@ import ( "github.com/chrislusf/seaweedfs/weed/wdclient" "io" "math" - "math/rand" "net/url" "strings" "time" @@ -143,9 +142,6 @@ func retriedStreamFetchChunkData(writer io.Writer, urlStrings []string, cipherKe var shouldRetry bool var totalWritten int - rand.Shuffle(len(urlStrings), func(i, j int) { - urlStrings[i], urlStrings[j] = urlStrings[j], urlStrings[i] - }) for waitTime := time.Second; waitTime < util.RetryWaitTime; waitTime += waitTime / 2 { for _, urlString := range urlStrings { var localProcesed int diff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.go index 670d1ad77..e0bea2a01 100644 --- a/weed/wdclient/vid_map.go +++ b/weed/wdclient/vid_map.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "github.com/chrislusf/seaweedfs/weed/pb" + "math/rand" "strconv" "strings" "sync" @@ -69,13 +70,21 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrls []string, err er if !found { return nil, fmt.Errorf("volume %d not found", id) } + var sameDcServers, otherDcServers []string for _, loc := range locations { if vc.DataCenter == "" || loc.DataCenter == "" || vc.DataCenter != loc.DataCenter { - serverUrls = append(serverUrls, loc.Url) + sameDcServers = append(sameDcServers, loc.Url) } else { - serverUrls = append([]string{loc.Url}, serverUrls...) + otherDcServers = append(otherDcServers, loc.Url) } } + rand.Shuffle(len(sameDcServers), func(i, j int) { + sameDcServers[i], sameDcServers[j] = sameDcServers[j], sameDcServers[i] + }) + rand.Shuffle(len(otherDcServers), func(i, j int) { + otherDcServers[i], otherDcServers[j] = otherDcServers[j], otherDcServers[i] + }) + serverUrls = append(sameDcServers, otherDcServers...) return } From 947fe4cc97abe1e7d166bb8efb8e01e54e09ae5c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 12 Nov 2021 17:21:49 -0800 Subject: [PATCH 13/23] docker: entry point change working directory from root to /data --- docker/Dockerfile | 1 + docker/Dockerfile.gccgo_build | 1 + docker/Dockerfile.go_build | 1 + docker/Dockerfile.go_build_large | 1 + docker/Dockerfile.local | 1 + docker/Dockerfile.rocksdb_large | 2 ++ 6 files changed, 7 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index d2c365c29..68bb6fe49 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -48,6 +48,7 @@ EXPOSE 7333 RUN mkdir -p /data/filerldb2 VOLUME /data +WORKDIR /data COPY filer.toml /etc/seaweedfs/filer.toml COPY entrypoint.sh /entrypoint.sh diff --git a/docker/Dockerfile.gccgo_build b/docker/Dockerfile.gccgo_build index e42a593cb..90cdf352f 100644 --- a/docker/Dockerfile.gccgo_build +++ b/docker/Dockerfile.gccgo_build @@ -37,6 +37,7 @@ EXPOSE 7333 RUN mkdir -p /data/filerldb2 VOLUME /data +WORKDIR /data RUN chmod +x /entrypoint.sh diff --git a/docker/Dockerfile.go_build b/docker/Dockerfile.go_build index 6354fc536..338a8e296 100644 --- a/docker/Dockerfile.go_build +++ b/docker/Dockerfile.go_build @@ -36,6 +36,7 @@ EXPOSE 7333 RUN mkdir -p /data/filerldb2 VOLUME /data +WORKDIR /data RUN chmod +x /entrypoint.sh diff --git a/docker/Dockerfile.go_build_large b/docker/Dockerfile.go_build_large index b5791bf9f..f831c4474 100644 --- a/docker/Dockerfile.go_build_large +++ b/docker/Dockerfile.go_build_large @@ -36,6 +36,7 @@ EXPOSE 7333 RUN mkdir -p /data/filerldb2 VOLUME /data +WORKDIR /data RUN chmod +x /entrypoint.sh diff --git a/docker/Dockerfile.local b/docker/Dockerfile.local index 0a85c56f0..947edffda 100644 --- a/docker/Dockerfile.local +++ b/docker/Dockerfile.local @@ -26,6 +26,7 @@ EXPOSE 7333 RUN mkdir -p /data/filerldb2 VOLUME /data +WORKDIR /data RUN chmod +x /entrypoint.sh diff --git a/docker/Dockerfile.rocksdb_large b/docker/Dockerfile.rocksdb_large index f3bc7eb7d..b5d569f44 100644 --- a/docker/Dockerfile.rocksdb_large +++ b/docker/Dockerfile.rocksdb_large @@ -54,6 +54,8 @@ RUN mkdir -p /data/filerldb2 VOLUME /data +WORKDIR /data + RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] From 100c654ec3b00783ec1cdf8fa71f31a63d584210 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 14 Nov 2021 23:29:59 -0800 Subject: [PATCH 14/23] 2.78 --- k8s/helm_charts2/Chart.yaml | 4 ++-- weed/util/constants.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s/helm_charts2/Chart.yaml b/k8s/helm_charts2/Chart.yaml index 093336674..865787463 100644 --- a/k8s/helm_charts2/Chart.yaml +++ b/k8s/helm_charts2/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 description: SeaweedFS name: seaweedfs -appVersion: "2.77" -version: "2.77" +appVersion: "2.78" +version: "2.78" diff --git a/weed/util/constants.go b/weed/util/constants.go index 012fa7eb9..f174ffe36 100644 --- a/weed/util/constants.go +++ b/weed/util/constants.go @@ -5,7 +5,7 @@ import ( ) var ( - VERSION_NUMBER = fmt.Sprintf("%.02f", 2.77) + VERSION_NUMBER = fmt.Sprintf("%.02f", 2.78) VERSION = sizeLimit + " " + VERSION_NUMBER COMMIT = "" ) From 320a08f250b59343a916dad98cfcd3015891d8ed Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 14 Nov 2021 23:45:34 -0800 Subject: [PATCH 15/23] adjust go release action version --- .github/workflows/binaries_release0.yml | 4 ++-- .github/workflows/binaries_release1.yml | 4 ++-- .github/workflows/binaries_release2.yml | 4 ++-- .github/workflows/binaries_release3.yml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/binaries_release0.yml b/.github/workflows/binaries_release0.yml index e485c8785..71e59a2aa 100644 --- a/.github/workflows/binaries_release0.yml +++ b/.github/workflows/binaries_release0.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release1.yml b/.github/workflows/binaries_release1.yml index ad546c3b4..d289fd7d4 100644 --- a/.github/workflows/binaries_release1.yml +++ b/.github/workflows/binaries_release1.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release2.yml b/.github/workflows/binaries_release2.yml index 8428a92f8..7c3a83d51 100644 --- a/.github/workflows/binaries_release2.yml +++ b/.github/workflows/binaries_release2.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release3.yml b/.github/workflows/binaries_release3.yml index 2ae2d9fee..d388c5a77 100644 --- a/.github/workflows/binaries_release3.yml +++ b/.github/workflows/binaries_release3.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.20 + uses: wangyoucao577/go-release-action@bugfix/upload-fail with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} From 791aa3cb44d6aa9143c59b61cd2ac36cda246824 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 15 Nov 2021 08:33:46 -0800 Subject: [PATCH 16/23] update to wangyoucao577/go-release-action@v1.21 --- .github/workflows/binaries_dev.yml | 8 ++++---- .github/workflows/binaries_release0.yml | 4 ++-- .github/workflows/binaries_release1.yml | 4 ++-- .github/workflows/binaries_release2.yml | 4 ++-- .github/workflows/binaries_release3.yml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index 2fa4cbfee..978eadba5 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -37,7 +37,7 @@ jobs: run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV} - name: Go Release Binaries Large Disk - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -53,7 +53,7 @@ jobs: asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}" - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -84,7 +84,7 @@ jobs: run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV} - name: Go Release Binaries Large Disk - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -100,7 +100,7 @@ jobs: asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}" - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release0.yml b/.github/workflows/binaries_release0.yml index 71e59a2aa..98ac480f7 100644 --- a/.github/workflows/binaries_release0.yml +++ b/.github/workflows/binaries_release0.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release1.yml b/.github/workflows/binaries_release1.yml index d289fd7d4..67e7020cf 100644 --- a/.github/workflows/binaries_release1.yml +++ b/.github/workflows/binaries_release1.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release2.yml b/.github/workflows/binaries_release2.yml index 7c3a83d51..fb7f5fdef 100644 --- a/.github/workflows/binaries_release2.yml +++ b/.github/workflows/binaries_release2.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release3.yml b/.github/workflows/binaries_release3.yml index d388c5a77..2215ae970 100644 --- a/.github/workflows/binaries_release3.yml +++ b/.github/workflows/binaries_release3.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@bugfix/upload-fail + uses: wangyoucao577/go-release-action@v1.21 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} From a0ef6e36110bce5ec28df704b88b5c1e9ca588ba Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 15 Nov 2021 08:46:01 -0800 Subject: [PATCH 17/23] prevent nil response fix https://github.com/chrislusf/seaweedfs/issues/2452 --- weed/server/volume_grpc_copy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/server/volume_grpc_copy.go b/weed/server/volume_grpc_copy.go index 9630b322e..9d9f756ce 100644 --- a/weed/server/volume_grpc_copy.go +++ b/weed/server/volume_grpc_copy.go @@ -226,7 +226,7 @@ func writeToFile(client volume_server_pb.VolumeServer_CopyFileClient, fileName s if receiveErr == io.EOF { break } - if resp.ModifiedTsNs != 0 { + if resp!=nil && resp.ModifiedTsNs != 0 { modifiedTsNs = resp.ModifiedTsNs } if receiveErr != nil { From 3d87aa767da1f5ae1b06c76676e26d507e9ee6e7 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 16 Nov 2021 09:14:01 -0800 Subject: [PATCH 18/23] fix same dc and other dc --- weed/wdclient/vid_map.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.go index e0bea2a01..0effa2262 100644 --- a/weed/wdclient/vid_map.go +++ b/weed/wdclient/vid_map.go @@ -73,9 +73,9 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrls []string, err er var sameDcServers, otherDcServers []string for _, loc := range locations { if vc.DataCenter == "" || loc.DataCenter == "" || vc.DataCenter != loc.DataCenter { - sameDcServers = append(sameDcServers, loc.Url) - } else { otherDcServers = append(otherDcServers, loc.Url) + } else { + sameDcServers = append(sameDcServers, loc.Url) } } rand.Shuffle(len(sameDcServers), func(i, j int) { From 40abae7caa64d766b6eceab4f51106121b675523 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev Date: Wed, 17 Nov 2021 14:42:24 +0500 Subject: [PATCH 19/23] Avoid forbiddening for HeadBucketHandler if owners are specified https://github.com/chrislusf/seaweedfs/issues/2434 --- weed/s3api/s3api_bucket_handlers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index e8ca20cb0..b932edbac 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -177,8 +177,8 @@ func (s3a *S3ApiServer) HeadBucketHandler(w http.ResponseWriter, r *http.Request bucket, _ := getBucketAndObject(r) glog.V(3).Infof("HeadBucketHandler %s", bucket) - if err := s3a.checkBucket(r, bucket); err != s3err.ErrNone { - s3err.WriteErrorResponse(w, r, err) + if entry, err := s3a.getEntry(s3a.option.BucketsPath, bucket); entry == nil || err == filer_pb.ErrNotFound { + s3err.WriteErrorResponse(w, r, s3err.ErrNoSuchBucket) return } From f3c789d662eeab2dcc07804cbb665752b3870d65 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 21 Nov 2021 18:40:24 -0800 Subject: [PATCH 20/23] 2.79 --- k8s/helm_charts2/Chart.yaml | 4 ++-- weed/util/constants.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s/helm_charts2/Chart.yaml b/k8s/helm_charts2/Chart.yaml index 865787463..6a8b7e5ea 100644 --- a/k8s/helm_charts2/Chart.yaml +++ b/k8s/helm_charts2/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 description: SeaweedFS name: seaweedfs -appVersion: "2.78" -version: "2.78" +appVersion: "2.79" +version: "2.79" diff --git a/weed/util/constants.go b/weed/util/constants.go index f174ffe36..3513d1669 100644 --- a/weed/util/constants.go +++ b/weed/util/constants.go @@ -5,7 +5,7 @@ import ( ) var ( - VERSION_NUMBER = fmt.Sprintf("%.02f", 2.78) + VERSION_NUMBER = fmt.Sprintf("%.02f", 2.79) VERSION = sizeLimit + " " + VERSION_NUMBER COMMIT = "" ) From 01558a0bd5dbe4681d00d93d824d3722c2f3dbd9 Mon Sep 17 00:00:00 2001 From: zer0def Date: Tue, 28 Sep 2021 14:08:54 +0200 Subject: [PATCH 21/23] Update resource API versions up to K8S 1.22 --- k8s/helm_charts2/templates/ingress.yaml | 90 ++++++++++--------- .../templates/service-account.yaml | 6 +- k8s/helm_charts2/values.yaml | 40 +++++++++ 3 files changed, 91 insertions(+), 45 deletions(-) diff --git a/k8s/helm_charts2/templates/ingress.yaml b/k8s/helm_charts2/templates/ingress.yaml index 4f1b4251d..f488ef67e 100644 --- a/k8s/helm_charts2/templates/ingress.yaml +++ b/k8s/helm_charts2/templates/ingress.yaml @@ -1,61 +1,67 @@ +{{- if .Values.filer.ingress.enabled }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: networking.k8s.io/v1beta1 +{{- else }} apiVersion: extensions/v1beta1 +{{- end }} kind: Ingress metadata: - name: ingress-{{ template "seaweedfs.name" . }}-filer - namespace: {{ .Release.Namespace }} - annotations: - kubernetes.io/ingress.class: "nginx" - nginx.ingress.kubernetes.io/auth-type: "basic" - nginx.ingress.kubernetes.io/auth-secret: "default/ingress-basic-auth-secret" - nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - SW-Filer' - nginx.ingress.kubernetes.io/service-upstream: "true" - nginx.ingress.kubernetes.io/rewrite-target: /$1 - nginx.ingress.kubernetes.io/use-regex: "true" - nginx.ingress.kubernetes.io/enable-rewrite-log: "true" - nginx.ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/force-ssl-redirect: "false" - nginx.ingress.kubernetes.io/configuration-snippet: | - sub_filter '' ' '; #add base url - sub_filter '="/' '="./'; #make absolute paths to relative - sub_filter '=/' '=./'; - sub_filter '/seaweedfsstatic' './seaweedfsstatic'; - sub_filter_once off; + name: ingress-{{ template "seaweedfs.name" . }}-filer + namespace: {{ .Release.Namespace }} + annotations: + {{ omit .Values.filer.ingress.annotations "kubernetes.io/ingress.class" | toYaml | nindent 4 }} spec: - rules: - - http: - paths: - - path: /sw-filer/?(.*) - backend: - serviceName: {{ template "seaweedfs.name" . }}-filer - servicePort: {{ .Values.filer.port }} + ingressClassName: {{ .Values.filer.ingress.className | quote }} + rules: + - http: + paths: + - path: /sw-filer/?(.*) + pathType: ImplementationSpecific + backend: +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + service: + name: {{ template "seaweedfs.name" . }}-filer + port: + number: {{ .Values.filer.port }} + #name: +{{- else }} + serviceName: {{ template "seaweedfs.name" . }}-filer + servicePort: {{ .Values.filer.port }} +{{- end }} +{{- end }} --- +{{- if .Values.master.ingress.enabled }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: networking.k8s.io/v1beta1 +{{- else }} apiVersion: extensions/v1beta1 +{{- end }} kind: Ingress metadata: name: ingress-{{ template "seaweedfs.name" . }}-master namespace: {{ .Release.Namespace }} annotations: - kubernetes.io/ingress.class: "nginx" - nginx.ingress.kubernetes.io/auth-type: "basic" - nginx.ingress.kubernetes.io/auth-secret: "default/ingress-basic-auth-secret" - nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - SW-Master' - nginx.ingress.kubernetes.io/service-upstream: "true" - nginx.ingress.kubernetes.io/rewrite-target: /$1 - nginx.ingress.kubernetes.io/use-regex: "true" - nginx.ingress.kubernetes.io/enable-rewrite-log: "true" - nginx.ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/force-ssl-redirect: "false" - nginx.ingress.kubernetes.io/configuration-snippet: | - sub_filter '' ' '; #add base url - sub_filter '="/' '="./'; #make absolute paths to relative - sub_filter '=/' '=./'; - sub_filter '/seaweedfsstatic' './seaweedfsstatic'; - sub_filter_once off; + {{ omit .Values.master.ingress.annotations "kubernetes.io/ingress.class" | toYaml | nindent 4 }} spec: + ingressClassName: {{ .Values.master.ingress.className | quote }} rules: - http: paths: - path: /sw-master/?(.*) + pathType: ImplementationSpecific backend: +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} + service: + name: {{ template "seaweedfs.name" . }}-master + port: + number: {{ .Values.master.port }} + #name: +{{- else }} serviceName: {{ template "seaweedfs.name" . }}-master servicePort: {{ .Values.master.port }} +{{- end }} +{{- end }} diff --git a/k8s/helm_charts2/templates/service-account.yaml b/k8s/helm_charts2/templates/service-account.yaml index e82ef7d62..978452ca4 100644 --- a/k8s/helm_charts2/templates/service-account.yaml +++ b/k8s/helm_charts2/templates/service-account.yaml @@ -1,7 +1,7 @@ #hack for delete pod master after migration --- kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: seaweefds-rw-cr rules: @@ -16,7 +16,7 @@ metadata: namespace: {{ .Release.Namespace }} --- kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: system:serviceaccount:seaweefds-rw-sa:default subjects: @@ -26,4 +26,4 @@ subjects: roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: seaweefds-rw-cr \ No newline at end of file + name: seaweefds-rw-cr diff --git a/k8s/helm_charts2/values.yaml b/k8s/helm_charts2/values.yaml index bd8a9f0e4..52d8c8eb6 100644 --- a/k8s/helm_charts2/values.yaml +++ b/k8s/helm_charts2/values.yaml @@ -109,6 +109,26 @@ master: # ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ priorityClassName: "" + ingress: + enabled: false + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/auth-type: "basic" + nginx.ingress.kubernetes.io/auth-secret: "default/ingress-basic-auth-secret" + nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - SW-Master' + nginx.ingress.kubernetes.io/service-upstream: "true" + nginx.ingress.kubernetes.io/rewrite-target: /$1 + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/enable-rewrite-log: "true" + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/force-ssl-redirect: "false" + nginx.ingress.kubernetes.io/configuration-snippet: | + sub_filter '' ' '; #add base url + sub_filter '="/' '="./'; #make absolute paths to relative + sub_filter '=/' '=./'; + sub_filter '/seaweedfsstatic' './seaweedfsstatic'; + sub_filter_once off; + extraEnvironmentVars: WEED_MASTER_VOLUME_GROWTH_COPY_1: 7 WEED_MASTER_VOLUME_GROWTH_COPY_2: 6 @@ -309,6 +329,26 @@ filer: # ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ priorityClassName: "" + ingress: + enabled: false + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/auth-type: "basic" + nginx.ingress.kubernetes.io/auth-secret: "default/ingress-basic-auth-secret" + nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - SW-Filer' + nginx.ingress.kubernetes.io/service-upstream: "true" + nginx.ingress.kubernetes.io/rewrite-target: /$1 + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/enable-rewrite-log: "true" + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/force-ssl-redirect: "false" + nginx.ingress.kubernetes.io/configuration-snippet: | + sub_filter '' ' '; #add base url + sub_filter '="/' '="./'; #make absolute paths to relative + sub_filter '=/' '=./'; + sub_filter '/seaweedfsstatic' './seaweedfsstatic'; + sub_filter_once off; + # extraEnvVars is a list of extra enviroment variables to set with the stateful set. extraEnvironmentVars: WEED_MYSQL_ENABLED: "true" From 6c27845be074d2342b85fc99cb9dda6966e0bb0b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 22 Nov 2021 21:48:00 -0800 Subject: [PATCH 22/23] add retries when writing to remote s3 fix https://github.com/chrislusf/seaweedfs/issues/2465 --- weed/command/filer_remote_gateway_buckets.go | 11 +++------- weed/command/filer_remote_sync_dir.go | 21 +++++++++++++++----- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/weed/command/filer_remote_gateway_buckets.go b/weed/command/filer_remote_gateway_buckets.go index bd3e76859..d70e96904 100644 --- a/weed/command/filer_remote_gateway_buckets.go +++ b/weed/command/filer_remote_gateway_buckets.go @@ -199,8 +199,7 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour return client.WriteDirectory(dest, message.NewEntry) } glog.V(0).Infof("create %s", remote_storage.FormatLocation(dest)) - reader := filer.NewFileReader(filerSource, message.NewEntry) - remoteEntry, writeErr := client.WriteFile(dest, message.NewEntry, reader) + remoteEntry, writeErr := retriedWriteFile(client, filerSource, message.NewEntry, dest) if writeErr != nil { return writeErr } @@ -264,9 +263,7 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour return client.UpdateFileMetadata(oldDest, message.OldEntry, message.NewEntry) } else { newDest := toRemoteStorageLocation(newBucket, util.NewFullPath(message.NewParentPath, message.NewEntry.Name), newRemoteStorageMountLocation) - reader := filer.NewFileReader(filerSource, message.NewEntry) - glog.V(0).Infof("create %s", remote_storage.FormatLocation(newDest)) - remoteEntry, writeErr := client.WriteFile(newDest, message.NewEntry, reader) + remoteEntry, writeErr := retriedWriteFile(client, filerSource, message.NewEntry, newDest) if writeErr != nil { return writeErr } @@ -303,9 +300,7 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour if message.NewEntry.IsDirectory { return client.WriteDirectory(newDest, message.NewEntry) } - reader := filer.NewFileReader(filerSource, message.NewEntry) - glog.V(0).Infof("create %s", remote_storage.FormatLocation(newDest)) - remoteEntry, writeErr := client.WriteFile(newDest, message.NewEntry, reader) + remoteEntry, writeErr := retriedWriteFile(client, filerSource, message.NewEntry, newDest) if writeErr != nil { return writeErr } diff --git a/weed/command/filer_remote_sync_dir.go b/weed/command/filer_remote_sync_dir.go index 8ff933833..e24c8f9e6 100644 --- a/weed/command/filer_remote_sync_dir.go +++ b/weed/command/filer_remote_sync_dir.go @@ -108,8 +108,7 @@ func makeEventProcessor(remoteStorage *remote_pb.RemoteConf, mountedDir string, return client.WriteDirectory(dest, message.NewEntry) } glog.V(0).Infof("create %s", remote_storage.FormatLocation(dest)) - reader := filer.NewFileReader(filerSource, message.NewEntry) - remoteEntry, writeErr := client.WriteFile(dest, message.NewEntry, reader) + remoteEntry, writeErr := retriedWriteFile(client, filerSource, message.NewEntry, dest) if writeErr != nil { return writeErr } @@ -146,9 +145,7 @@ func makeEventProcessor(remoteStorage *remote_pb.RemoteConf, mountedDir string, if err := client.DeleteFile(oldDest); err != nil { return err } - reader := filer.NewFileReader(filerSource, message.NewEntry) - glog.V(0).Infof("create %s", remote_storage.FormatLocation(dest)) - remoteEntry, writeErr := client.WriteFile(dest, message.NewEntry, reader) + remoteEntry, writeErr := retriedWriteFile(client, filerSource, message.NewEntry, dest) if writeErr != nil { return writeErr } @@ -160,6 +157,20 @@ func makeEventProcessor(remoteStorage *remote_pb.RemoteConf, mountedDir string, return eachEntryFunc, nil } +func retriedWriteFile(client remote_storage.RemoteStorageClient, filerSource *source.FilerSource, newEntry *filer_pb.Entry, dest *remote_pb.RemoteStorageLocation) (remoteEntry *filer_pb.RemoteEntry, err error) { + var writeErr error + err = util.Retry("writeFile", func() error { + reader := filer.NewFileReader(filerSource, newEntry) + glog.V(0).Infof("create %s", remote_storage.FormatLocation(dest)) + remoteEntry, writeErr = client.WriteFile(dest, newEntry, reader) + if writeErr != nil { + return writeErr + } + return nil + }) + return +} + func collectLastSyncOffset(filerClient filer_pb.FilerClient, grpcDialOption grpc.DialOption, filerAddress pb.ServerAddress, mountedDir string, timeAgo time.Duration) time.Time { // 1. specified by timeAgo // 2. last offset timestamp for this directory From da1c755f6ac4ea0a53c3f6f7b83b4115468e1887 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 23 Nov 2021 07:39:43 -0800 Subject: [PATCH 23/23] fix build issue fix https://github.com/wangyoucao577/go-release-action/issues/66 --- .github/workflows/binaries_dev.yml | 8 ++++---- .github/workflows/binaries_release0.yml | 4 ++-- .github/workflows/binaries_release1.yml | 4 ++-- .github/workflows/binaries_release2.yml | 4 ++-- .github/workflows/binaries_release3.yml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index 978eadba5..5b34b5f4b 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -37,7 +37,7 @@ jobs: run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV} - name: Go Release Binaries Large Disk - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -53,7 +53,7 @@ jobs: asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}" - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -84,7 +84,7 @@ jobs: run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV} - name: Go Release Binaries Large Disk - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -100,7 +100,7 @@ jobs: asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}" - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release0.yml b/.github/workflows/binaries_release0.yml index 98ac480f7..14302dac0 100644 --- a/.github/workflows/binaries_release0.yml +++ b/.github/workflows/binaries_release0.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release1.yml b/.github/workflows/binaries_release1.yml index 67e7020cf..326a551cb 100644 --- a/.github/workflows/binaries_release1.yml +++ b/.github/workflows/binaries_release1.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release2.yml b/.github/workflows/binaries_release2.yml index fb7f5fdef..bc3b7b4fa 100644 --- a/.github/workflows/binaries_release2.yml +++ b/.github/workflows/binaries_release2.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} diff --git a/.github/workflows/binaries_release3.yml b/.github/workflows/binaries_release3.yml index 2215ae970..4baae2c9f 100644 --- a/.github/workflows/binaries_release3.yml +++ b/.github/workflows/binaries_release3.yml @@ -25,7 +25,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Go Release Binaries Normal Volume Size - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} @@ -39,7 +39,7 @@ jobs: binary_name: weed asset_name: "${{ matrix.goos }}_${{ matrix.goarch }}" - name: Go Release Large Disk Binaries - uses: wangyoucao577/go-release-action@v1.21 + uses: wangyoucao577/go-release-action@v1.22 with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }}