Documentation
¶
Index ¶
- Constants
- Variables
- func CheckCert(r *http.Request, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, ...) bool
- func Connect(address string, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, ...) (incus.InstanceServer, error)
- func ConnectIfBucketIsRemote(s *state.State, poolName string, projectName string, bucketName string, ...) (incus.InstanceServer, error)
- func ConnectIfInstanceIsRemote(s *state.State, projectName string, instName string, r *http.Request) (incus.InstanceServer, error)
- func ConnectIfVolumeIsRemote(s *state.State, poolName string, projectName string, volumeName string, ...) (incus.InstanceServer, error)
- func Enabled(database *db.Node) (bool, error)
- func EnsureServerCertificateTrusted(serverName string, serverCertx509 *x509.Certificate, tx *db.ClusterTx) error
- func EventHubPush(event api.Event)
- func EventListenerWait(ctx context.Context, address string) error
- func EventsUpdateListeners(s *state.State, hbMembers map[int64]cowsqldb.HeartbeatMember, ...)
- func HasConnectivity(networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, address string, ...) bool
- func HeartbeatTask(gateway cluster.Gateway) (task.Func, task.Schedule)
- func ListDatabaseNodes(database *db.Node) ([]string, error)
- func MemberState(ctx context.Context, s *state.State, memberName string) (*api.ClusterMemberState, error)
- func NewGateway(ctx context.Context, database *db.Node, stateFunc func() *state.State, ...) (cluster.Gateway, error)
- func NotifyUpgradeCompleted(s *state.State, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo) error
- func PreUpdateCheck(s *state.State) (func() error, error)
- func Reconfigure(database *db.Node, raftNodes []db.RaftNode) error
- func Recover(database *db.Node) error
- func ResolveTarget(ctx context.Context, s *state.State, targetMember string) (string, error)
- func RoleInSlice(role db.ClusterRole, roles []db.ClusterRole) bool
- func SetClusterDB(g cluster.Gateway, database *db.Cluster)
- func SetupTrust(serverCert *localtls.CertInfo, serverName string, targetAddress string, ...) error
- func UpdateTrust(serverCert *localtls.CertInfo, serverName string, targetAddress string, ...) error
- type APIHeartbeat
- type ClusterResources
- type EventMode
- type Notifier
- type NotifierPolicy
Constants ¶
const ( NotifyAll = cluster.NotifyAll // Requires that all nodes are up. NotifyAlive = cluster.NotifyAlive // Only notifies nodes that are alive NotifyTryAll = cluster.NotifyTryAll // Attempt to notify all nodes regardless of state. )
Possible notification policies.
Variables ¶
var SchemaVersion = cluster.SchemaVersion
SchemaVersion holds the version of the cluster database schema.
Functions ¶
func CheckCert ¶ added in v7.6.0
func CheckCert(r *http.Request, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, trustedCerts map[string]x509.Certificate) bool
CheckCert checks certificate access, returns true if certificate is trusted.
func Connect ¶
func Connect(address string, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, r *http.Request, notify bool) (incus.InstanceServer, error)
Connect is a convenience around incus.ConnectIncus that configures the client with the correct parameters for node-to-node communication.
If 'notify' switch is true, then the user agent will be set to the special to the UserAgentNotifier value, which can be used in some cases to distinguish between a regular client request and an internal cluster request.
func ConnectIfBucketIsRemote ¶ added in v7.0.2
func ConnectIfBucketIsRemote(s *state.State, poolName string, projectName string, bucketName string, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, r *http.Request) (incus.InstanceServer, error)
ConnectIfBucketIsRemote figures out the address of the cluster member on which the bucket with the given name is defined. If it's not the local cluster member it will connect to it and return the connected client, otherwise it just returns nil. If there is more than one cluster member with a matching bucket name, an error is returned.
func ConnectIfInstanceIsRemote ¶
func ConnectIfInstanceIsRemote(s *state.State, projectName string, instName string, r *http.Request) (incus.InstanceServer, error)
ConnectIfInstanceIsRemote figures out the address of the cluster member which is running the instance with the given name in the specified project. If it's not the local member will connect to it and return the connected client (configured with the specified project), otherwise it will just return nil.
func ConnectIfVolumeIsRemote ¶
func ConnectIfVolumeIsRemote(s *state.State, poolName string, projectName string, volumeName string, volumeType int, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, r *http.Request) (incus.InstanceServer, error)
ConnectIfVolumeIsRemote figures out the address of the cluster member on which the volume with the given name is defined. If it's not the local cluster member it will connect to it and return the connected client, otherwise it just returns nil. If there is more than one cluster member with a matching volume name, an error is returned.
func EnsureServerCertificateTrusted ¶
func EnsureServerCertificateTrusted(serverName string, serverCertx509 *x509.Certificate, tx *db.ClusterTx) error
EnsureServerCertificateTrusted adds the serverCert to the DB trusted certificates store using the serverName. If a certificate with the same fingerprint is already in the trust store, but is of the wrong type or name then the existing certificate is updated to the correct type and name. If the existing certificate is the correct type but the wrong name then an error is returned. And if the existing certificate is the correct type and name then nothing more is done.
func EventHubPush ¶
EventHubPush pushes the event to the event hub members if local server is an event-hub client.
func EventListenerWait ¶
EventListenerWait waits for there to be listener connected to the specified address, or one of the event hubs if operating in event hub mode.
func EventsUpdateListeners ¶
func EventsUpdateListeners(s *state.State, hbMembers map[int64]cowsqldb.HeartbeatMember, inject events.InjectFunc)
EventsUpdateListeners refreshes the cluster event listener connections.
func HasConnectivity ¶
func HasConnectivity(networkCert *localtls.CertInfo, serverCert *localtls.CertInfo, address string, apiCheck bool) bool
HasConnectivity probes the member with the given address for connectivity.
func HeartbeatTask ¶
HeartbeatTask returns a task function that performs leader-initiated heartbeat checks against all cluster members in the cluster.
It will update the heartbeat timestamp column of the nodes table accordingly, and also notify them of the current list of database nodes.
func ListDatabaseNodes ¶
ListDatabaseNodes returns a list of database node names.
func MemberState ¶
func MemberState(ctx context.Context, s *state.State, memberName string) (*api.ClusterMemberState, error)
MemberState retrieves state information about the cluster member.
func NewGateway ¶
func NewGateway(ctx context.Context, database *db.Node, stateFunc func() *state.State, networkCert *tls.CertInfo, serverCertFunc func() *tls.CertInfo, opts ...options.Option) (cluster.Gateway, error)
NewGateway instantiates a new cluster gateway.
func NotifyUpgradeCompleted ¶
func NotifyUpgradeCompleted(s *state.State, networkCert *localtls.CertInfo, serverCert *localtls.CertInfo) error
NotifyUpgradeCompleted sends a notification to all other nodes in the cluster that any possible pending database update has been applied, and any nodes which was waiting for this node to be upgraded should re-check if it's okay to move forward.
func PreUpdateCheck ¶ added in v7.6.0
PreUpdateCheck checks for the INCUS_CLUSTER_UPDATE env var and returns the resulting executable path.
func Reconfigure ¶
Reconfigure replaces the entire cluster configuration. Addresses and node roles may be updated. Node IDs are read-only.
func ResolveTarget ¶
ResolveTarget is a convenience for resolving a target member name to address. It returns the address of the given member, or the empty string if the given member is the local one.
func RoleInSlice ¶
func RoleInSlice(role db.ClusterRole, roles []db.ClusterRole) bool
RoleInSlice returns whether or not the rule is within the roles list.
func SetClusterDB ¶ added in v7.6.0
SetClusterDB applies the cluster database to the gateway.
func SetupTrust ¶
func SetupTrust(serverCert *localtls.CertInfo, serverName string, targetAddress string, targetCert string, targetToken string) error
SetupTrust is a convenience around InstanceServer.CreateCertificate that adds the given server certificate to the trusted pool of the cluster at the given address, using the given token. The certificate is added as type CertificateTypeServer to allow intra-member communication. If a certificate with the same fingerprint already exists with a different name or type, then no error is returned.
func UpdateTrust ¶
func UpdateTrust(serverCert *localtls.CertInfo, serverName string, targetAddress string, targetCert string) error
UpdateTrust ensures that the supplied certificate is stored in the target trust store with the correct name and type to ensure correct cluster operation. Should be called after SetupTrust. If a certificate with the same fingerprint is already in the trust store, but is of the wrong type or name then the existing certificate is updated to the correct type and name. If the existing certificate is the correct type but the wrong name then an error is returned. And if the existing certificate is the correct type and name then nothing more is done.
Types ¶
type APIHeartbeat ¶
type APIHeartbeat = heartbeat.APIHeartbeat
APIHeartbeat contains data sent to nodes in heartbeat.
type ClusterResources ¶ added in v7.6.0
type ClusterResources struct {
Pools map[string]map[string]string
Networks map[string]map[string]string
Operations []cluster.Operation
}
ClusterResources represents non-cowsql related cluster resources.
type EventMode ¶
type EventMode string
EventMode indicates the event distribution mode.
const EventModeFullMesh EventMode = "full-mesh"
EventModeFullMesh is when every cluster member connects to every other cluster member to pull events.
const EventModeHubClient EventMode = "hub-client"
EventModeHubClient is when the cluster is operating in event-hub mode and this member is designated as a hub client, meaning that it is expected to connect to the event-hub members.
const EventModeHubServer EventMode = "hub-server"
EventModeHubServer is when the cluster is operating in event-hub mode and this server is designated as a hub server, meaning that it will only connect to the other event-hub members and not other members.
func ServerEventMode ¶
func ServerEventMode() EventMode
ServerEventMode returns the event distribution mode that this local server is operating in.
type Notifier ¶
type Notifier func(hook func(incus.InstanceServer) error) error
Notifier is a function that invokes the given function against each node in the cluster excluding the invoking one.
type NotifierPolicy ¶
type NotifierPolicy = cluster.NotifierPolicy
NotifierPolicy can be used to tweak the behavior of NewNotifier in case of some nodes are down.