forked from aerospike/aerospike-management-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aeroinfo.go
102 lines (81 loc) · 3.77 KB
/
aeroinfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package deployment
import (
"fmt"
"github.com/go-logr/logr"
aero "github.com/aerospike/aerospike-client-go/v7"
)
// IsClusterAndStable returns true if the cluster formed by the set of hosts is stable.
func IsClusterAndStable(log logr.Logger, policy *aero.ClientPolicy, allHosts []*HostConn) (bool, error) {
c, err := newCluster(log, policy, allHosts, allHosts)
if err != nil {
return false, fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.IsClusterAndStable(getHostIDsFromHostConns(allHosts))
}
// InfoQuiesce quiesce hosts.
func InfoQuiesce(log logr.Logger, policy *aero.ClientPolicy, allHosts, selectedHosts []*HostConn,
removedNamespaces []string) error {
c, err := newCluster(log, policy, allHosts, selectedHosts)
if err != nil {
return fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.InfoQuiesce(getHostIDsFromHostConns(selectedHosts), getHostIDsFromHostConns(allHosts), removedNamespaces)
}
// InfoQuiesceUndo revert the effects of quiesce on the next recluster event
func InfoQuiesceUndo(log logr.Logger, policy *aero.ClientPolicy, allHosts []*HostConn) error {
c, err := newCluster(log, policy, allHosts, allHosts)
if err != nil {
return fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.InfoQuiesceUndo(getHostIDsFromHostConns(allHosts))
}
// InfoRecluster recluster hosts.
func InfoRecluster(log logr.Logger, policy *aero.ClientPolicy, allHosts []*HostConn) error {
c, err := newCluster(log, policy, allHosts, allHosts)
if err != nil {
return fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.InfoRecluster(getHostIDsFromHostConns(allHosts))
}
// GetQuiescedNodes returns a list of node hostIDs of all nodes that are pending_quiesce=true.
func GetQuiescedNodes(log logr.Logger, policy *aero.ClientPolicy, allHosts []*HostConn) ([]string, error) {
c, err := newCluster(log, policy, allHosts, allHosts)
if err != nil {
return nil, fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.getQuiescedNodes(getHostIDsFromHostConns(allHosts))
}
// SetMigrateFillDelay sets the given migrate-fill-delay on all the given cluster nodes
func SetMigrateFillDelay(log logr.Logger, policy *aero.ClientPolicy, allHosts []*HostConn, migrateFillDelay int) error {
c, err := newCluster(log, policy, allHosts, allHosts)
if err != nil {
return fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.setMigrateFillDelay(migrateFillDelay, allHosts)
}
// SetConfigCommandsOnHosts runs set config command for dynamic config on all the given cluster nodes
func SetConfigCommandsOnHosts(log logr.Logger, policy *aero.ClientPolicy, allHosts, selectedHosts []*HostConn,
cmds []string) ([]string, error) {
c, err := newCluster(log, policy, allHosts, selectedHosts)
if err != nil {
return nil, fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.setConfigCommandsOnHosts(cmds, selectedHosts)
}
// GetClusterNamespaces gets the cluster namespaces
func GetClusterNamespaces(log logr.Logger, policy *aero.ClientPolicy,
allHosts []*HostConn) (map[string][]string, error) {
c, err := newCluster(log, policy, allHosts, allHosts)
if err != nil {
return nil, fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.getClusterNamespaces(getHostIDsFromHostConns(allHosts))
}
func GetInfoOnHosts(log logr.Logger, policy *aero.ClientPolicy,
allHosts []*HostConn, cmd string) (map[string]InfoResult, error) {
c, err := newCluster(log, policy, allHosts, allHosts)
if err != nil {
return nil, fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}
return c.infoOnHosts(getHostIDsFromHostConns(allHosts), cmd)
}