mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
mini: admit volume servers started against the embedded master (#13416)
* mini: admit volume servers started against the embedded master A single-master weed mini pinned its embedded volume server as the only admitted reporter, so the master refused every extra weed volume pointed at it. Use the expected-reporter release a single-master weed server already uses: the embedded server's first clean inventory still collapses the post-mint allocation hold, and other volume servers are admitted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mini: test that a single-master mini does not pin its volume server Move the reporter choice into setMiniExpectedReporter so a command-level test can check it: the embedded volume server is the expected reporter in single-master mode, never the only admitted one, and a multi-master rerun clears it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
39f568f614
commit
68d56d8ff8
6 files changed
+82
-31
No files matched your search
@@ -86,19 +86,16 @@ type MasterOptions struct {
|
||||
// standalone weed master.
|
||||
shutdownCtx context.Context
|
||||
// releaseAllocOnFirstReport lifts the post-mint allocation hold as soon as
|
||||
// one full volume-server inventory has been applied. weed mini sets it in
|
||||
// single-master mode, with singleReporterAddr pinning the embedded volume
|
||||
// server as the only admitted reporter: any other volume server is refused,
|
||||
// so the warmup window after a fresh topology id is dead time.
|
||||
// Standalone weed master can face late-arriving veterans and must keep
|
||||
// the window; a single-master weed server releases on its embedded
|
||||
// volume server's clean report through expectedReporterAddr instead.
|
||||
// one full volume-server inventory has been applied, with
|
||||
// singleReporterAddr pinning the only admitted reporter: any other volume
|
||||
// server is refused, so the warmup window after a fresh topology id is
|
||||
// dead time.
|
||||
releaseAllocOnFirstReport bool
|
||||
singleReporterAddr string
|
||||
// expectedReporterAddr names the reporter whose first clean inventory
|
||||
// collapses the post-mint allocation hold to a confirm pulse without
|
||||
// refusing others: a single-master weed server points it at its
|
||||
// embedded volume server.
|
||||
// refusing others: a single-master weed server or weed mini points it at
|
||||
// its embedded volume server.
|
||||
expectedReporterAddr string
|
||||
}
|
||||
|
||||
|
||||
+16
-17
@@ -606,6 +606,20 @@ func miniMqBrokerAddress() string {
|
||||
return util.JoinHostPort(*miniIp, *miniMqBrokerOptions.port)
|
||||
}
|
||||
|
||||
// setMiniExpectedReporter mirrors a single-master weed server: the embedded
|
||||
// volume server's first clean inventory collapses the post-mint allocation
|
||||
// hold to a confirm pulse, while volume servers started later against this
|
||||
// master are still admitted. Multi-master minis keep the regular hold.
|
||||
// Re-derived on every run: the package-level options survive in-process
|
||||
// reruns, so a multi-master mini after a single-master one must not inherit
|
||||
// the expected reporter.
|
||||
func setMiniExpectedReporter() {
|
||||
miniMasterOptions.expectedReporterAddr = ""
|
||||
if isSingleMasterMode(*miniMasterOptions.peers) {
|
||||
miniMasterOptions.expectedReporterAddr = util.JoinHostPort(*miniIp, *miniOptions.v.port)
|
||||
}
|
||||
}
|
||||
|
||||
// initMiniWebDAVFlags initializes WebDAV server flag options
|
||||
func initMiniWebDAVFlags() {
|
||||
miniWebDavOptions.port = cmdMini.Flag.Int("webdav.port", 7333, "webdav server http listen port")
|
||||
@@ -1698,23 +1712,8 @@ func runMini(cmd *Command, args []string) bool {
|
||||
// tear those services down too. On Ctrl+C they rely on their own
|
||||
// OnInterrupt hooks (see grace's LIFO ordering).
|
||||
miniMasterOptions.shutdownCtx = MiniClusterCtx
|
||||
// In single-master mode mini's embedded volume server is the only reporter
|
||||
// of prior cluster state; its first heartbeat already carries the full
|
||||
// inventory, so the post-mint allocation hold ends there instead of
|
||||
// running the whole warmup window on every fresh start. The master pins
|
||||
// the embedded address and refuses any other volume server, keeping the
|
||||
// single-reporter assumption true. Multi-master minis can field
|
||||
// late-reporting volume servers and keep the regular hold.
|
||||
// Both fields are re-derived on every run: the package-level options
|
||||
// survive in-process reruns, so a multi-master mini after a
|
||||
// single-master one must not inherit the release or the stale pin.
|
||||
singleMaster := isSingleMasterMode(*miniMasterOptions.peers)
|
||||
miniMasterOptions.releaseAllocOnFirstReport = singleMaster
|
||||
miniMasterOptions.singleReporterAddr = ""
|
||||
miniFilerOptions.skipEmptyMembershipConfirm = singleMaster
|
||||
if singleMaster {
|
||||
miniMasterOptions.singleReporterAddr = util.JoinHostPort(*miniIp, *miniOptions.v.port)
|
||||
}
|
||||
setMiniExpectedReporter()
|
||||
miniFilerOptions.skipEmptyMembershipConfirm = isSingleMasterMode(*miniMasterOptions.peers)
|
||||
miniOptions.v.shutdownCtx = MiniClusterCtx
|
||||
miniFilerOptions.shutdownCtx = MiniClusterCtx
|
||||
// Mini is a small/dev setup with short-lived RPCs; cap the filer's
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package command
|
||||
|
||||
import "testing"
|
||||
|
||||
// A single-master mini names its embedded volume server only as the reporter
|
||||
// whose inventory lifts the post-mint hold; it must not pin it as the only
|
||||
// admitted one, or volume servers added to the mini are refused.
|
||||
func TestMiniSingleMasterAdmitsOutsideVolumeServers(t *testing.T) {
|
||||
oldPeers, oldIp, oldPort := *miniMasterOptions.peers, *miniIp, *miniOptions.v.port
|
||||
oldExpected := miniMasterOptions.expectedReporterAddr
|
||||
defer func() {
|
||||
*miniMasterOptions.peers, *miniIp, *miniOptions.v.port = oldPeers, oldIp, oldPort
|
||||
miniMasterOptions.expectedReporterAddr = oldExpected
|
||||
}()
|
||||
*miniIp, *miniOptions.v.port = "10.0.0.1", 8080
|
||||
|
||||
*miniMasterOptions.peers = "none"
|
||||
setMiniExpectedReporter()
|
||||
if miniMasterOptions.releaseAllocOnFirstReport || miniMasterOptions.singleReporterAddr != "" {
|
||||
t.Fatalf("single-master mini pins its embedded volume server: release=%v reporter=%q", miniMasterOptions.releaseAllocOnFirstReport, miniMasterOptions.singleReporterAddr)
|
||||
}
|
||||
if got := miniMasterOptions.expectedReporterAddr; got != "10.0.0.1:8080" {
|
||||
t.Fatalf("expected reporter = %q, want 10.0.0.1:8080", got)
|
||||
}
|
||||
|
||||
*miniMasterOptions.peers = "10.0.0.1:9333,10.0.0.2:9333,10.0.0.3:9333"
|
||||
setMiniExpectedReporter()
|
||||
if got := miniMasterOptions.expectedReporterAddr; got != "" {
|
||||
t.Fatalf("multi-master mini kept expected reporter %q", got)
|
||||
}
|
||||
}
|
||||
@@ -108,3 +108,26 @@ func TestSendHeartbeatRejectsAddresslessFirstHeartbeat(t *testing.T) {
|
||||
assert.Zero(t, uint32(ms.Topo.GetMaxVolumeId()))
|
||||
assert.Empty(t, stream.sent)
|
||||
}
|
||||
|
||||
// The expected-reporter release a single-master weed server or weed mini
|
||||
// uses gates only which report lifts the allocation hold: volume servers
|
||||
// started beside the embedded one are still admitted and applied.
|
||||
func TestSendHeartbeatAdmitsOutsideReporterBesideExpected(t *testing.T) {
|
||||
ms := newLeaderMaster()
|
||||
ms.Topo.RaftServer = admitTestRaftServer{}
|
||||
ms.Topo.ReleaseAllocationOnReport("10.0.0.1:8080")
|
||||
|
||||
stream := &fakeHeartbeatStream{heartbeats: []*master_pb.Heartbeat{{
|
||||
Ip: "10.0.0.2",
|
||||
Port: 8080,
|
||||
MaxVolumeIdSeen: 7,
|
||||
HasNoVolumes: true,
|
||||
}}}
|
||||
|
||||
err := ms.SendHeartbeat(stream)
|
||||
if err != nil {
|
||||
assert.NotContains(t, err.Error(), "rejected")
|
||||
}
|
||||
assert.EqualValues(t, 7, ms.Topo.GetMaxVolumeId())
|
||||
assert.NotEmpty(t, stream.sent)
|
||||
}
|
||||
@@ -72,14 +72,15 @@ type MasterOption struct {
|
||||
VolumeGrowthDisabled bool
|
||||
// ReleaseAllocOnFirstReport lifts the post-mint allocation hold as soon as
|
||||
// one full volume-server inventory has been applied, for setups whose
|
||||
// embedded volume server is the only possible reporter (weed mini).
|
||||
// embedded volume server is the only possible reporter.
|
||||
// SingleVolumeReporter pins that reporter's ip:port; any other volume
|
||||
// server trying to register is rejected.
|
||||
ReleaseAllocOnFirstReport bool
|
||||
SingleVolumeReporter string
|
||||
// ExpectedReporterAddr names the one volume server whose first clean full
|
||||
// inventory lifts the post-mint allocation hold (a single-master weed
|
||||
// server's embedded volume server). Other reporters are still admitted.
|
||||
// inventory lifts the post-mint allocation hold (the embedded volume
|
||||
// server of a single-master weed server or weed mini). Other reporters
|
||||
// are still admitted.
|
||||
ExpectedReporterAddr string
|
||||
}
|
||||
|
||||
|
||||
@@ -2045,8 +2045,8 @@ func (t *Topology) SetTopologyInitPending(pending bool) {
|
||||
// ReleaseAllocationOnFirstReport opts the topology into lifting the post-mint
|
||||
// allocation hold once one full volume-server inventory has been applied, and
|
||||
// pins the admitted volume-server reporter: the early release is only sound
|
||||
// when a single embedded server (weed mini) can carry prior cluster state, so
|
||||
// every other reporter must be refused rather than silently trusted.
|
||||
// when a single embedded server can carry prior cluster state, so every other
|
||||
// reporter must be refused rather than silently trusted.
|
||||
func (t *Topology) ReleaseAllocationOnFirstReport(onlyReporter ...string) {
|
||||
if len(onlyReporter) > 0 {
|
||||
t.singleReporter.Store(onlyReporter[0])
|
||||
|
||||
Reference in new issue
Block a user