Skip to content

Commit

Permalink
set primary with force
Browse files Browse the repository at this point in the history
* part eleven, prev. commit: 373d60f

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Feb 1, 2025
1 parent 373d60f commit 6c2901b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
20 changes: 13 additions & 7 deletions ais/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2674,13 +2674,7 @@ func (p *proxy) httpdaeget(w http.ResponseWriter, r *http.Request) {
return
}
if checkReady := r.Header.Get(apc.HdrReadyToJoinClu); checkReady != "" {
err := p.pready(smap, true)
if err == nil {
if cmn.GCO.Get().Rebalance.Enabled && smap.CountTargets() > 1 {
err = errors.New(p.String() + ": please disable global rebalance for the duration of the critical (force-join) operation")
}
}
if err != nil {
if err := p.readyToJoinClu(smap); err != nil {
p.writeErr(w, r, err)
return
}
Expand All @@ -2691,6 +2685,18 @@ func (p *proxy) httpdaeget(w http.ResponseWriter, r *http.Request) {
}
}

func (p *proxy) readyToJoinClu(smap *smapX) error {
switch {
case !smap.IsPrimary(p.si):
return newErrNotPrimary(p.si, smap)
case cmn.GCO.Get().Rebalance.Enabled && smap.CountTargets() > 1:
return errors.New(p.String() + ": please disable global rebalance for the duration of the critical (force-join) operation")
case nlog.Stopping():
return p.errStopping()
}
return p.pready(smap, true)
}

func (p *proxy) httpdaeput(w http.ResponseWriter, r *http.Request) {
apiItems, err := p.parseURL(w, r, apc.URLPathDae.L, 0, true)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion ais/psetforce.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (p *proxy) forceJoin(w http.ResponseWriter, r *http.Request, npid string, q
// 2. the first inter-cluster network call:
// get and validate destination Smap, henceforth nsmap
nsmap, ern := p._getSmapCheckReady(nurl)
if _destinationNotReady(ern) {
if ern != nil && _destinationNotReady(ern) {
p.writeErr(w, r, ern)
return
}
Expand Down Expand Up @@ -374,6 +374,7 @@ func (p *proxy) forceJoin(w http.ResponseWriter, r *http.Request, npid string, q
p.metasyncer.becomeNonPrimary()
time.Sleep(time.Second)

// TODO -- FIXME: remove?
// 10. finally, ask npsi to bump versions and metasync all (see `msyncForceAll`)
const act2 = "\"bump\""
nlog.Infoln(act, "(10) npsi to", act2, "metasync")
Expand Down

0 comments on commit 6c2901b

Please sign in to comment.