-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
135 lines (124 loc) · 3.69 KB
/
Copy pathconfig.go
File metadata and controls
135 lines (124 loc) · 3.69 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package cmd
import (
"fmt"
"strings"
)
type RunConfig struct {
Engines []string
ServerInstance string
ClientInstance string
ServerArch string
ClientArch string
Region string
AvailabilityZone string
SSHUser string
MemtierThreads int
MemtierRatio string
MemtierDataSize int
MemtierPipeline int
MemtierClients int
MemtierRequests int
DistinctClientSeed bool
WarmupRequests int
Trials int
Output string
SkipDestroy bool
// Optional replication topology. quickstart wires this up to stay
// symmetric with setup; the memtier benchmark itself never reads it.
Replicas int
ReplicaInstance string
ReplicaArch string
}
// ValidOutput is the set of accepted --output values.
var ValidOutput = map[string]bool{
"table": true,
"json": true,
"csv": true,
}
// ValidArch is the set of accepted --server-arch / --client-arch values.
// These match what `uname -m` reports on Linux.
var ValidArch = map[string]bool{
"x86_64": true,
"arm64": true,
}
// ValidUbuntuVersion is the set of accepted --ubuntu-version values.
// Canonical publishes SSM AMI parameters for each, and newer releases ship
// a newer glibc (24.04, for example, provides GLIBC_2.38).
var ValidUbuntuVersion = map[string]bool{
"20.04": true,
"22.04": true,
"24.04": true,
}
// DetectArch guesses the CPU architecture of an EC2 instance type from its
// family name: a1 and the Graviton families (c7g, m7g, t4g, ...) are arm64,
// everything else is x86_64. Only used for non-fatal mismatch warnings.
func DetectArch(instanceType string) string {
fam := instanceType
if i := strings.Index(instanceType, "."); i > 0 {
fam = instanceType[:i]
}
if strings.HasPrefix(fam, "a1") {
return "arm64"
}
// Grab the letters after the generation digit, e.g. "c6gn" -> "gn".
i := len(fam) - 1
for i >= 0 && fam[i] >= 'a' && fam[i] <= 'z' {
i--
}
if i >= 0 && i+1 < len(fam) && strings.HasPrefix(fam[i+1:], "g") {
return "arm64"
}
return "x86_64"
}
// clusterPlacementUnsupportedFamilies lists the EC2 instance families AWS
// rejects in cluster placement groups. It's a blocklist so new families
// work by default.
var clusterPlacementUnsupportedFamilies = []string{
"t2", "t3", "t3a", "t4g", // burstable
"a1", // first-gen Graviton, no ENA
"mac1", "mac2", // dedicated-tenancy macOS bare-metal
}
// ValidateClusterPlacementCompatible returns an error when instanceType is
// in a family that can't join a cluster placement group (which the rendered
// CFN template always uses). Catching it up front saves a slow CreateStack
// rollback. role names the offending flag in the error.
func ValidateClusterPlacementCompatible(role, instanceType string) error {
fam := instanceType
if i := strings.Index(instanceType, "."); i > 0 {
fam = instanceType[:i]
}
fam = strings.ToLower(fam)
for _, bad := range clusterPlacementUnsupportedFamilies {
if fam == bad {
return fmt.Errorf(
"--%s-instance %q: %s-family instances do not support cluster placement groups "+
"(required by dfbench for same-rack benchmark isolation). "+
"Use a c/m/r family instead (e.g. c5.large, c6i.large, c7g.large for arm64)",
role, instanceType, fam)
}
}
return nil
}
func parseEngines(raw string) ([]string, bool) {
parts := strings.Split(raw, ",")
var engines []string
for _, p := range parts {
p = strings.TrimSpace(strings.ToLower(p))
if p == "" {
continue
}
if !validEngines[p] {
return nil, false
}
engines = append(engines, p)
}
if len(engines) == 0 {
return nil, false
}
return engines, true
}
var validEngines = map[string]bool{
"dragonfly": true,
"redis": true,
"valkey": true,
}