mirror of
https://github.com/openziti/ziti.git
synced 2026-11-25 08:52:03 +00:00
7f2f619e88
- adds a startup reconcile that asks the leader to move this node's stored raft address to its configured advertise address, retrying with jittered backoff until the change is visible locally - wakes the running reconcile on leader events instead of starting a second one, and jitters the first attempt and each wake so controllers reconciling after the same event spread their requests - keeps checking a node whose copy of the configuration doesn't list it yet, as after a restart before any of the log reached it, instead of treating it as reconciled - adds an UpdatePeerAddressRequest peer message carrying the member id, the address the node believes is stored and the new address; the leader accepts it only from the node it names and does not forward it - adds updateMemberAddressAsLeader, which changes a member's address in place, keeping its suffrage, after refusing non-members, addresses held by another member and stale from addresses - probes the new address as a sanity check, refusing the change if a different controller answers and making it with a warning if the address can't be reached, since some controllers only dial out - conditions the update on a configuration index read from the raft log and snapshot stores, since GetConfiguration().Index() is always zero in the pinned raft version - routes AddPeer requests that find an existing member at a new address to the in-place update instead of remove and re-add, identifying the member through GetPeerInfo rather than the request id - falls back to the member id when the raft transport dials a stored address with no peer connected at it - adds a probe hello header so probe connections are closed without registering a peer - excludes self by server id in GetPeerAddresses - corrects the inverted voter flag in the peer AddPeer log and removes the unused ctrlAddress field - tests single-node, follower, non-voter and leader address changes, refused and unverified addresses, requests from the wrong sender, membership changes made while a member is offline or during the probe, and configuration lookup across snapshots and log gaps - tests the reconcile starting on an empty log and waiting until the configuration lists the node - waits in the HA test harness for a restarted peer's own configuration to list it before restarting it - adds a changelog entry describing the address update and the leader version requirement
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
/*
|
|
Copyright NetFoundry Inc.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package handler_peer_ctrl
|
|
|
|
import (
|
|
"crypto/x509"
|
|
|
|
"github.com/openziti/channel/v5"
|
|
"github.com/openziti/ziti/v2/controller/raft/mesh"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// requireSentBy returns an error unless ch's peer certificate identifies the controller memberId.
|
|
func requireSentBy(ch channel.Channel, memberId string) error {
|
|
return checkSentBy(ch.Underlay().Certificates(), memberId)
|
|
}
|
|
|
|
// checkSentBy returns an error unless certs carry the controller SPIFFE id memberId.
|
|
func checkSentBy(certs []*x509.Certificate, memberId string) error {
|
|
id, err := mesh.ExtractSpiffeId(certs)
|
|
if err != nil {
|
|
return errors.Wrap(err, "unable to identify sending controller")
|
|
}
|
|
if id != memberId {
|
|
return errors.Errorf("request for member %s was sent by controller %s", memberId, id)
|
|
}
|
|
return nil
|
|
}
|