From e8ba79aae6e14f5b70daf30febf3e31bbf795a58 Mon Sep 17 00:00:00 2001 From: Howard Lau Date: Fri, 30 Oct 2020 09:15:16 +0000 Subject: [PATCH 1/4] add filer peers on filer startup Signed-off-by: Howard Lau --- controllers/controller_filer_statefulset.go | 1 + controllers/helper.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/controllers/controller_filer_statefulset.go b/controllers/controller_filer_statefulset.go index 5de5557..71ae7ec 100644 --- a/controllers/controller_filer_statefulset.go +++ b/controllers/controller_filer_statefulset.go @@ -16,6 +16,7 @@ func buildFilerStartupScript(m *seaweedv1.Seaweed) string { commands := []string{"weed", "filer"} commands = append(commands, fmt.Sprintf("-port=%d", seaweedv1.FilerHTTPPort)) commands = append(commands, fmt.Sprintf("-ip=$(POD_NAME).%s-filer-peer", m.Name)) + commands = append(commands, fmt.Sprintf("-peers=%s", getFilerPeersString(m.Name, m.Spec.Volume.Replicas))) commands = append(commands, fmt.Sprintf("-master=%s", getMasterPeersString(m.Name, m.Spec.Master.Replicas))) commands = append(commands, "-s3") diff --git a/controllers/helper.go b/controllers/helper.go index 12b7c6b..e00695a 100644 --- a/controllers/helper.go +++ b/controllers/helper.go @@ -10,6 +10,7 @@ import ( const ( masterPeerAddressPattern = "%s-master-%d.%s-master-peer:9333" + filerPeerAddressPattern = "%s-filer-%d.%s-filer-peer:9333" masterPeerAddressWithNamespacePattern = "%s-master-%d.%s-master-peer.%s:9333" filerServiceAddressWithNamespacePattern = "%s-filer.%s:8888" masterServiceAddressWithNamespacePattern = "%s-master.%s:9333" @@ -51,6 +52,18 @@ func ReconcileResult(err error) (bool, ctrl.Result, error) { return false, ctrl.Result{}, nil } +func getFilerAddresses(name string, replicas int32) []string { + peersAddresses := make([]string, 0, replicas) + for i := int32(0); i < replicas; i++ { + peersAddresses = append(peersAddresses, fmt.Sprintf(filerPeerAddressPattern, name, i, name)) + } + return peersAddresses +} + +func getFilerPeersString(name string, replicas int32) string { + return strings.Join(getFilerAddresses(name, replicas), ",") +} + func getMasterAddresses(name string, replicas int32) []string { peersAddresses := make([]string, 0, replicas) for i := int32(0); i < replicas; i++ { @@ -62,6 +75,7 @@ func getMasterAddresses(name string, replicas int32) []string { func getMasterPeersString(name string, replicas int32) string { return strings.Join(getMasterAddresses(name, replicas), ",") } + func getMasterAddressesWithNamespace(name, namespace string, replicas int32) []string { peersAddresses := make([]string, 0, replicas) for i := int32(0); i < replicas; i++ { From a9ea14b3998bb93d55eb7b7ec1b79ef21f0894c1 Mon Sep 17 00:00:00 2001 From: Howard Lau Date: Fri, 30 Oct 2020 09:23:54 +0000 Subject: [PATCH 2/4] fix port Signed-off-by: Howard Lau --- controllers/helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/helper.go b/controllers/helper.go index e00695a..f449876 100644 --- a/controllers/helper.go +++ b/controllers/helper.go @@ -10,7 +10,7 @@ import ( const ( masterPeerAddressPattern = "%s-master-%d.%s-master-peer:9333" - filerPeerAddressPattern = "%s-filer-%d.%s-filer-peer:9333" + filerPeerAddressPattern = "%s-filer-%d.%s-filer-peer:8888" masterPeerAddressWithNamespacePattern = "%s-master-%d.%s-master-peer.%s:9333" filerServiceAddressWithNamespacePattern = "%s-filer.%s:8888" masterServiceAddressWithNamespacePattern = "%s-master.%s:9333" From 034a36489dfc65642547bd4aac5d255bf776b203 Mon Sep 17 00:00:00 2001 From: Howard Lau Date: Fri, 30 Oct 2020 15:55:35 +0000 Subject: [PATCH 3/4] Add golangci-lint Signed-off-by: Howard Lau --- .github/workflows/lint.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3622390 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,29 @@ +name: Lint +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + golangci: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.31 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # TODO: remove disabled + args: -D errcheck -D deadcode -D unused + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true From 6ae2bba4755419d4de71e96327da67a0847b21d9 Mon Sep 17 00:00:00 2001 From: Howard Lau Date: Fri, 30 Oct 2020 15:59:29 +0000 Subject: [PATCH 4/4] Increase lint timeout Signed-off-by: Howard Lau --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3622390..0d0fd94 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,7 +23,7 @@ jobs: # Optional: golangci-lint command line arguments. # TODO: remove disabled - args: -D errcheck -D deadcode -D unused + args: --timeout=10m -D errcheck -D deadcode -D unused # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true