mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
iscsi: address frontend review feedback
This commit is contained in:
1 parent
b92a468c5b
commit
92c6cc126c
13 files changed
+77
-42
No files matched your search
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func TestParseFlags_IscsiPortalAddrRequiresListen(t *testing.T) {
|
||||
args := append(requiredBlockvolumeArgs(),
|
||||
"--iscsi-portal-addr", "192.168.1.184:3260,1",
|
||||
"--iscsi-portal-addr", "203.0.113.10:3260,1",
|
||||
)
|
||||
_, err := parseFlags(args)
|
||||
if err == nil {
|
||||
@@ -23,13 +23,13 @@ func TestParseFlags_IscsiPortalAddrDoesNotChangeLoopbackBind(t *testing.T) {
|
||||
args := append(requiredBlockvolumeArgs(),
|
||||
"--iscsi-listen", "127.0.0.1:3260",
|
||||
"--iscsi-iqn", "iqn.2026-05.io.seaweedfs:test-v1",
|
||||
"--iscsi-portal-addr", "192.168.1.184:3260,1",
|
||||
"--iscsi-portal-addr", "203.0.113.10:3260,1",
|
||||
)
|
||||
got, err := parseFlags(args)
|
||||
if err != nil {
|
||||
t.Fatalf("parseFlags: %v", err)
|
||||
}
|
||||
if got.iscsiPortalAddr != "192.168.1.184:3260,1" {
|
||||
if got.iscsiPortalAddr != "203.0.113.10:3260,1" {
|
||||
t.Fatalf("iscsiPortalAddr = %q", got.iscsiPortalAddr)
|
||||
}
|
||||
if !got.enableT1Readiness {
|
||||
@@ -39,9 +39,9 @@ func TestParseFlags_IscsiPortalAddrDoesNotChangeLoopbackBind(t *testing.T) {
|
||||
|
||||
func TestParseFlags_IscsiPortalAddrStillRejectsExternalBind(t *testing.T) {
|
||||
args := append(requiredBlockvolumeArgs(),
|
||||
"--iscsi-listen", "192.168.1.184:3260",
|
||||
"--iscsi-listen", "203.0.113.10:3260",
|
||||
"--iscsi-iqn", "iqn.2026-05.io.seaweedfs:test-v1",
|
||||
"--iscsi-portal-addr", "192.168.1.184:3260,1",
|
||||
"--iscsi-portal-addr", "203.0.113.10:3260,1",
|
||||
)
|
||||
_, err := parseFlags(args)
|
||||
if err == nil {
|
||||
@@ -125,6 +125,22 @@ func TestParseFlags_IscsiCHAPPlumbed(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseFlags_IscsiCHAPFromEnvironment(t *testing.T) {
|
||||
t.Setenv("SW_BLOCK_ISCSI_CHAP_USERNAME", "env-user")
|
||||
t.Setenv("SW_BLOCK_ISCSI_CHAP_SECRET", "env-secret")
|
||||
args := append(requiredBlockvolumeArgs(),
|
||||
"--iscsi-listen", "127.0.0.1:3260",
|
||||
"--iscsi-iqn", "iqn.2026-05.io.seaweedfs:test-v1",
|
||||
)
|
||||
got, err := parseFlags(args)
|
||||
if err != nil {
|
||||
t.Fatalf("parseFlags: %v", err)
|
||||
}
|
||||
if got.iscsiCHAPUser != "env-user" || got.iscsiCHAPSecret != "env-secret" {
|
||||
t.Fatalf("CHAP env = %q/%q", got.iscsiCHAPUser, got.iscsiCHAPSecret)
|
||||
}
|
||||
}
|
||||
|
||||
func requiredBlockvolumeArgs() []string {
|
||||
return []string{
|
||||
"--master", "127.0.0.1:9333",
|
||||
|
||||
@@ -132,7 +132,7 @@ func parseFlags(args []string) (flags, error) {
|
||||
fs.BoolVar(&f.statusRecovery, "status-recovery", false, "expose /status/recovery?volume=<id> with engine.ReplicaProjection (Mode/R/S/H/RecoveryDecision); off by default; loopback-only; intended for hardware test orchestration")
|
||||
fs.StringVar(&f.iscsiListen, "iscsi-listen", "", "iSCSI target bind address (e.g. 127.0.0.1:0); empty disables. Loopback-only unless paired with an operator-managed proxy")
|
||||
fs.StringVar(&f.iscsiIQN, "iscsi-iqn", "", "iSCSI target IQN (required if --iscsi-listen is set)")
|
||||
fs.StringVar(&f.iscsiPortalAddr, "iscsi-portal-addr", "", "iSCSI TargetAddress advertised in SendTargets responses (e.g. 192.168.1.184:3260,1). Defaults to the bound listen address. Does not change the loopback-only bind policy")
|
||||
fs.StringVar(&f.iscsiPortalAddr, "iscsi-portal-addr", "", "iSCSI TargetAddress advertised in SendTargets responses (e.g. 203.0.113.10:3260,1). Defaults to the bound listen address. Does not change the loopback-only bind policy")
|
||||
fs.DurationVar(&f.iscsiDataOutTTL, "iscsi-dataout-timeout", 0, "iSCSI R2T/Data-Out wait timeout. 0 uses the target default. Bounds how long a session waits for solicited Data-Out from an initiator")
|
||||
fs.UintVar(&f.iscsiLUN, "iscsi-lun", 0, "iSCSI LUN id (default 0)")
|
||||
fs.StringVar(&f.iscsiCHAPUser, "iscsi-chap-username", "", "iSCSI target-side CHAP username. Requires --iscsi-chap-secret and --iscsi-listen")
|
||||
@@ -184,6 +184,12 @@ func parseFlags(args []string) (flags, error) {
|
||||
if _, _, err := parseReplicationAckProfile(f.replicationAck); err != nil {
|
||||
return flags{}, err
|
||||
}
|
||||
if f.iscsiCHAPUser == "" {
|
||||
f.iscsiCHAPUser = os.Getenv("SW_BLOCK_ISCSI_CHAP_USERNAME")
|
||||
}
|
||||
if f.iscsiCHAPSecret == "" {
|
||||
f.iscsiCHAPSecret = os.Getenv("SW_BLOCK_ISCSI_CHAP_SECRET")
|
||||
}
|
||||
missing := []string{}
|
||||
for name, val := range map[string]string{
|
||||
"master": f.masterAddr, "server-id": f.serverID,
|
||||
|
||||
@@ -93,7 +93,7 @@ type CHAPConfig struct {
|
||||
Challenge []byte
|
||||
}
|
||||
|
||||
func (c NegotiableConfig) isZero() bool {
|
||||
func (c NegotiableConfig) isZeroExceptCHAP() bool {
|
||||
return c.MaxRecvDataSegmentLength == 0 &&
|
||||
c.MaxBurstLength == 0 &&
|
||||
c.FirstBurstLength == 0 &&
|
||||
@@ -107,10 +107,7 @@ func (c NegotiableConfig) isZero() bool {
|
||||
!c.DataSequenceInOrder &&
|
||||
c.ErrorRecoveryLevel == 0 &&
|
||||
c.TargetPortalGroupTag == 0 &&
|
||||
c.TargetAlias == "" &&
|
||||
c.CHAP.Username == "" &&
|
||||
c.CHAP.Secret == "" &&
|
||||
len(c.CHAP.Challenge) == 0
|
||||
c.TargetAlias == ""
|
||||
}
|
||||
|
||||
// DefaultNegotiableConfig returns a profile that interoperates
|
||||
|
||||
@@ -308,10 +308,11 @@ func TestLoginNegotiator_CHAP_ChallengeIgnoresPrematureTransit(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("ParseParams: %v", err)
|
||||
}
|
||||
if v, _ := respParams.Get("CHAP_C"); v != "0x"+hex.EncodeToString(challenge) {
|
||||
if v, _ := respParams.Get("AuthMethod"); v != "CHAP" {
|
||||
t.Fatalf("AuthMethod=%q want CHAP", v)
|
||||
}
|
||||
if v, _ := respParams.Get("AuthMethod"); v != "CHAP" {
|
||||
t.Fatalf("AuthMethod=%q want CHAP", v)
|
||||
}
|
||||
if v, ok := respParams.Get("CHAP_C"); ok {
|
||||
t.Fatalf("CHAP_C=%q should not be emitted before CHAP_A is offered", v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,10 @@ func NewTarget(cfg TargetConfig) *Target {
|
||||
if lg == nil {
|
||||
lg = log.Default()
|
||||
}
|
||||
if cfg.Negotiation.isZero() {
|
||||
if cfg.Negotiation.isZeroExceptCHAP() {
|
||||
chap := cfg.Negotiation.CHAP
|
||||
cfg.Negotiation = DefaultNegotiableConfig()
|
||||
cfg.Negotiation.CHAP = chap
|
||||
}
|
||||
if cfg.DataOutTimeout == 0 {
|
||||
cfg.DataOutTimeout = 30 * time.Second
|
||||
|
||||
@@ -137,12 +137,6 @@ func blockVolumeArgs(plan lifecycle.BlockVolumeWorkloadPlan, replica lifecycle.B
|
||||
fmt.Sprintf("--iscsi-listen=127.0.0.1:%d", replica.ISCSIListenPort),
|
||||
"--iscsi-iqn=" + replica.ISCSIQualifiedName,
|
||||
}
|
||||
if cfg.ISCSICHAP.Name != "" {
|
||||
args = append(args,
|
||||
"--iscsi-chap-username=$(SW_BLOCK_ISCSI_CHAP_USERNAME)",
|
||||
"--iscsi-chap-secret=$(SW_BLOCK_ISCSI_CHAP_SECRET)",
|
||||
)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
|
||||
@@ -114,8 +114,6 @@ func TestG15d_K8sRenderer_CanWireCHAPSecret(t *testing.T) {
|
||||
}
|
||||
raw := string(manifests[0].YAML)
|
||||
for _, want := range []string{
|
||||
"--iscsi-chap-username=$(SW_BLOCK_ISCSI_CHAP_USERNAME)",
|
||||
"--iscsi-chap-secret=$(SW_BLOCK_ISCSI_CHAP_SECRET)",
|
||||
"name: SW_BLOCK_ISCSI_CHAP_USERNAME",
|
||||
"name: SW_BLOCK_ISCSI_CHAP_SECRET",
|
||||
"name: sw-block-iscsi-chap",
|
||||
@@ -126,6 +124,14 @@ func TestG15d_K8sRenderer_CanWireCHAPSecret(t *testing.T) {
|
||||
t.Fatalf("manifest missing %q:\n%s", want, raw)
|
||||
}
|
||||
}
|
||||
for _, forbidden := range []string{
|
||||
"--iscsi-chap-username=$(SW_BLOCK_ISCSI_CHAP_USERNAME)",
|
||||
"--iscsi-chap-secret=$(SW_BLOCK_ISCSI_CHAP_SECRET)",
|
||||
} {
|
||||
if strings.Contains(raw, forbidden) {
|
||||
t.Fatalf("manifest must not put CHAP secret material in process args %q:\n%s", forbidden, raw)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15d_K8sRenderer_OutputIsNotAuthorityShaped(t *testing.T) {
|
||||
|
||||
@@ -26,9 +26,19 @@ metadata:
|
||||
name: sw-block-dynamic-smoke
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: writer
|
||||
image: alpine:3.20
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
|
||||
@@ -9,8 +9,9 @@ This is the short internal roadmap. Keep it current and readable.
|
||||
- Target early users running lab or small Kubernetes clusters.
|
||||
- Keep alpha claims narrow: dynamic PVC, iSCSI path, app write/read, clean
|
||||
teardown.
|
||||
- Do not claim production HA, seamless mounted failover, performance, CHAP,
|
||||
multipath, or NVMe-oF readiness until separately tested.
|
||||
- CHAP is implemented for target-side iSCSI and CSI node staging, with lab
|
||||
validation. Do not claim production HA, seamless mounted failover,
|
||||
performance, multipath, or NVMe-oF readiness until separately tested.
|
||||
|
||||
## Product Phases
|
||||
|
||||
@@ -63,9 +64,10 @@ This is the short internal roadmap. Keep it current and readable.
|
||||
|
||||
### Track B: iSCSI Frontend Stability
|
||||
|
||||
- Current: iSCSI-P1 OS initiator correctness is implemented and evidenced.
|
||||
- Next: iSCSI-P2 session stability and memory-pressure coverage.
|
||||
- Later: product-backed iSCSI stability, CHAP, CSI lifecycle, ALUA/MPIO.
|
||||
- Current: OS initiator correctness, session stability, product-backed K8s
|
||||
fio/attach-detach, and CHAP are implemented and evidenced.
|
||||
- Next: CSI lifecycle and restart behavior.
|
||||
- Later: ALUA/MPIO and mounted failover.
|
||||
|
||||
### Track C: Durable State
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Status: QA green.
|
||||
|
||||
Branch under test: `iscsi/frontend-completeness`.
|
||||
Verified commit: `e7c95ee44863f34b304995fa977a4ff57ab3e649`.
|
||||
Host: M02 (`192.168.1.184`).
|
||||
Host: M02 (lab address redacted).
|
||||
|
||||
Purpose: validate the local iSCSI P2/P3 test/tooling work on a real Linux/K8s
|
||||
lab. This is not a performance claim and not a failover claim.
|
||||
@@ -30,7 +30,7 @@ lab. This is not a performance claim and not a failover claim.
|
||||
|
||||
- Result: PASS.
|
||||
- Artifact:
|
||||
`/mnt/smb/work/share/g15d-k8s/20260505T062122Z-iscsi-p2-test1-os-repeat`.
|
||||
`[artifact-root]/20260505T062122Z-iscsi-p2-test1-os-repeat`.
|
||||
- Final line:
|
||||
`[iscsi-os] PASS: 5 x iscsiadm mkfs mount write/read logout`.
|
||||
- Cleanup: `iscsi-sessions.final.txt` reports no active sessions.
|
||||
@@ -62,7 +62,7 @@ lab. This is not a performance claim and not a failover claim.
|
||||
|
||||
- Result: PASS.
|
||||
- Artifact:
|
||||
`/mnt/smb/work/share/g15d-k8s/20260505T062159Z-iscsi-p2-test2-os-fio60s`.
|
||||
`[artifact-root]/20260505T062159Z-iscsi-p2-test2-os-fio60s`.
|
||||
- fio summary:
|
||||
- read IOPS=122, BW=490KiB/s,
|
||||
- write IOPS=123, BW=494KiB/s,
|
||||
@@ -92,7 +92,7 @@ lab. This is not a performance claim and not a failover claim.
|
||||
|
||||
- Result: PASS.
|
||||
- Artifact:
|
||||
`/mnt/smb/work/share/g15d-k8s/20260505T062334Z-iscsi-p3-test3-k8s-fio`.
|
||||
`[artifact-root]/20260505T062334Z-iscsi-p3-test3-k8s-fio`.
|
||||
- Pod evidence:
|
||||
- `pod.log` shows Alpine `apk` install of fio,
|
||||
- 60s randrw run,
|
||||
@@ -126,7 +126,7 @@ lab. This is not a performance claim and not a failover claim.
|
||||
|
||||
- Result: PASS.
|
||||
- Artifact:
|
||||
`/mnt/smb/work/share/g15d-k8s/20260505T062606Z-iscsi-p3-test4-attach-detach`.
|
||||
`[artifact-root]/20260505T062606Z-iscsi-p3-test4-attach-detach`.
|
||||
- Iterations:
|
||||
- iter-1 PASS: writer wrote and verified `/data/demo.bin`; reader read-back OK; no active iSCSI sessions after delete.
|
||||
- iter-2 PASS: same.
|
||||
|
||||
@@ -8,10 +8,10 @@ initiator. No Kubernetes Secret or CSI CHAP claim in this assignment.
|
||||
Dev preflight:
|
||||
|
||||
- commit: `d0c62e6`
|
||||
- host: M02
|
||||
- host: M02 or equivalent Linux lab host
|
||||
- command: Test 2 below
|
||||
- artifact:
|
||||
`/mnt/smb/work/share/g15d-k8s/20260505T072921Z-iscsi-p4-chap`
|
||||
`[artifact-root]/20260505T072921Z-iscsi-p4-chap`
|
||||
- result: PASS, including wrong-secret failure, correct-secret login,
|
||||
`mkfs.ext4`, mount, checksum, 32 MiB dd, logout, and no active sessions.
|
||||
|
||||
@@ -19,7 +19,7 @@ Dev preflight:
|
||||
|
||||
- Host: M02 or equivalent Linux host with `sudo`, `iscsiadm`, `mkfs.ext4`,
|
||||
`mount`, `sha256sum`, and optional `fio`.
|
||||
- Worktree: `C:\work\seaweed_block` branch `iscsi/frontend-completeness`,
|
||||
- Worktree: local `seaweed-block` checkout on branch `iscsi/frontend-completeness`,
|
||||
or archived copy of the same commit on the Linux host.
|
||||
- Lab must start clean:
|
||||
- `sudo iscsiadm -m session` reports no active sessions, or only unrelated
|
||||
|
||||
@@ -34,7 +34,7 @@ Run first to prove the default alpha path still works.
|
||||
|
||||
```bash
|
||||
RUN_ID="$(date -u +%Y%m%dT%H%M%SZ)-iscsi-p4-k8s-default"
|
||||
SW_BLOCK_ARTIFACT_DIR="/mnt/smb/work/share/g15d-k8s/$RUN_ID" \
|
||||
SW_BLOCK_ARTIFACT_DIR="/tmp/sw-block-artifacts/$RUN_ID" \
|
||||
bash scripts/run-k8s-alpha.sh "$PWD"
|
||||
```
|
||||
|
||||
@@ -50,7 +50,7 @@ Expected:
|
||||
|
||||
```bash
|
||||
RUN_ID="$(date -u +%Y%m%dT%H%M%SZ)-iscsi-p4-k8s-chap"
|
||||
SW_BLOCK_ARTIFACT_DIR="/mnt/smb/work/share/g15d-k8s/$RUN_ID" \
|
||||
SW_BLOCK_ARTIFACT_DIR="/tmp/sw-block-artifacts/$RUN_ID" \
|
||||
SW_BLOCK_ISCSI_CHAP_USERNAME=swchap \
|
||||
SW_BLOCK_ISCSI_CHAP_SECRET=swchap-secret \
|
||||
bash scripts/run-k8s-alpha.sh "$PWD"
|
||||
@@ -62,10 +62,11 @@ Expected:
|
||||
- `dynamic-pvc-pod.rendered.yaml` contains:
|
||||
- `csi.storage.k8s.io/node-stage-secret-name`,
|
||||
- `csi.storage.k8s.io/node-stage-secret-namespace`.
|
||||
- `generated-blockvolume.yaml` does not contain `--iscsi-chap-`.
|
||||
- `generated-blockvolume.yaml` contains:
|
||||
- `--iscsi-chap-username=$(SW_BLOCK_ISCSI_CHAP_USERNAME)`,
|
||||
- `--iscsi-chap-secret=$(SW_BLOCK_ISCSI_CHAP_SECRET)`,
|
||||
- `secretKeyRef`,
|
||||
- `SW_BLOCK_ISCSI_CHAP_USERNAME`,
|
||||
- `SW_BLOCK_ISCSI_CHAP_SECRET`,
|
||||
- `chapUsername`,
|
||||
- `chapSecret`.
|
||||
- pod log contains `/data/payload.bin: OK`.
|
||||
|
||||
@@ -35,7 +35,7 @@ for iter in $(seq 1 "$ITERATIONS"); do
|
||||
exit 1
|
||||
fi
|
||||
if [[ -f "$iter_dir/iscsi-sessions.after-delete.txt" ]] &&
|
||||
! grep -q "No active sessions" "$iter_dir/iscsi-sessions.after-delete.txt"; then
|
||||
grep -q "iqn.2026-05.io.seaweedfs" "$iter_dir/iscsi-sessions.after-delete.txt"; then
|
||||
log "iteration ${iter}: dangling iSCSI session"
|
||||
cat "$iter_dir/iscsi-sessions.after-delete.txt" | tee -a "$SUMMARY"
|
||||
exit 1
|
||||
|
||||
Reference in new issue
Block a user