feat(seaweedfs): bump chart to 4.48 and backport Gateway API HTTPRoutes (#4879)

## What this PR does

This adds Gateway API HTTPRoutes for the SeaweedFS S3 endpoint and the
filer, as groundwork for moving tenant ingress to Gateway API (#4788).
This builds on #4893, which is now merged and keeps Object Lock working
for COSI credentials once SeaweedFS is on 4.48. Nothing is switched.
Both routes are off by default, and the route commit leaves the rendered
release unchanged.

The chart is bumped from 4.45 to 4.48 first, together with the in-tree
SeaweedFS image, so the patched binary matches the chart. Every carried
chart patch still applies. `s3-grpc-tls.patch` is dropped because 4.48
ships the same `[grpc.s3]` section. The in-tree image also drops
`volume-layout-crowded-lock.diff` from main. 4.48 already has that fix
(seaweedfs/seaweedfs#11216), so the patch no longer applies. CI rebuilds
the in-tree image and stamps its digest into the E2E and installer
artifacts.

The image also fixes peer discovery during startup. Peer changes could
be lost between the bootstrap scan and consumer setup, leaving S3
gateways subscribed to only one filer's metadata. Before the reconnect
fix I checked a CI image binary for the handoff and bootstrap replay
floor. The image for this head has not been checked that way.

The checked-in image ref is from an earlier build. Main and
release-candidate builds rebuild SeaweedFS and stamp its actual ref into
the packages before publication. To get this fix from a chart installed
straight from git, build the image first.

With this package's values, the render changes only in image references,
chart labels and new `checksum/*` annotations on master and s3 pods, so
those pods roll once on upgrade. With lifecycle enabled, the admin
container also gets an explicit `-ip=0.0.0.0`. Names, selectors and
volumeClaimTemplates stay the same. Suites that render master or s3 now
list the templates the checksum annotations include, because
helm-unittest only loads the templates a suite names.

The routes come from upstream commit seaweedfs/seaweedfs@68af030e38,
first released in 4.49. This package stays on 4.48, so they arrive as a
new patch. Only the s3 and filer routes and their values are taken. One
line differs from upstream on purpose. The s3 route's default backend is
`<name>-s3`, built from `seaweedfs.name` like the Service that
`s3-service-name.patch` renders. Upstream uses `componentName`, which
matches that Service only while the fullname equals `seaweedfs.name`, so
the new tests override `fullnameOverride` and fail on upstream's form.

The patch is temporary. Drop `patches/httproute-backport.patch` and its
Makefile line when bumping to 4.49 or later. From that release on, `make
update` fails on the patch, because it creates both templates. Before
dropping it, move the s3 backend name change into
`s3-service-name-consumers.patch` and the BackendTLSPolicy note into
`s3-tls-main-port.patch`. Upstream also ships master, volume and admin
routes, which I left out on purpose. The patch header carries the same
note.

Enabling the s3 route needs one more thing. With security on and no
`httpsPort`, the standalone s3 gateway serves TLS on its main port
(`s3-tls-main-port.patch`), so the Gateway needs a BackendTLSPolicy to
reach it. The chart does not render one, and a note next to
`s3.httpRoute` says so.

Extracting the chart from the 4.48 source archive and applying the
patches in `make update` order reproduces the committed `charts/` byte
for byte. Both in-tree image patches apply to the 4.48 source, and the
chart tests pass.

The tests reproduce peer changes lost during startup, and a peer kept
from an earlier master stream after a reconnect. With the current
patches, the filer, wdclient and server suites and focused race checks
pass on Linux. Before the reconnect fix I tested a native build with two
filers, shared PostgreSQL and two S3 gateways. Both filers returned the
identities, and both gateways accepted valid keys and rejected an
unknown key. These checks do not cover COSI driver RPCs or establish the
original failed run's persisted IAM state.

The E2E run on 79f2cfe passed all 33 cases, including Kafka metadata
backup. It does not validate the image for this head.

The earlier human review threads are answered. The PR needs a fresh
review after this update.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
feat(seaweedfs): bump the vendored SeaweedFS chart and the in-tree image to 4.48 and add opt-in Gateway API HTTPRoutes for the S3 endpoint and the filer (`s3.httpRoute`, `filer.httpRoute`, both disabled by default). Existing exposure does not change. Fix lost peer discovery during filer startup.
```



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added configurable Gateway API HTTP routes for filer and S3 services.
* Added configurable labels for ingress resources and support for
combining global and component pod annotations.
* Added admin address configuration with authentication checks for
non-loopback bindings.
  * Updated SeaweedFS to version 4.48.
* **Bug Fixes**
  * Improved pod rollouts when master or S3 configuration changes.
  * Expanded read-only S3 credentials to allow listing.
  * Improved filer handling of peer updates during startup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-11-23 14:45:08 +03:00
commit 7a2d532d16
38 files changed
+1393 -169

No files matched your search

+1 -5
View File
@@ -61,12 +61,8 @@ update:
patch --no-backup-if-mismatch -p4 < patches/s3-service-name.patch
patch --no-backup-if-mismatch -p4 < patches/s3-service-name-consumers.patch
patch --no-backup-if-mismatch -p4 < patches/cluster-scoped-names-per-namespace.patch
# Backport of seaweedfs/seaweedfs#11157, released in 4.46: drop the patch
# once the vendored chart carries [grpc.s3]. --forward makes that point
# fail here, where BSD patch would otherwise reverse it and remove the
# section without an error.
patch --forward --no-backup-if-mismatch -p4 < patches/s3-grpc-tls.patch
patch --forward --no-backup-if-mismatch -p4 < patches/storage-class-string.patch
patch --forward --no-backup-if-mismatch -p4 < patches/httproute-backport.patch
#patch --no-backup-if-mismatch -p4 < patches/retention-policy-delete.yaml
$(MAKE) update-image
@@ -1,6 +1,6 @@
apiVersion: v1
description: SeaweedFS
name: seaweedfs
appVersion: "4.45"
appVersion: "4.48"
# Dev note: Trigger a helm chart release by `git tag -a helm-<version>`
version: 4.45.0
version: 4.48.0
@@ -286,7 +286,7 @@ metadata:
app.kubernetes.io/component: s3
stringData:
# this key must be an inline json config file
seaweedfs_s3_config: '{"identities":[{"name":"anvAdmin","credentials":[{"accessKey":"snu8yoP6QAlY0ne4","secretKey":"PNzBcmeLNEdR0oviwm04NQAicOrDH1Km"}],"actions":["Admin","Read","Write"]},{"name":"anvReadOnly","credentials":[{"accessKey":"SCigFee6c5lbi04A","secretKey":"kgFhbT38R8WUYVtiFQ1OiSVOrYr3NKku"}],"actions":["Read"]}]}'
seaweedfs_s3_config: '{"identities":[{"name":"anvAdmin","credentials":[{"accessKey":"snu8yoP6QAlY0ne4","secretKey":"PNzBcmeLNEdR0oviwm04NQAicOrDH1Km"}],"actions":["Admin","Read","Write"]},{"name":"anvReadOnly","credentials":[{"accessKey":"SCigFee6c5lbi04A","secretKey":"kgFhbT38R8WUYVtiFQ1OiSVOrYr3NKku"}],"actions":["Read","List"]}]}'
```
#### Source S3 credentials from an existing Secret
@@ -363,6 +363,30 @@ If `adminPassword` is empty or not set, the admin interface runs without authent
As an alternative, a kubernetes Secret can be used (`admin.secret.existingSecret`).
### Admin listen address
Since SeaweedFS 4.46, `weed admin` defaults to listening on loopback (`127.0.0.1`).
The chart's httpGet readiness/liveness probes dial the pod IP, so the admin
server must bind a non-loopback address for the probes to succeed. The chart
therefore passes `-ip={{ .Values.admin.ip }}`, defaulting `admin.ip` to `0.0.0.0`
(the pre-4.46 behaviour of listening on all interfaces).
Binding a non-loopback address requires authentication: `weed admin` refuses to
start on a non-loopback address without `-adminPassword`, so the chart fails at
render time if `admin.ip` is non-loopback and authentication is not configured via
`admin.secret.adminPassword`, `admin.secret.existingSecret`, or
`WEED_ADMIN_PASSWORD` supplied through `admin.extraEnvironmentVars` /
`admin.secretExtraEnvironmentVars`. Setting `admin.allowInsecureBind` renders
`-allowInsecureBind` and bypasses this guard; it leaves the admin API
unauthenticated on the network, so use it only when access is otherwise
restricted (e.g. network policies). The whole `127.0.0.0/8` range and `::1` are
treated as loopback (matching `weed admin`); `localhost` is treated as
non-loopback. Set `admin.ip` to a loopback address only if you also replace the
httpGet probes (e.g. with an `exec` probe that checks `127.0.0.1`).
The `-ip` flag requires SeaweedFS 4.46 or newer; pinning `admin.imageOverride`
to an older image is not supported with this chart version.
### Admin Data Persistence
The admin component can store configuration and maintenance data. You can configure storage in several ways:
@@ -0,0 +1,7 @@
# Admin install: exercises the admin StatefulSet, which passes -ip (default
# 0.0.0.0) and therefore requires authentication to bind a non-loopback address.
admin:
enabled: true
secret:
adminUser: "admin"
adminPassword: "ci-admin-password"
@@ -23,6 +23,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: admin
{{- with .Values.admin.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) .Values.admin.ingress.className }}
ingressClassName: {{ .Values.admin.ingress.className | quote }}
@@ -6,6 +6,11 @@
{{- if and (not .Values.admin.masters) (not .Values.global.seaweedfs.masterServer) (not .Values.master.enabled) }}
{{- fail "admin.masters or global.seaweedfs.masterServer must be set if master.enabled is false" -}}
{{- end }}
{{- $adminAuthEnabled := include "seaweedfs.admin.authEnabled" . }}
{{- $adminIp := .Values.admin.ip | default "0.0.0.0" }}
{{- if and (not (include "seaweedfs.admin.isLoopbackIp" $adminIp)) (ne $adminAuthEnabled "true") }}
{{- fail (printf "admin.ip is set to %q (non-loopback) but admin authentication is not configured. Since `weed admin` 4.46 refuses to bind a non-loopback address without authentication, the admin container would exit on startup. Set admin.secret.adminPassword or admin.secret.existingSecret, or supply WEED_ADMIN_PASSWORD via admin.extraEnvironmentVars / admin.secretExtraEnvironmentVars, or set admin.ip to a loopback address such as 127.0.0.1 (note: a loopback bind makes the chart's httpGet readiness/liveness probes fail), or set admin.allowInsecureBind to true to opt out via -allowInsecureBind (INSECURE: exposes the admin API unauthenticated on the network)." $adminIp) -}}
{{- end }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
@@ -162,6 +167,7 @@ spec:
-v={{ .Values.global.seaweedfs.loggingLevel }} \
{{- end }}
admin \
-ip={{ .Values.admin.ip | default "0.0.0.0" }} \
-port={{ .Values.admin.port }} \
-port.grpc={{ .Values.admin.grpcPort }} \
{{- if or (eq .Values.admin.data.type "hostPath") (eq .Values.admin.data.type "persistentVolumeClaim") (eq .Values.admin.data.type "emptyDir") (eq .Values.admin.data.type "existingClaim") }}
@@ -170,14 +176,17 @@ spec:
-dataDir={{ .Values.admin.dataDir }} \
{{- end }}
{{- if .Values.admin.masters }}
-masters={{ .Values.admin.masters }}{{- if or $urlPrefix .Values.admin.extraArgs }} \{{ end }}
-masters={{ .Values.admin.masters }} \
{{- else if .Values.global.seaweedfs.masterServer }}
-masters={{ .Values.global.seaweedfs.masterServer }}{{- if or $urlPrefix .Values.admin.extraArgs }} \{{ end }}
-masters={{ .Values.global.seaweedfs.masterServer }} \
{{- else }}
-masters={{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master.{{ $.Release.Namespace }}:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }}{{- if or $urlPrefix .Values.admin.extraArgs }} \{{ end }}
-masters={{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master.{{ $.Release.Namespace }}:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }} \
{{- end }}
{{- if $urlPrefix }}
-urlPrefix={{ $urlPrefix }}{{- if .Values.admin.extraArgs }} \{{ end }}
-urlPrefix={{ $urlPrefix }} \
{{- end }}
{{- if .Values.admin.allowInsecureBind }}
-allowInsecureBind \
{{- end }}
{{- range $index, $arg := .Values.admin.extraArgs }}
{{ $arg }}{{- if lt $index (sub (len $.Values.admin.extraArgs) 1) }} \{{ end }}
@@ -37,13 +37,17 @@ spec:
{{- with .Values.allInOne.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.allInOne.podAnnotations | default dict) }}
{{- $existingS3ConfigSecret := or .Values.allInOne.s3.existingConfigSecret .Values.s3.existingConfigSecret .Values.filer.s3.existingConfigSecret }}
{{- if $existingS3ConfigSecret }}
{{- $configSecret := (lookup "v1" "Secret" .Release.Namespace $existingS3ConfigSecret) | default dict }}
{{- $_ := set $podAnnotations "checksum/s3config" ($configSecret | toYaml | sha256sum) }}
{{- else }}
{{- $_ := set $podAnnotations "checksum/s3config" (include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum) }}
{{- end }}
{{- $_ := set $podAnnotations "checksum/master-config" (include (print .Template.BasePath "/master/master-configmap.yaml") . | sha256sum) }}
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.allInOne.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- toYaml $podAnnotations | nindent 8 }}
spec:
restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.allInOne.restartPolicy }}
{{- if .Values.allInOne.affinity }}
@@ -24,6 +24,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: filer
{{- with .Values.filer.ingresses.grpc.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if $securityEnabled }}
tls:
@@ -0,0 +1,57 @@
{{- $filerEnabled := or .Values.filer.enabled .Values.allInOne.enabled }}
{{- if and $filerEnabled .Values.filer.httpRoute.enabled }}
{{- $serviceName := ternary (include "seaweedfs.componentName" (list . "all-in-one")) (include "seaweedfs.componentName" (list . "filer")) .Values.allInOne.enabled }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: {{ include "seaweedfs.componentName" (list . "filer") }}
namespace: {{ .Release.Namespace }}
{{- with .Values.filer.httpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: filer
{{- with .Values.filer.httpRoute.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.filer.httpRoute.parentRefs }}
parentRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.filer.httpRoute.hostnames }}
hostnames:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
{{- range .Values.filer.httpRoute.rules | default (list dict) }}
- backendRefs:
{{- with .backendRefs }}
{{- toYaml . | nindent 8 }}
{{- else }}
- group: ""
kind: Service
name: {{ $serviceName }}
namespace: {{ $.Release.Namespace }}
port: {{ $.Values.filer.port }}
weight: 1
{{- end }}
{{- with .matches }}
matches:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .filters }}
filters:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .timeouts }}
timeouts:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
@@ -29,6 +29,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: filer
{{- with .Values.filer.ingresses.http.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) .Values.filer.ingresses.http.className }}
ingressClassName: {{ .Values.filer.ingresses.http.className | quote }}
@@ -87,6 +90,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: filer
{{- with .Values.filer.ingresses.grpc.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) .Values.filer.ingresses.grpc.className }}
ingressClassName: {{ .Values.filer.ingresses.grpc.className | quote }}
@@ -43,19 +43,15 @@ spec:
{{- with .Values.filer.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.filer.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.filer.podAnnotations | default dict) }}
{{- if .Values.filer.s3.existingConfigSecret }}
{{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.filer.s3.existingConfigSecret) | default dict }}
checksum/s3config: {{ $configSecret | toYaml | sha256sum }}
{{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.filer.s3.existingConfigSecret) | default dict }}
{{- $_ := set $podAnnotations "checksum/s3config" ($configSecret | toYaml | sha256sum) }}
{{- else }}
checksum/s3config: {{ include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum }}
{{- $_ := set $podAnnotations "checksum/s3config" (include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum) }}
{{- end }}
annotations:
{{- toYaml $podAnnotations | nindent 8 }}
spec:
restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.filer.restartPolicy }}
{{- if .Values.filer.affinity }}
@@ -21,6 +21,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: master
{{- with .Values.master.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.master.ingress.className | quote }}
tls:
@@ -43,13 +43,10 @@ spec:
{{- with .Values.master.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.master.podAnnotations | default dict) }}
{{- $_ := set $podAnnotations "checksum/master-config" (include (print .Template.BasePath "/master/master-configmap.yaml") . | sha256sum) }}
annotations:
{{ with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.master.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- toYaml $podAnnotations | nindent 8 }}
spec:
restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.master.restartPolicy }}
{{- if .Values.master.affinity }}
@@ -35,13 +35,15 @@ spec:
{{- with .Values.s3.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.s3.podAnnotations | default dict) }}
{{- if .Values.s3.existingConfigSecret }}
{{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.s3.existingConfigSecret) | default dict }}
{{- $_ := set $podAnnotations "checksum/s3config" ($configSecret | toYaml | sha256sum) }}
{{- else }}
{{- $_ := set $podAnnotations "checksum/s3config" (include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum) }}
{{- end }}
annotations:
{{ with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.s3.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- toYaml $podAnnotations | nindent 8 }}
spec:
restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.s3.restartPolicy }}
{{- if .Values.s3.affinity }}
@@ -0,0 +1,64 @@
{{- $s3Enabled := or .Values.s3.enabled (and .Values.filer.s3.enabled (not .Values.allInOne.enabled)) (and .Values.allInOne.enabled .Values.allInOne.s3.enabled) }}
{{- if and $s3Enabled .Values.s3.httpRoute.enabled }}
{{- $serviceName := printf "%s-s3" (include "seaweedfs.name" .) }}
{{- $s3Port := .Values.filer.s3.port }}
{{- if and .Values.allInOne.enabled .Values.allInOne.s3.enabled }}
{{- $serviceName = include "seaweedfs.componentName" (list . "all-in-one") }}
{{- $s3Port = .Values.allInOne.s3.port | default .Values.s3.port }}
{{- else if .Values.s3.enabled }}
{{- $s3Port = .Values.s3.port }}
{{- end }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: {{ include "seaweedfs.componentName" (list . "s3") }}
namespace: {{ .Release.Namespace }}
{{- with .Values.s3.httpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: s3
{{- with .Values.s3.httpRoute.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.s3.httpRoute.parentRefs }}
parentRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.s3.httpRoute.hostnames }}
hostnames:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
{{- range .Values.s3.httpRoute.rules | default (list dict) }}
- backendRefs:
{{- with .backendRefs }}
{{- toYaml . | nindent 8 }}
{{- else }}
- group: ""
kind: Service
name: {{ $serviceName }}
namespace: {{ $.Release.Namespace }}
port: {{ $s3Port }}
weight: 1
{{- end }}
{{- with .matches }}
matches:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .filters }}
filters:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .timeouts }}
timeouts:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
@@ -41,6 +41,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: s3-iceberg
{{- with .Values.s3.icebergIngress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.s3.icebergIngress.className }}
ingressClassName: {{ .Values.s3.icebergIngress.className | quote }}
@@ -32,6 +32,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: s3
{{- with .Values.s3.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.s3.ingress.className | quote }}
tls:
@@ -41,6 +41,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: s3-lance
{{- with .Values.s3.lanceIngress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.s3.lanceIngress.className }}
ingressClassName: {{ .Values.s3.lanceIngress.className | quote }}
@@ -60,7 +60,7 @@ stringData:
read_access_key_id: {{ $access_key_read }}
read_secret_access_key: {{ $secret_key_read }}
{{- end }}
seaweedfs_s3_config: '{"identities":[{"name":"anvAdmin","credentials":[{"accessKey":"{{ $access_key_admin }}","secretKey":"{{ $secret_key_admin }}"}],"actions":["Admin","Read","Write"]},{"name":"anvReadOnly","credentials":[{"accessKey":"{{ $access_key_read }}","secretKey":"{{ $secret_key_read }}"}],"actions":["Read"]}]}'
seaweedfs_s3_config: '{"identities":[{"name":"anvAdmin","credentials":[{"accessKey":"{{ $access_key_admin }}","secretKey":"{{ $secret_key_admin }}"}],"actions":["Admin","Read","Write"]},{"name":"anvReadOnly","credentials":[{"accessKey":"{{ $access_key_read }}","secretKey":"{{ $secret_key_read }}"}],"actions":["Read","List"]}]}'
{{- if .Values.filer.s3.auditLogConfig }}
filer_s3_auditLogConfig.json: |
{{ toJson .Values.filer.s3.auditLogConfig | nindent 4 }}
@@ -88,6 +88,43 @@ true
{{- end -}}
{{- end -}}
{{/* Classify an admin bind address as loopback, mirroring weed admin's
isLoopbackIp (net.ParseIP + IsLoopback). Helm templates cannot call
net.ParseIP, so we approximate: valid IPv4 addresses in 127.0.0.0/8
(validated via regex to reject malformed values like "127.not-an-ip")
and the IPv6 loopback "::1" / its expanded form "0:0:0:0:0:0:0:1" are
loopback. Hostnames (e.g. "localhost") and wildcard addresses
("0.0.0.0", "::") are non-loopback, matching the binary, which
treats unparseable hostnames as non-loopback to be safe. Other IPv6
loopback representations are not matched; the binary's own runtime
validation is the authoritative guard. */}}
{{- define "seaweedfs.admin.isLoopbackIp" -}}
{{- $ip := toString . -}}
{{- if or (regexMatch "^127\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$" $ip) (eq $ip "::1") (eq $ip "0:0:0:0:0:0:0:1") -}}
true
{{- end -}}
{{- end -}}
{{/* Whether the admin non-loopback bind guard is satisfied: admin.secret
(adminPassword or existingSecret), WEED_ADMIN_PASSWORD via
extraEnvironmentVars / secretExtraEnvironmentVars, or
admin.allowInsecureBind. A secret-backed entry counts as enabled even
though the chart cannot read its value. */}}
{{- define "seaweedfs.admin.authEnabled" -}}
{{- if or .Values.admin.secret.existingSecret .Values.admin.secret.adminPassword .Values.admin.allowInsecureBind -}}
true
{{- else -}}
{{- $merged := dict -}}
{{- $_ := include "seaweedfs.mergeExtraEnvironmentVars" (dict "global" .Values.global.seaweedfs "component" .Values.admin "target" $merged) -}}
{{- $envPassword := index $merged "WEED_ADMIN_PASSWORD" -}}
{{- if or (kindIs "map" $envPassword) (hasKey (.Values.admin.secretExtraEnvironmentVars | default dict) "WEED_ADMIN_PASSWORD") -}}
true
{{- else if and $envPassword (ne (toString $envPassword) "") -}}
true
{{- end -}}
{{- end -}}
{{- end -}}
{{/* Return the proper filer image */}}
{{- define "seaweedfs.filer.image" -}}
{{- if .Values.filer.imageOverride -}}
@@ -27,6 +27,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: volume
{{- with .Values.volume.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) .Values.volume.ingress.className }}
ingressClassName: {{ .Values.volume.ingress.className | quote }}
@@ -55,7 +55,7 @@ global:
gatewayHost: null
gatewayPort: null
additionalLabels: {}
# if enabled will use global.seaweedfs.replicationPlacement and override master & filer defaultReplicaPlacement config
# if enabled will use global.seaweedfs.replicationPlacement and override master.defaultReplication & filer.defaultReplicaPlacement config
enableReplication: false
# replication type is XYZ:
# X number of replica in other data centers
@@ -190,6 +190,8 @@ master:
podLabels: {}
# Annotations to be added to the master pods
# The chart sets checksum/master-config on master pods; other checksum/* keys
# can be used for custom rollouts.
podAnnotations: {}
# Annotations to be added to the master resources
@@ -276,6 +278,7 @@ master:
host: "master.seaweedfs.local"
path: "/sw-master/?(.*)"
pathType: ImplementationSpecific
labels: {}
annotations: {}
# nginx.ingress.kubernetes.io/auth-type: "basic"
# nginx.ingress.kubernetes.io/auth-secret: "default/ingress-basic-auth-secret"
@@ -600,6 +603,7 @@ volume:
host: "volume.seaweedfs.local"
path: "/"
pathType: Prefix
labels: {}
annotations:
nginx.ingress.kubernetes.io/app-root: /ui/index.html
# nginx.ingress.kubernetes.io/use-regex: "true"
@@ -771,6 +775,8 @@ filer:
podLabels: {}
# Annotations to be added to the filer pods
# The chart sets checksum/s3config on filer pods; other checksum/* keys can be
# used for custom rollouts.
podAnnotations: {}
# Annotations to be added to the filer resource
@@ -858,6 +864,7 @@ filer:
host: "seaweedfs.cluster.local"
path: "/sw-filer/?(.*)"
pathType: ImplementationSpecific
labels: {}
annotations: {}
# nginx.ingress.kubernetes.io/backend-protocol: GRPC
# nginx.ingress.kubernetes.io/auth-type: "basic"
@@ -884,6 +891,7 @@ filer:
# whole host, not the HTTP UI's regex path.
path: "/"
pathType: Prefix
labels: {}
annotations:
# Ingress terminates TLS and re-originates gRPC (HTTP/2) to the filer.
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
@@ -895,6 +903,24 @@ filer:
# requires ingress-nginx to run with --enable-ssl-passthrough.
tls: []
# Gateway API HTTPRoute, an alternative to the ingress above.
httpRoute:
enabled: false
labels: {}
annotations: {}
# Gateways this route attaches to, for example:
# - group: gateway.networking.k8s.io
# kind: Gateway
# name: my-gateway
# namespace: gateway-system
# sectionName: https
parentRefs: []
hostnames: []
# Each rule may set matches, filters, timeouts and backendRefs.
# A rule without backendRefs routes to the filer service.
# An empty list routes all traffic there.
rules: []
# extraEnvVars is a list of extra environment variables to set with the stateful set.
extraEnvironmentVars:
# the WEED_MYSQL_* keys and the db credential secret only render while this is "true"
@@ -1074,6 +1100,8 @@ s3:
podLabels: {}
# Annotations to be added to the s3 pods
# The chart sets checksum/s3config on s3 pods; other checksum/* keys can be
# used for custom rollouts.
podAnnotations: {}
# Annotations to be added to the s3 resources
@@ -1180,10 +1208,32 @@ s3:
host: "seaweedfs.cluster.local"
path: "/"
pathType: Prefix
labels: {}
# additional ingress annotations for the s3 endpoint
annotations: {}
tls: []
# Gateway API HTTPRoute, an alternative to the ingress above.
# With global.seaweedfs.enableSecurity and no httpsPort, the standalone s3
# gateway (s3.enabled) serves TLS on s3.port, so the Gateway also needs a
# BackendTLSPolicy for the s3 Service, which this chart does not render.
httpRoute:
enabled: false
labels: {}
annotations: {}
# Gateways this route attaches to, for example:
# - group: gateway.networking.k8s.io
# kind: Gateway
# name: my-gateway
# namespace: gateway-system
# sectionName: https
parentRefs: []
hostnames: []
# Each rule may set matches, filters, timeouts and backendRefs.
# A rule without backendRefs routes to the s3 service.
# An empty list routes all traffic there.
rules: []
# Service settings
service:
type: ClusterIP
@@ -1205,6 +1255,7 @@ s3:
host: "seaweedfs-iceberg.cluster.local"
path: "/"
pathType: Prefix
labels: {}
annotations: {}
tls: []
@@ -1214,6 +1265,7 @@ s3:
host: "seaweedfs-lance.cluster.local"
path: "/"
pathType: Prefix
labels: {}
annotations: {}
tls: []
@@ -1321,8 +1373,26 @@ admin:
replicas: 1
port: 23646 # Default admin port
grpcPort: 33646 # Default gRPC port for worker connections
# IP address the admin server listens on. Since `weed admin` 4.46 defaults to
# loopback (127.0.0.1), the chart must bind a non-loopback address for the
# kubelet's httpGet readiness/liveness probes (which dial the pod IP) to ever
# succeed. "0.0.0.0" restores the pre-4.46 behaviour of listening on all
# interfaces. A non-loopback address requires authentication: set
# admin.secret.adminPassword or admin.secret.existingSecret, supply
# WEED_ADMIN_PASSWORD via admin.extraEnvironmentVars /
# admin.secretExtraEnvironmentVars, or opt out with admin.allowInsecureBind;
# otherwise the admin container will exit with a clear error rather than
# silently staying unready. The whole
# 127.0.0.0/8 range and ::1 are treated as loopback (matching weed admin).
# Set to a loopback address only if you also replace the httpGet probes.
# Note: the -ip flag requires SeaweedFS 4.46 or newer; pinning
# admin.imageOverride to an older image is not supported with this chart.
ip: "0.0.0.0"
loggingOverrideLevel: null
# INSECURE: allow binding a non-loopback ip without authentication.
allowInsecureBind: false
# Admin authentication
secret:
# Name of an existing secret containing admin credentials. If set, adminUser and adminPassword below are ignored.
@@ -1445,6 +1515,7 @@ admin:
host: "admin.seaweedfs.local"
path: "/"
pathType: Prefix
labels: {}
annotations: {}
tls: []
@@ -1766,6 +1837,8 @@ allInOne:
initContainers: "" # Init containers
sidecars: "" # Sidecar containers
annotations: {} # Annotations for the deployment
# The chart sets checksum/master-config and checksum/s3config on all-in-one
# pods; other checksum/* keys can be used for custom rollouts.
podAnnotations: {} # Annotations for the pods
podLabels: {} # Labels for the pods
@@ -1900,6 +1973,9 @@ certificates:
# Labels to be added to all the created pods
podLabels: {}
# Annotations to be added to all the created pods
# The chart sets checksum/master-config and checksum/s3config on pods whose
# rendered ConfigMaps or Secrets should trigger rollouts. Other checksum/* keys
# can be used for custom rollout annotations.
podAnnotations: {}
networkPolicy:
@@ -16,22 +16,16 @@
# seaweedfs/seaweedfs#11674 after 4.48; drop the patch on the first vendored
# release that carries it.
#
# patches/volume-layout-crowded-lock.diff makes SetVolumeCrowded take the write
# lock of the volume layout. Upstream 4.45 mutates the crowded map under the
# read lock, while Assign reads it under the same read lock through
# GetWritableVolumeCount, so under a steady stream of writes the master dies on
# a fatal "concurrent map read and map write", which recover cannot catch, and
# S3 answers 500 until it is back. Backport of seaweedfs/seaweedfs#11216,
# released in 4.46; drop the patch on the first vendored release that carries
# it.
# patches/peer-membership-handoff.diff prevents a startup peer-discovery gap
# from leaving S3 gateways subscribed to only one filer's metadata changes.
#
# `make update` re-pins VERSION from the vendored chart, SOURCE_SHA256 from the
# source archive of that tag, UPSTREAM_DIGEST from the upstream image of that
# tag and the builder from upstream's docker/Dockerfile.go_build, and checks
# that the patches still apply.
ARG VERSION=4.45
ARG SOURCE_SHA256=800a91693e2a4e974ef0e2a157b6a04eff9f4df507303b1cff31b0601081fc30
ARG UPSTREAM_DIGEST=sha256:fc9f76fa993ad69966ffeb2f65d0318fcae39c6f8e20cf68ef7b3a5cb97769e5
ARG VERSION=4.48
ARG SOURCE_SHA256=93199495e93a981451d1fefecb5aa71e12aa1692093eed2338bbfe7f08960bfb
ARG UPSTREAM_DIGEST=sha256:4e61d15fd35994cb1e43e1e553dff106794841fd9a99ade2fc8c8bfce4d7872d
# The Go toolchain of upstream's builder (docker/Dockerfile.go_build), which
# compiles the upstream weed.
@@ -0,0 +1,631 @@
diff --git a/weed/filer/filer.go b/weed/filer/filer.go
index d83486c..a48c9df 100644
--- a/weed/filer/filer.go
+++ b/weed/filer/filer.go
@@ -165,14 +165,6 @@ func (f *Filer) AggregateFromPeers(self pb.ServerAddress, existingNodes []*maste
// The ring starts empty while peer history sits on disk: mark the pre-startFrom
// range evicted so a cursor there reads disk, not the ring's earliest entry.
f.MetaAggregator.MetaLogBuffer.MarkEvictedThrough(startFrom.UnixNano())
- f.MasterClient.SetOnPeerUpdateFn(func(update *master_pb.ClusterNodeUpdate, startFrom time.Time) {
- if update.NodeType != cluster.FilerType {
- return
- }
- // Lock ring is now managed by the master via LockRingUpdate,
- // so we no longer call AddServer/RemoveServer here.
- f.MetaAggregator.OnPeerUpdate(update, startFrom)
- })
f.MasterClient.SetOnLockRingUpdateFn(func(update *master_pb.LockRingUpdate) {
var servers []pb.ServerAddress
for _, s := range update.Servers {
@@ -186,19 +178,31 @@ func (f *Filer) AggregateFromPeers(self pb.ServerAddress, existingNodes []*maste
f.Dlm.LockRing.Reset()
})
- // Subscribe to the local filer first: its events reach the aggregated
- // buffer only through this subscription, and the peer watermarks must
- // account for it before any remote peer - a remotes-only watermark set
- // would claim completeness without self. existingNodes can omit self
- // (master registration races this bootstrap); duplicate adds are no-ops.
+ // Remote-only watermarks could claim completeness without the local merge source.
f.MetaAggregator.OnPeerUpdate(&master_pb.ClusterNodeUpdate{
NodeType: cluster.FilerType,
Address: string(self),
IsAdd: true,
}, startFrom)
- for _, peerUpdate := range existingNodes {
- f.MetaAggregator.OnPeerUpdate(peerUpdate, startFrom)
+ initialPeers := make(map[string]struct{}, len(existingNodes))
+ for _, peer := range existingNodes {
+ initialPeers[pb.ServerAddress(peer.Address).ToHttpAddress()] = struct{}{}
}
+ // The bootstrap snapshot can predate a streamed removal; use the stream's retained state.
+ f.MasterClient.SetOnPeerUpdateFn(func(update *master_pb.ClusterNodeUpdate, observedAt time.Time) {
+ if update.NodeType != cluster.FilerType {
+ return
+ }
+ address := pb.ServerAddress(update.Address).ToHttpAddress()
+ if _, initial := initialPeers[address]; initial {
+ delete(initialPeers, address)
+ // A delayed initial ADD must not skip the bootstrap replay window.
+ if update.IsAdd && startFrom.Before(observedAt) {
+ observedAt = startFrom
+ }
+ }
+ f.MetaAggregator.OnPeerUpdate(update, observedAt)
+ })
}
diff --git a/weed/filer/peer_discovery_gap_test.go b/weed/filer/peer_discovery_gap_test.go
new file mode 100644
index 0000000..4c70b40
--- /dev/null
+++ b/weed/filer/peer_discovery_gap_test.go
@@ -0,0 +1,184 @@
+package filer
+
+import (
+ "context"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/seaweedfs/seaweedfs/weed/cluster"
+ "github.com/seaweedfs/seaweedfs/weed/cluster/lock_manager"
+ "github.com/seaweedfs/seaweedfs/weed/pb"
+ "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
+ "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
+ "github.com/seaweedfs/seaweedfs/weed/wdclient"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
+)
+
+type discoveryGapMaster struct {
+ master_pb.UnimplementedSeaweedServer
+ self pb.ServerAddress
+ peer pb.ServerAddress
+ announce chan struct{}
+ snapshotHasPeer bool
+ events []bool
+ delayInitial bool
+}
+
+func (s *discoveryGapMaster) KeepConnected(stream master_pb.Seaweed_KeepConnectedServer) error {
+ if _, err := stream.Recv(); err != nil {
+ return err
+ }
+ if err := stream.Send(&master_pb.KeepConnectedResponse{VolumeLocation: &master_pb.VolumeLocation{Leader: string(s.self)}}); err != nil {
+ return err
+ }
+ initial := []pb.ServerAddress{s.self}
+ if s.snapshotHasPeer && !s.delayInitial {
+ initial = append(initial, s.peer)
+ }
+ for _, address := range initial {
+ if err := stream.Send(&master_pb.KeepConnectedResponse{ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{NodeType: cluster.FilerType, Address: string(address), IsAdd: true}}); err != nil {
+ return err
+ }
+ }
+ select {
+ case <-s.announce:
+ case <-stream.Context().Done():
+ return stream.Context().Err()
+ }
+ for _, add := range s.events {
+ if err := stream.Send(&master_pb.KeepConnectedResponse{ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{NodeType: cluster.FilerType, Address: string(s.peer), IsAdd: add}}); err != nil {
+ return err
+ }
+ }
+ if err := stream.Send(&master_pb.KeepConnectedResponse{LockRingUpdate: &master_pb.LockRingUpdate{Version: 1}}); err != nil {
+ return err
+ }
+ <-stream.Context().Done()
+ return stream.Context().Err()
+}
+
+func (s *discoveryGapMaster) ListClusterNodes(context.Context, *master_pb.ListClusterNodesRequest) (*master_pb.ListClusterNodesResponse, error) {
+ nodes := []*master_pb.ListClusterNodesResponse_ClusterNode{{Address: string(s.self)}}
+ if s.snapshotHasPeer {
+ nodes = append(nodes, &master_pb.ListClusterNodesResponse_ClusterNode{Address: string(s.peer)})
+ }
+ return &master_pb.ListClusterNodesResponse{ClusterNodes: nodes}, nil
+}
+
+type discoveryGapFiler struct {
+ filer_pb.UnimplementedSeaweedFilerServer
+ subscriptions chan int64
+}
+
+func (*discoveryGapFiler) GetFilerConfiguration(context.Context, *filer_pb.GetFilerConfigurationRequest) (*filer_pb.GetFilerConfigurationResponse, error) {
+ return &filer_pb.GetFilerConfigurationResponse{Signature: 41}, nil
+}
+func (s *discoveryGapFiler) SubscribeLocalMetadata(req *filer_pb.SubscribeMetadataRequest, stream filer_pb.SeaweedFiler_SubscribeLocalMetadataServer) error {
+ s.subscriptions <- req.SinceNs
+ <-stream.Context().Done()
+ return stream.Context().Err()
+}
+
+func TestPeerDiscoveryAcrossAggregatorInitialization(t *testing.T) {
+ cases := []struct {
+ name string
+ before bool
+ snapshotHasPeer bool
+ events []bool
+ wantPeer bool
+ cursor bool
+ }{
+ {"pre_init_add", true, false, []bool{true}, true, false},
+ {"pre_init_remove", true, true, []bool{false}, false, false},
+ {"pre_init_add_remove", true, false, []bool{true, false}, false, false},
+ {"pre_init_remove_add", true, true, []bool{false, true}, true, false},
+ {"post_init_add", false, false, []bool{true}, true, false},
+ {"post_init_remove", false, true, []bool{false}, false, false},
+ {"delayed_initial_add_replay_cursor", false, true, []bool{true}, true, true},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ listener, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, port, err := net.SplitHostPort(listener.Addr().String())
+ if err != nil {
+ t.Fatal(err)
+ }
+ self := pb.ServerAddress("127.0.0.1:0." + port)
+ peer := pb.ServerAddress("localhost:0." + port)
+ master := &discoveryGapMaster{self: self, peer: peer, announce: make(chan struct{}), snapshotHasPeer: tc.snapshotHasPeer, events: tc.events, delayInitial: tc.cursor}
+ server := grpc.NewServer()
+ master_pb.RegisterSeaweedServer(server, master)
+ subscriptions := make(chan int64, 16)
+ filer_pb.RegisterSeaweedFilerServer(server, &discoveryGapFiler{subscriptions: subscriptions})
+ go server.Serve(listener)
+ defer server.Stop()
+ dial := grpc.WithTransportCredentials(insecure.NewCredentials())
+ mc := wdclient.NewMasterClient(dial, "", cluster.FilerType, self, "", "", *pb.NewServiceDiscoveryFromMap(map[string]pb.ServerAddress{"master": self}))
+ go mc.KeepConnectedToMaster(ctx)
+ f := &Filer{MasterClient: mc, GrpcDialOption: dial, Signature: 41, Dlm: lock_manager.NewDistributedLockManager(self)}
+ snapshot := f.ListExistingPeerUpdates(ctx)
+ wantSize := 1
+ if tc.snapshotHasPeer {
+ wantSize++
+ }
+ if len(snapshot) != wantSize {
+ t.Fatalf("snapshot = %v, want %d nodes", snapshot, wantSize)
+ }
+ if mc.OnPeerUpdate != nil {
+ t.Fatal("unexpected peer callback before initialization")
+ }
+ dispatched := make(chan struct{})
+ barrier := func(*master_pb.LockRingUpdate) { close(dispatched) }
+ await := func() {
+ select {
+ case <-dispatched:
+ case <-ctx.Done():
+ t.Fatal("master dispatch barrier not reached")
+ }
+ }
+ if tc.before {
+ mc.SetOnLockRingUpdateFn(barrier)
+ close(master.announce)
+ await()
+ t.Log("membership events passed through real MasterClient dispatch while OnPeerUpdate was nil")
+ }
+ replayFrom := time.Now().Add(-time.Minute)
+ f.AggregateFromPeers(self, snapshot, replayFrom)
+ defer func() {
+ f.MetaAggregator.OnPeerUpdate(&master_pb.ClusterNodeUpdate{Address: string(self)}, time.Now())
+ f.MetaAggregator.OnPeerUpdate(&master_pb.ClusterNodeUpdate{Address: string(peer)}, time.Now())
+ f.MetaAggregator.MetaLogBuffer.ShutdownLogBuffer()
+ }()
+ if mc.OnPeerUpdate == nil {
+ t.Fatal("initialization did not install callback")
+ }
+ if !tc.before {
+ mc.SetOnLockRingUpdateFn(barrier)
+ close(master.announce)
+ await()
+ }
+ if tc.cursor {
+ for range 2 {
+ select {
+ case since := <-subscriptions:
+ if since > replayFrom.UnixNano() {
+ t.Errorf("initial peer replay starts at %d, after bootstrap overlap %d", since, replayFrom.UnixNano())
+ }
+ case <-ctx.Done():
+ t.Fatal("metadata subscription not started")
+ }
+ }
+ }
+ if got := f.MetaAggregator.HasRemotePeers(); got != tc.wantPeer {
+ t.Fatalf("remote peer membership = %t, want %t after events %v", got, tc.wantPeer, tc.events)
+ }
+ })
+ }
+}
diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go
index 6d638b6..9f16364 100644
--- a/weed/wdclient/masterclient.go
+++ b/weed/wdclient/masterclient.go
@@ -142,6 +142,16 @@ func (p *masterVolumeProvider) LookupVolumeIds(ctx context.Context, volumeIds []
// MasterClient connects to master servers and maintains volume location cache
// It receives real-time updates via KeepConnected streaming and uses vidMapClient for caching
+type peerUpdateKey struct {
+ nodeType string
+ address string
+}
+
+type pendingPeerUpdate struct {
+ update *master_pb.ClusterNodeUpdate
+ startFrom time.Time
+}
+
type MasterClient struct {
*vidMapClient // Embedded cache with shared logic
@@ -157,6 +167,7 @@ type MasterClient struct {
grpcTimeout time.Duration // Timeout for gRPC calls to master
OnPeerUpdate func(update *master_pb.ClusterNodeUpdate, startFrom time.Time)
OnPeerUpdateLock sync.RWMutex
+ pendingPeerUpdates map[peerUpdateKey]pendingPeerUpdate
OnLockRingUpdate func(update *master_pb.LockRingUpdate)
OnLockRingUpdateLock sync.RWMutex
OnMasterChange func(previous, current pb.ServerAddress)
@@ -185,8 +196,58 @@ func NewMasterClient(grpcDialOption grpc.DialOption, filerGroup string, clientTy
func (mc *MasterClient) SetOnPeerUpdateFn(onPeerUpdate func(update *master_pb.ClusterNodeUpdate, startFrom time.Time)) {
mc.OnPeerUpdateLock.Lock()
- mc.OnPeerUpdate = onPeerUpdate
+ if onPeerUpdate == nil || len(mc.pendingPeerUpdates) == 0 {
+ if onPeerUpdate != nil {
+ mc.pendingPeerUpdates = nil
+ }
+ mc.OnPeerUpdate = onPeerUpdate
+ mc.OnPeerUpdateLock.Unlock()
+ return
+ }
+ pending := mc.pendingPeerUpdates
+ mc.pendingPeerUpdates = nil
+ // Retained state must precede concurrently arriving live events.
+ replayed := make(chan struct{})
+ mc.OnPeerUpdate = func(update *master_pb.ClusterNodeUpdate, startFrom time.Time) {
+ <-replayed
+ onPeerUpdate(update, startFrom)
+ }
mc.OnPeerUpdateLock.Unlock()
+ defer close(replayed)
+ for _, peer := range pending {
+ onPeerUpdate(peer.update, peer.startFrom)
+ }
+}
+
+func (mc *MasterClient) dispatchPeerUpdate(update *master_pb.ClusterNodeUpdate) {
+ if update.FilerGroup != mc.FilerGroup {
+ return
+ }
+ startFrom := time.Now()
+ mc.OnPeerUpdateLock.Lock()
+ callback := mc.OnPeerUpdate
+ if callback == nil {
+ key := peerUpdateKey{nodeType: update.NodeType, address: update.Address}
+ if update.IsAdd {
+ if mc.pendingPeerUpdates == nil {
+ mc.pendingPeerUpdates = make(map[peerUpdateKey]pendingPeerUpdate)
+ }
+ mc.pendingPeerUpdates[key] = pendingPeerUpdate{update: update, startFrom: startFrom}
+ } else {
+ delete(mc.pendingPeerUpdates, key)
+ }
+ }
+ mc.OnPeerUpdateLock.Unlock()
+ if callback == nil {
+ return
+ }
+ if update.IsAdd {
+ glog.V(0).Infof("+ %s@%s noticed %s.%s %s", mc.clientType, mc.clientHost, update.FilerGroup, update.NodeType, update.Address)
+ } else {
+ glog.V(0).Infof("- %s@%s noticed %s.%s %s", mc.clientType, mc.clientHost, update.FilerGroup, update.NodeType, update.Address)
+ }
+ stats.MasterClientConnectCounter.WithLabelValues(stats.OnPeerUpdate).Inc()
+ callback(update, startFrom)
}
func (mc *MasterClient) SetOnLockRingUpdateFn(fn func(update *master_pb.LockRingUpdate)) {
@@ -289,6 +350,14 @@ func (mc *MasterClient) tryConnectToMaster(ctx context.Context, master pb.Server
// Still need to reset cache to ensure we don't use stale data from previous master
mc.resetVidMap()
}
+ // Retained peers are valid only while this stream lives: the next
+ // stream lists just its current members and never reports removals
+ // made before it connected.
+ defer func() {
+ mc.OnPeerUpdateLock.Lock()
+ mc.pendingPeerUpdates = nil
+ mc.OnPeerUpdateLock.Unlock()
+ }()
if previous := mc.markServingMaster(master); previous != "" {
mc.OnMasterChangeLock.RLock()
if mc.OnMasterChange != nil {
@@ -323,20 +392,7 @@ func (mc *MasterClient) tryConnectToMaster(ctx context.Context, master pb.Server
mc.updateVidMap(resp)
}
if resp.ClusterNodeUpdate != nil {
- update := resp.ClusterNodeUpdate
- mc.OnPeerUpdateLock.RLock()
- if mc.OnPeerUpdate != nil {
- if update.FilerGroup == mc.FilerGroup {
- if update.IsAdd {
- glog.V(0).Infof("+ %s@%s noticed %s.%s %s\n", mc.clientType, mc.clientHost, update.FilerGroup, update.NodeType, update.Address)
- } else {
- glog.V(0).Infof("- %s@%s noticed %s.%s %s\n", mc.clientType, mc.clientHost, update.FilerGroup, update.NodeType, update.Address)
- }
- stats.MasterClientConnectCounter.WithLabelValues(stats.OnPeerUpdate).Inc()
- mc.OnPeerUpdate(update, time.Now())
- }
- }
- mc.OnPeerUpdateLock.RUnlock()
+ mc.dispatchPeerUpdate(resp.ClusterNodeUpdate)
}
if resp.LockRingUpdate != nil {
update := resp.LockRingUpdate
diff --git a/weed/wdclient/masterclient_peer_handoff_test.go b/weed/wdclient/masterclient_peer_handoff_test.go
new file mode 100644
index 0000000..38730ec
--- /dev/null
+++ b/weed/wdclient/masterclient_peer_handoff_test.go
@@ -0,0 +1,99 @@
+package wdclient
+
+import (
+ "reflect"
+ "sync"
+ "testing"
+ "testing/synctest"
+ "time"
+
+ "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
+)
+
+func TestPeerUpdateHandoffRetainsActiveState(t *testing.T) {
+ mc := &MasterClient{FilerGroup: "test"}
+ event := func(kind, address, group string, add bool) *master_pb.ClusterNodeUpdate {
+ return &master_pb.ClusterNodeUpdate{NodeType: kind, Address: address, FilerGroup: group, IsAdd: add}
+ }
+ for i := 0; i < 100; i++ {
+ mc.dispatchPeerUpdate(event("filer", "gone:8888", "test", true))
+ mc.dispatchPeerUpdate(event("filer", "gone:8888", "test", false))
+ }
+ mc.dispatchPeerUpdate(event("filer", "keep:8888", "test", true))
+ mc.dispatchPeerUpdate(event("s3", "keep:8888", "test", true))
+ mc.dispatchPeerUpdate(event("filer", "foreign:8888", "other", true))
+ if len(mc.pendingPeerUpdates) != 2 {
+ t.Fatalf("retained entries = %d, want two active peer keys", len(mc.pendingPeerUpdates))
+ }
+ got := make(map[string]bool)
+ mc.SetOnPeerUpdateFn(func(update *master_pb.ClusterNodeUpdate, _ time.Time) {
+ got[update.NodeType+"/"+update.Address] = true
+ })
+ want := map[string]bool{"filer/keep:8888": true, "s3/keep:8888": true}
+ if !reflect.DeepEqual(got, want) {
+ t.Fatalf("handoff = %v, want %v", got, want)
+ }
+ if len(mc.pendingPeerUpdates) != 0 {
+ t.Fatal("handoff retained state after consumer installation")
+ }
+}
+
+func TestPeerUpdateHandoffOrdersConcurrentDispatch(t *testing.T) {
+ synctest.Test(t, func(t *testing.T) {
+ mc := &MasterClient{}
+ add := &master_pb.ClusterNodeUpdate{NodeType: "filer", Address: "peer:8888", IsAdd: true}
+ remove := &master_pb.ClusterNodeUpdate{NodeType: "filer", Address: "peer:8888"}
+ mc.dispatchPeerUpdate(add)
+ replayEntered := make(chan struct{})
+ releaseReplay := make(chan struct{})
+ callbackReturned := make(chan struct{})
+ var got []bool
+ var mu sync.Mutex
+ var wg sync.WaitGroup
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ mc.SetOnPeerUpdateFn(func(update *master_pb.ClusterNodeUpdate, _ time.Time) {
+ if update.IsAdd {
+ close(replayEntered)
+ <-releaseReplay
+ }
+ mu.Lock()
+ got = append(got, update.IsAdd)
+ mu.Unlock()
+ })
+ }()
+ <-replayEntered
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ mc.dispatchPeerUpdate(remove)
+ close(callbackReturned)
+ }()
+ synctest.Wait()
+ mu.Lock()
+ early := len(got)
+ mu.Unlock()
+ if early != 0 {
+ t.Errorf("live callback overtook retained-state replay: %d callbacks", early)
+ }
+ close(releaseReplay)
+ wg.Wait()
+ <-callbackReturned
+ if !reflect.DeepEqual(got, []bool{true, false}) {
+ t.Fatalf("callback order = %v, want ADD then REMOVE", got)
+ }
+ })
+}
+
+func TestPeerUpdateHandoffCallbackRunsOutsideStateLock(t *testing.T) {
+ mc := &MasterClient{}
+ mc.dispatchPeerUpdate(&master_pb.ClusterNodeUpdate{NodeType: "filer", Address: "peer:8888", IsAdd: true})
+ mc.SetOnPeerUpdateFn(func(*master_pb.ClusterNodeUpdate, time.Time) {
+ if !mc.OnPeerUpdateLock.TryLock() {
+ t.Fatal("callback invoked with state lock held")
+ }
+ mc.OnPeerUpdateLock.Unlock()
+ })
+ mc.dispatchPeerUpdate(&master_pb.ClusterNodeUpdate{NodeType: "filer", Address: "peer:8888"})
+}
diff --git a/weed/wdclient/masterclient_peer_reconnect_test.go b/weed/wdclient/masterclient_peer_reconnect_test.go
new file mode 100644
index 0000000..70efe0f
--- /dev/null
+++ b/weed/wdclient/masterclient_peer_reconnect_test.go
@@ -0,0 +1,146 @@
+package wdclient
+
+import (
+ "context"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "github.com/seaweedfs/seaweedfs/weed/pb"
+ "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/credentials/insecure"
+ "google.golang.org/grpc/status"
+)
+
+type peerReconnectMaster struct {
+ master_pb.UnimplementedSeaweedServer
+ address pb.ServerAddress
+ streams [][]string
+ connections atomic.Int32
+}
+
+func (s *peerReconnectMaster) KeepConnected(stream master_pb.Seaweed_KeepConnectedServer) error {
+ if _, err := stream.Recv(); err != nil {
+ return err
+ }
+ n := s.connections.Add(1)
+ if err := stream.Send(&master_pb.KeepConnectedResponse{VolumeLocation: &master_pb.VolumeLocation{Leader: string(s.address)}}); err != nil {
+ return err
+ }
+ for _, address := range s.streams[min(int(n), len(s.streams))-1] {
+ if err := stream.Send(&master_pb.KeepConnectedResponse{ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{NodeType: "filer", Address: address, IsAdd: true}}); err != nil {
+ return err
+ }
+ }
+ if n == 1 {
+ return status.Error(codes.Unavailable, "reconnect")
+ }
+ if err := stream.Send(&master_pb.KeepConnectedResponse{LockRingUpdate: &master_pb.LockRingUpdate{Version: 2}}); err != nil {
+ return err
+ }
+ <-stream.Context().Done()
+ return stream.Context().Err()
+}
+
+func TestPeerUpdateHandoffReconnectInitialAdds(t *testing.T) {
+ server := &peerReconnectMaster{streams: [][]string{{"peer-a:8888"}, {"peer-a:8888", "peer-b:8888"}}}
+ server.address = startFakeMasterServer(t, server)
+ mc := NewMasterClient(grpc.WithTransportCredentials(insecure.NewCredentials()), "", "filer", "", "", "", pb.ServerDiscovery{})
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ mc.tryConnectToMaster(ctx, server.address)
+ if server.connections.Load() != 1 {
+ t.Fatal("first stream did not register")
+ }
+ updates := make(chan string, 3)
+ mc.SetOnPeerUpdateFn(func(update *master_pb.ClusterNodeUpdate, _ time.Time) { updates <- update.Address })
+ barrier := make(chan struct{})
+ mc.SetOnLockRingUpdateFn(func(*master_pb.LockRingUpdate) { close(barrier) })
+ done := make(chan struct{})
+ go func() { mc.tryConnectToMaster(ctx, server.address); close(done) }()
+ select {
+ case <-barrier:
+ case <-ctx.Done():
+ t.Fatal("reconnected stream did not dispatch its initial ADDs")
+ }
+ cancel()
+ <-done
+ for _, want := range []string{"peer-a:8888", "peer-b:8888"} {
+ select {
+ case got := <-updates:
+ if got != want {
+ t.Fatalf("update = %q, want %q", got, want)
+ }
+ default:
+ t.Fatalf("missing update %q", want)
+ }
+ }
+}
+
+func TestPeerUpdateHandoffReconnectDropsPeersAbsentFromNewStream(t *testing.T) {
+ server := &peerReconnectMaster{streams: [][]string{{"peer-a:8888"}, {"peer-b:8888"}}}
+ server.address = startFakeMasterServer(t, server)
+ mc := NewMasterClient(grpc.WithTransportCredentials(insecure.NewCredentials()), "", "filer", "", "", "", pb.ServerDiscovery{})
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ mc.tryConnectToMaster(ctx, server.address)
+ if server.connections.Load() != 1 {
+ t.Fatal("first stream did not register")
+ }
+ barrier := make(chan struct{})
+ mc.SetOnLockRingUpdateFn(func(*master_pb.LockRingUpdate) { close(barrier) })
+ done := make(chan struct{})
+ go func() { mc.tryConnectToMaster(ctx, server.address); close(done) }()
+ select {
+ case <-barrier:
+ case <-ctx.Done():
+ t.Fatal("reconnected stream did not deliver its initial ADDs")
+ }
+ var replayed []string
+ mc.SetOnPeerUpdateFn(func(update *master_pb.ClusterNodeUpdate, _ time.Time) { replayed = append(replayed, update.Address) })
+ cancel()
+ <-done
+ if len(replayed) != 1 || replayed[0] != "peer-b:8888" {
+ t.Fatalf("replayed %v, want only the reconnected stream's [peer-b:8888]", replayed)
+ }
+}
+
+func TestPeerUpdateHandoffReconnectSkipsPeersOfEndedStream(t *testing.T) {
+ server := &peerReconnectMaster{streams: [][]string{{"peer-a:8888"}, {"peer-b:8888"}}}
+ server.address = startFakeMasterServer(t, server)
+ mc := NewMasterClient(grpc.WithTransportCredentials(insecure.NewCredentials()), "", "filer", "", "", "", pb.ServerDiscovery{})
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ mc.tryConnectToMaster(ctx, server.address)
+ if server.connections.Load() != 1 {
+ t.Fatal("first stream did not register")
+ }
+ updates := make(chan string, 3)
+ mc.SetOnPeerUpdateFn(func(update *master_pb.ClusterNodeUpdate, _ time.Time) { updates <- update.Address })
+ select {
+ case got := <-updates:
+ t.Fatalf("replayed %q from a stream that already ended", got)
+ default:
+ }
+ barrier := make(chan struct{})
+ mc.SetOnLockRingUpdateFn(func(*master_pb.LockRingUpdate) { close(barrier) })
+ done := make(chan struct{})
+ go func() { mc.tryConnectToMaster(ctx, server.address); close(done) }()
+ select {
+ case <-barrier:
+ case <-ctx.Done():
+ t.Fatal("reconnected stream did not deliver its initial ADDs")
+ }
+ cancel()
+ <-done
+ close(updates)
+ var got []string
+ for address := range updates {
+ got = append(got, address)
+ }
+ if len(got) != 1 || got[0] != "peer-b:8888" {
+ t.Fatalf("updates %v, want only the reconnected stream's [peer-b:8888]", got)
+ }
+}
@@ -1,87 +0,0 @@
diff --git a/weed/topology/crowded_writable_test.go b/weed/topology/crowded_writable_test.go
--- a/weed/topology/crowded_writable_test.go
+++ b/weed/topology/crowded_writable_test.go
@@ -1,6 +1,7 @@
package topology
import (
+ "sync"
"testing"
"time"
@@ -73,3 +74,52 @@ func TestCrowdedCountStillMatchesWritables(t *testing.T) {
t.Errorf("writable=%d crowded=%d, want 1 and 1", writable, crowded)
}
}
+
+// SetVolumeCrowded mutates the crowded map while GetWritableVolumeCount reads
+// it on the Assign hot path. Under RLock both could run at once and the Go
+// runtime aborts with "concurrent map read and map write". Run with -race to
+// reproduce the original bug; the write lock makes this pass.
+func TestSetVolumeCrowdedNoRaceWithGetWritableVolumeCount(t *testing.T) {
+ rp, _ := super_block.NewReplicaPlacementFromString("000")
+ vl := NewVolumeLayout(rp, needle.EMPTY_TTL, types.HardDriveType, 10000, false)
+ // GetWritableVolumeCount iterates vl.writables, so give it something to
+ // read while the crowded map is being mutated.
+ vl.writables = []needle.VolumeId{1, 2, 3}
+
+ var wg sync.WaitGroup
+ stop := make(chan struct{})
+ for range 8 {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for {
+ select {
+ case <-stop:
+ return
+ default:
+ vl.SetVolumeCrowded(needle.VolumeId(2))
+ }
+ }
+ }()
+ }
+ for range 8 {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for {
+ select {
+ case <-stop:
+ return
+ default:
+ vl.GetWritableVolumeCount()
+ }
+ }
+ }()
+ }
+
+ // The race detector needs only a brief window to flag a concurrent
+ // map read/write; let the goroutines hammer the lock briefly.
+ time.Sleep(50 * time.Millisecond)
+ close(stop)
+ wg.Wait()
+}
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
--- a/weed/topology/volume_layout.go
+++ b/weed/topology/volume_layout.go
@@ -1019,11 +1019,14 @@ func (vl *VolumeLayout) setVolumeCrowded(vid needle.VolumeId) {
}
func (vl *VolumeLayout) SetVolumeCrowded(vid needle.VolumeId) {
- // since delete is guarded by accessLock.Lock(),
- // and is always called in sequential order,
- // RLock() should be safe enough
- vl.accessLock.RLock()
- defer vl.accessLock.RUnlock()
+ // setVolumeCrowded mutates the crowded map, and GetWritableVolumeCount
+ // reads it under RLock on the Assign hot path. Two concurrent RLock
+ // holders with one writing the map triggers a fatal
+ // "concurrent map read and map write". Take the write lock: this path
+ // is a low-frequency single consumer driven by the crowded-volume
+ // event loop, and every other mutation of crowded already holds Lock().
+ vl.accessLock.Lock()
+ defer vl.accessLock.Unlock()
vl.setVolumeCrowded(vid)
}
@@ -0,0 +1,204 @@
Backport of the s3 and filer HTTPRoutes from upstream seaweedfs commit
68af030e381f, which no release carried when this patch was written.
Drop this patch and its Makefile line when bumping to the first
seaweedfs release that contains 68af030e381f (expected 4.49 or later):
it creates both templates, so `make update` fails on it once upstream
ships them. Before dropping it, carry over the two deliberate
differences: the s3 route's default backendRef here targets the renamed
`<name>-s3` Service from s3-service-name.patch, where upstream uses
componentName, so that line moves into s3-service-name-consumers.patch;
and the BackendTLSPolicy note on s3.httpRoute, which belongs with
s3-tls-main-port.patch.
Upstream's master, volume and admin routes were not backported.
diff --git a/packages/system/seaweedfs/charts/seaweedfs/templates/filer/filer-httproute.yaml b/packages/system/seaweedfs/charts/seaweedfs/templates/filer/filer-httproute.yaml
new file mode 100644
index 000000000..e655c1c19
--- /dev/null
+++ b/packages/system/seaweedfs/charts/seaweedfs/templates/filer/filer-httproute.yaml
@@ -0,0 +1,57 @@
+{{- $filerEnabled := or .Values.filer.enabled .Values.allInOne.enabled }}
+{{- if and $filerEnabled .Values.filer.httpRoute.enabled }}
+{{- $serviceName := ternary (include "seaweedfs.componentName" (list . "all-in-one")) (include "seaweedfs.componentName" (list . "filer")) .Values.allInOne.enabled }}
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: {{ include "seaweedfs.componentName" (list . "filer") }}
+ namespace: {{ .Release.Namespace }}
+ {{- with .Values.filer.httpRoute.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ labels:
+ app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
+ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ app.kubernetes.io/component: filer
+ {{- with .Values.filer.httpRoute.labels }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- with .Values.filer.httpRoute.parentRefs }}
+ parentRefs:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ {{- with .Values.filer.httpRoute.hostnames }}
+ hostnames:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ rules:
+ {{- range .Values.filer.httpRoute.rules | default (list dict) }}
+ - backendRefs:
+ {{- with .backendRefs }}
+ {{- toYaml . | nindent 8 }}
+ {{- else }}
+ - group: ""
+ kind: Service
+ name: {{ $serviceName }}
+ namespace: {{ $.Release.Namespace }}
+ port: {{ $.Values.filer.port }}
+ weight: 1
+ {{- end }}
+ {{- with .matches }}
+ matches:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .filters }}
+ filters:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .timeouts }}
+ timeouts:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/packages/system/seaweedfs/charts/seaweedfs/templates/s3/s3-httproute.yaml b/packages/system/seaweedfs/charts/seaweedfs/templates/s3/s3-httproute.yaml
new file mode 100644
index 000000000..4d8afee3c
--- /dev/null
+++ b/packages/system/seaweedfs/charts/seaweedfs/templates/s3/s3-httproute.yaml
@@ -0,0 +1,64 @@
+{{- $s3Enabled := or .Values.s3.enabled (and .Values.filer.s3.enabled (not .Values.allInOne.enabled)) (and .Values.allInOne.enabled .Values.allInOne.s3.enabled) }}
+{{- if and $s3Enabled .Values.s3.httpRoute.enabled }}
+{{- $serviceName := printf "%s-s3" (include "seaweedfs.name" .) }}
+{{- $s3Port := .Values.filer.s3.port }}
+{{- if and .Values.allInOne.enabled .Values.allInOne.s3.enabled }}
+{{- $serviceName = include "seaweedfs.componentName" (list . "all-in-one") }}
+{{- $s3Port = .Values.allInOne.s3.port | default .Values.s3.port }}
+{{- else if .Values.s3.enabled }}
+{{- $s3Port = .Values.s3.port }}
+{{- end }}
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: {{ include "seaweedfs.componentName" (list . "s3") }}
+ namespace: {{ .Release.Namespace }}
+ {{- with .Values.s3.httpRoute.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ labels:
+ app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
+ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ app.kubernetes.io/component: s3
+ {{- with .Values.s3.httpRoute.labels }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- with .Values.s3.httpRoute.parentRefs }}
+ parentRefs:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ {{- with .Values.s3.httpRoute.hostnames }}
+ hostnames:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ rules:
+ {{- range .Values.s3.httpRoute.rules | default (list dict) }}
+ - backendRefs:
+ {{- with .backendRefs }}
+ {{- toYaml . | nindent 8 }}
+ {{- else }}
+ - group: ""
+ kind: Service
+ name: {{ $serviceName }}
+ namespace: {{ $.Release.Namespace }}
+ port: {{ $s3Port }}
+ weight: 1
+ {{- end }}
+ {{- with .matches }}
+ matches:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .filters }}
+ filters:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .timeouts }}
+ timeouts:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/packages/system/seaweedfs/charts/seaweedfs/values.yaml b/packages/system/seaweedfs/charts/seaweedfs/values.yaml
index 5b8a8c2e5..3a188323b 100644
--- a/packages/system/seaweedfs/charts/seaweedfs/values.yaml
+++ b/packages/system/seaweedfs/charts/seaweedfs/values.yaml
@@ -903,6 +903,24 @@ filer:
# requires ingress-nginx to run with --enable-ssl-passthrough.
tls: []
+ # Gateway API HTTPRoute, an alternative to the ingress above.
+ httpRoute:
+ enabled: false
+ labels: {}
+ annotations: {}
+ # Gateways this route attaches to, for example:
+ # - group: gateway.networking.k8s.io
+ # kind: Gateway
+ # name: my-gateway
+ # namespace: gateway-system
+ # sectionName: https
+ parentRefs: []
+ hostnames: []
+ # Each rule may set matches, filters, timeouts and backendRefs.
+ # A rule without backendRefs routes to the filer service.
+ # An empty list routes all traffic there.
+ rules: []
+
# extraEnvVars is a list of extra environment variables to set with the stateful set.
extraEnvironmentVars:
# the WEED_MYSQL_* keys and the db credential secret only render while this is "true"
@@ -1195,6 +1213,27 @@ s3:
annotations: {}
tls: []
+ # Gateway API HTTPRoute, an alternative to the ingress above.
+ # With global.seaweedfs.enableSecurity and no httpsPort, the standalone s3
+ # gateway (s3.enabled) serves TLS on s3.port, so the Gateway also needs a
+ # BackendTLSPolicy for the s3 Service, which this chart does not render.
+ httpRoute:
+ enabled: false
+ labels: {}
+ annotations: {}
+ # Gateways this route attaches to, for example:
+ # - group: gateway.networking.k8s.io
+ # kind: Gateway
+ # name: my-gateway
+ # namespace: gateway-system
+ # sectionName: https
+ parentRefs: []
+ hostnames: []
+ # Each rule may set matches, filters, timeouts and backendRefs.
+ # A rule without backendRefs routes to the s3 service.
+ # An empty list routes all traffic there.
+ rules: []
+
# Service settings
service:
type: ClusterIP
@@ -1,24 +0,0 @@
diff --git a/packages/system/seaweedfs/charts/seaweedfs/templates/shared/security-configmap.yaml b/packages/system/seaweedfs/charts/seaweedfs/templates/shared/security-configmap.yaml
index a067e1de9..17b82cca0 100644
--- a/packages/system/seaweedfs/charts/seaweedfs/templates/shared/security-configmap.yaml
+++ b/packages/system/seaweedfs/charts/seaweedfs/templates/shared/security-configmap.yaml
@@ -97,6 +97,19 @@ data:
cert = "/usr/local/share/ca-certificates/worker/tls.crt"
key = "/usr/local/share/ca-certificates/worker/tls.key"
+ {{- /* S3 gRPC server identity (weed s3 -port.grpc, default httpPort+10000).
+ Without this section, LoadServerTLS("grpc.s3") returns nil and the S3
+ server serves its internal gRPC (IAM cache propagation, s3 lifecycle
+ delete RPCs) as plaintext, while peers dial it with mTLS credentials:
+ "tls: first record does not look like a TLS handshake".
+ Always uses the internal CA-signed client certificate (already mounted
+ on s3 pods by s3-deployment.yaml). Deliberately NOT s3.tlsSecret: that
+ secret is for the public HTTPS listener and may be issued by a public
+ CA which internal gRPC peers (trusting only grpc.ca) would reject. */}}
+ [grpc.s3]
+ cert = "/usr/local/share/ca-certificates/client/tls.crt"
+ key = "/usr/local/share/ca-certificates/client/tls.key"
+
# use this for any place needs a grpc client
# i.e., "weed backup|benchmark|filer.copy|filer.replicate|mount|s3|upload"
[grpc.client]
@@ -0,0 +1,149 @@
suite: seaweedfs Gateway API HTTPRoutes
# The routes come from patches/httproute-backport.patch. Its s3 route names
# the backend <name>-s3, as s3-service-name.patch names the Service. Upstream
# uses componentName (<fullname>-s3) there, which renders the same name while
# fullnameOverride equals the chart name, so the routing cases override it to
# make upstream's form render a different name and fail.
templates:
- charts/seaweedfs/templates/s3/s3-httproute.yaml
- charts/seaweedfs/templates/s3/s3-service.yaml
- charts/seaweedfs/templates/filer/filer-httproute.yaml
- charts/seaweedfs/templates/filer/filer-service.yaml
release:
name: seaweedfs-system
namespace: cozy-seaweedfs
tests:
- it: renders no s3 route by default
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
asserts:
- hasDocuments:
count: 0
- it: renders no filer route by default
template: charts/seaweedfs/templates/filer/filer-httproute.yaml
asserts:
- hasDocuments:
count: 0
- it: s3 route targets the renamed s3 service on the s3 port
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.filer.s3.port: 8334
seaweedfs.s3.httpRoute.enabled: true
seaweedfs.s3.httpRoute.parentRefs:
- name: gw
namespace: gateway-system
seaweedfs.s3.httpRoute.hostnames:
- s3.example.com
asserts:
- isKind:
of: HTTPRoute
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-s3
- equal:
path: spec.rules[0].backendRefs[0].port
value: 8333
- equal:
path: spec.parentRefs[0].name
value: gw
- equal:
path: spec.hostnames[0]
value: s3.example.com
- it: the s3 service it targets is the one the chart renders
template: charts/seaweedfs/templates/s3/s3-service.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
asserts:
- equal:
path: metadata.name
value: seaweedfs-s3
- it: s3 route on a filer-embedded gateway targets the renamed service on the filer s3 port
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.s3.enabled: false
seaweedfs.filer.s3.enabled: true
seaweedfs.filer.s3.port: 8334
seaweedfs.s3.httpRoute.enabled: true
asserts:
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-s3
- equal:
path: spec.rules[0].backendRefs[0].port
value: 8334
- it: filer route targets the filer service on the filer port
template: charts/seaweedfs/templates/filer/filer-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.filer.httpRoute.enabled: true
asserts:
- isKind:
of: HTTPRoute
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-system-filer
- equal:
path: spec.rules[0].backendRefs[0].port
value: 8888
- it: the filer service it targets is the one the chart renders
template: charts/seaweedfs/templates/filer/filer-service.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
asserts:
- equal:
path: metadata.name
value: seaweedfs-system-filer
- it: an s3 rule without backendRefs keeps its matches and routes to the s3 service
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.s3.httpRoute.enabled: true
seaweedfs.s3.httpRoute.rules:
- matches:
- path:
type: PathPrefix
value: /bucket
asserts:
- lengthEqual:
path: spec.rules
count: 1
- equal:
path: spec.rules[0].matches[0].path.value
value: /bucket
- equal:
path: spec.rules[0].backendRefs
value:
- group: ""
kind: Service
name: seaweedfs-s3
namespace: cozy-seaweedfs
port: 8333
weight: 1
- it: an empty s3 rule list renders one catch-all rule to the s3 service
template: charts/seaweedfs/templates/s3/s3-httproute.yaml
set:
seaweedfs.fullnameOverride: seaweedfs-system
seaweedfs.s3.httpRoute.enabled: true
seaweedfs.s3.httpRoute.rules: []
asserts:
- lengthEqual:
path: spec.rules
count: 1
- notExists:
path: spec.rules[0].matches
- equal:
path: spec.rules[0].backendRefs[0].name
value: seaweedfs-s3
@@ -8,6 +8,7 @@ suite: seaweedfs image
templates:
- charts/seaweedfs/templates/master/master-statefulset.yaml
- charts/seaweedfs/templates/master/master-configmap.yaml
- charts/seaweedfs/templates/volume/volume-statefulset.yaml
- charts/seaweedfs/templates/filer/filer-statefulset.yaml
- charts/seaweedfs/templates/s3/s3-deployment.yaml
@@ -14,6 +14,43 @@ release:
namespace: tenant-root
tests:
- it: refuses a non-loopback admin without authentication
template: charts/seaweedfs/templates/admin/admin-statefulset.yaml
set:
seaweedfs:
global:
seaweedfs:
extraEnvironmentVars: null
admin: &unauthenticatedAdmin
enabled: true
ip: "0.0.0.0"
allowInsecureBind: false
secret:
existingSecret: ""
adminPassword: ""
extraEnvironmentVars: null
secretExtraEnvironmentVars: null
asserts:
- failedTemplate:
errorPattern: 'admin\.ip is set to "0\.0\.0\.0" \(non-loopback\) but admin authentication is not configured\.'
- it: allows an explicitly unauthenticated non-loopback admin
template: charts/seaweedfs/templates/admin/admin-statefulset.yaml
set:
seaweedfs:
global:
seaweedfs:
extraEnvironmentVars: null
admin:
<<: *unauthenticatedAdmin
allowInsecureBind: true
asserts:
- isKind:
of: StatefulSet
- matchRegex:
path: spec.template.spec.containers[0].command[2]
pattern: '-allowInsecureBind '
- it: runs the admin server that schedules lifecycle jobs
template: charts/seaweedfs/templates/admin/admin-statefulset.yaml
set: &enabled
@@ -47,6 +84,17 @@ tests:
path: spec.volumeClaimTemplates[0].spec.resources.requests.storage
value: 1Gi
# weed admin keeps its worker gRPC port on loopback unless -ip is given
# explicitly (weed/command/admin.go at 4.48), and the worker runs in its own
# pod.
- it: lets the worker reach the admin gRPC port
template: charts/seaweedfs/templates/admin/admin-statefulset.yaml
set: *enabled
asserts:
- matchRegex:
path: spec.template.spec.containers[0].command[2]
pattern: '-ip=0\.0\.0\.0 '
- it: runs the worker against the admin of the same release
template: charts/seaweedfs/templates/worker/worker-deployment.yaml
set: *enabled
@@ -12,6 +12,7 @@ suite: seaweedfs master anti-affinity
templates:
- charts/seaweedfs/templates/master/master-statefulset.yaml
- charts/seaweedfs/templates/master/master-configmap.yaml
release:
name: seaweedfs
@@ -19,6 +20,7 @@ release:
tests:
- it: softens the master hostname anti-affinity to a preference
template: charts/seaweedfs/templates/master/master-statefulset.yaml
asserts:
- notExists:
path: spec.template.spec.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution
@@ -13,6 +13,7 @@ suite: seaweedfs master probe timeouts
templates:
- charts/seaweedfs/templates/master/master-statefulset.yaml
- charts/seaweedfs/templates/master/master-configmap.yaml
release:
name: seaweedfs
@@ -20,6 +21,7 @@ release:
tests:
- it: raises both master probe timeouts above the cluster-status backoff
template: charts/seaweedfs/templates/master/master-statefulset.yaml
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe.timeoutSeconds
@@ -29,6 +31,7 @@ tests:
value: 30
- it: preserves the other master probe fields through the deep-merge
template: charts/seaweedfs/templates/master/master-statefulset.yaml
asserts:
# liveness: only timeoutSeconds is overridden, the rest survive
- equal:
@@ -14,6 +14,7 @@ suite: seaweedfs s3 catalog listener ports
templates:
- charts/seaweedfs/templates/s3/s3-service.yaml
- charts/seaweedfs/templates/s3/s3-deployment.yaml
- charts/seaweedfs/templates/s3/s3-secret.yaml
release:
name: seaweedfs
@@ -3,6 +3,7 @@ suite: seaweedfs s3 gRPC listener speaks mTLS
templates:
- charts/seaweedfs/templates/shared/security-configmap.yaml
- charts/seaweedfs/templates/s3/s3-deployment.yaml
- charts/seaweedfs/templates/s3/s3-secret.yaml
release:
name: seaweedfs-system
@@ -12,7 +13,7 @@ tests:
# weed s3 serves its internal gRPC (the LifecycleDelete RPC among it) with
# the [grpc.s3] identity and as plaintext without one, while the worker dials
# it with [grpc.worker] mTLS credentials, so every delete failed the TLS
# handshake. patches/s3-grpc-tls.patch backports the section from upstream.
# handshake. The vendored chart carries the section since 4.46.
- it: gives the s3 gRPC server a TLS identity signed by the internal CA
template: charts/seaweedfs/templates/shared/security-configmap.yaml
asserts:
@@ -19,6 +19,7 @@ suite: seaweedfs s3 TLS on main port + COSI provisioner SA name
templates:
- charts/seaweedfs/templates/s3/s3-deployment.yaml
- charts/seaweedfs/templates/s3/s3-secret.yaml
- charts/seaweedfs/templates/cosi/cosi-deployment.yaml
release:
@@ -7,6 +7,7 @@ suite: seaweedfs claims keep the storage class a string
templates:
- charts/seaweedfs/templates/master/master-statefulset.yaml
- charts/seaweedfs/templates/master/master-configmap.yaml
- charts/seaweedfs/templates/filer/filer-statefulset.yaml
- charts/seaweedfs/templates/volume/volume-statefulset.yaml
- charts/seaweedfs/templates/admin/admin-statefulset.yaml
@@ -97,6 +98,7 @@ tests:
template: charts/seaweedfs/templates/admin/admin-statefulset.yaml
set:
seaweedfs.admin.enabled: true
seaweedfs.admin.secret.existingSecret: seaweedfs-admin-credentials
seaweedfs.admin.logs: {type: persistentVolumeClaim, size: 1Gi, storageClass: "456"}
asserts:
- equal:
@@ -107,6 +109,7 @@ tests:
template: charts/seaweedfs/templates/admin/admin-statefulset.yaml
set:
seaweedfs.admin.enabled: true
seaweedfs.admin.secret.existingSecret: seaweedfs-admin-credentials
seaweedfs.admin.logs: {type: persistentVolumeClaim, size: 1Gi}
asserts:
- notExists:
@@ -28,6 +28,7 @@ suite: seaweedfs volume slot ceiling
templates:
- charts/seaweedfs/templates/master/master-statefulset.yaml
- charts/seaweedfs/templates/master/master-configmap.yaml
- charts/seaweedfs/templates/volume/volume-statefulset.yaml
release:
+4 -4
View File
@@ -31,7 +31,7 @@ seaweedfs:
# `make image` rewrites both keys on every build.
image:
repository: "ghcr.io/cozystack/cozystack/seaweedfs"
tag: "4.45@sha256:2a063deb9992ac0c06f8c09589ae063a30ac8c87af2c6aa1f4d4420cc544535c"
tag: "4.48@sha256:5360a02bbf1156947a7bae64182cfcc14d03aa67ab4499859721a87fabe580ca"
master:
# At the shipped replicationFactor of 2 the size limit and
# extraEnvironmentVars.WEED_MASTER_VOLUME_GROWTH_COPY_2 below are one
@@ -207,9 +207,9 @@ seaweedfs:
# weed skip startLanceServer and drops the container port and Service port
# with it.
lancePort: 0
# patches/s3-grpc-tls.patch adds [grpc.s3] to security.toml, which the s3
# pods mount by subPath and so never re-read. This annotation changes the
# pod template in the release that brings the section, so an upgrade
# The chart adds [grpc.s3] to security.toml, which the s3 pods mount by
# subPath and so never re-read. This annotation changes the pod
# template in the release that brings the section, so an upgrade
# restarts s3 onto it instead of leaving its gRPC in plaintext. The
# upstream s3 template carries no checksum of that ConfigMap, and adding
# one would be another vendored patch for a change made once.