@@ -45,22 +45,45 @@ var (
45
45
` ))
46
46
)
47
47
48
- func newDevStackOptions () * devstack.DevStackOptions {
49
- return & devstack.DevStackOptions {
48
+ type options struct {
49
+ NumberOfHybridNodes int // Number of nodes to start in the cluster
50
+ NumberOfRequesterOnlyNodes int // Number of nodes to start in the cluster
51
+ NumberOfComputeOnlyNodes int // Number of nodes to start in the cluster
52
+ NumberOfBadComputeActors int // Number of compute nodes to be bad actors
53
+ CPUProfilingFile string
54
+ MemoryProfilingFile string
55
+ BasePath string
56
+ WebUIListen string
57
+ }
58
+
59
+ func (o * options ) devstackOptions () []devstack.ConfigOption {
60
+ opts := []devstack.ConfigOption {
61
+ devstack .WithNumberOfHybridNodes (o .NumberOfHybridNodes ),
62
+ devstack .WithNumberOfRequesterOnlyNodes (o .NumberOfRequesterOnlyNodes ),
63
+ devstack .WithNumberOfComputeOnlyNodes (o .NumberOfComputeOnlyNodes ),
64
+ devstack .WithNumberOfBadComputeActors (o .NumberOfBadComputeActors ),
65
+ devstack .WithCPUProfilingFile (o .CPUProfilingFile ),
66
+ devstack .WithMemoryProfilingFile (o .MemoryProfilingFile ),
67
+ devstack .WithBasePath (o .BasePath ),
68
+ }
69
+ return opts
70
+ }
71
+
72
+ func newOptions () * options {
73
+ return & options {
50
74
NumberOfRequesterOnlyNodes : 1 ,
51
75
NumberOfComputeOnlyNodes : 3 ,
52
76
NumberOfBadComputeActors : 0 ,
53
- Peer : "" ,
54
77
CPUProfilingFile : "" ,
55
78
MemoryProfilingFile : "" ,
56
79
BasePath : "" ,
80
+ WebUIListen : config .Default .WebUI .Listen ,
57
81
}
58
82
}
59
83
60
84
//nolint:funlen,gocyclo
61
85
func NewCmd () * cobra.Command {
62
- ODs := newDevStackOptions ()
63
- var webUIListen string
86
+ ODs := newOptions ()
64
87
devstackFlags := map [string ][]configflags.Definition {
65
88
"job-selection" : configflags .JobSelectionFlags ,
66
89
"disable-features" : configflags .DisabledFeatureFlags ,
@@ -83,7 +106,7 @@ func NewCmd() *cobra.Command {
83
106
if err := logger .ConfigureLogging (string (logger .LogModeDefault ), "debug" ); err != nil {
84
107
return fmt .Errorf ("failed to configure logging: %w" , err )
85
108
}
86
- return runDevstack (cmd , ODs , webUIListen )
109
+ return runDevstack (cmd , ODs )
87
110
},
88
111
}
89
112
@@ -108,13 +131,9 @@ func NewCmd() *cobra.Command {
108
131
`How many compute nodes should be bad actors` ,
109
132
)
110
133
devstackCmd .PersistentFlags ().StringVar (
111
- & webUIListen , "webui-address" , config . Default . WebUI . Listen ,
134
+ & ODs . WebUIListen , "webui-address" , ODs . WebUIListen ,
112
135
`Listen address for the web UI server` ,
113
136
)
114
- devstackCmd .PersistentFlags ().StringVar (
115
- & ODs .Peer , "peer" , ODs .Peer ,
116
- `Connect node 0 to another network node` ,
117
- )
118
137
devstackCmd .PersistentFlags ().StringVar (
119
138
& ODs .CPUProfilingFile , "cpu-profiling-file" , ODs .CPUProfilingFile ,
120
139
"File to save CPU profiling to" ,
@@ -131,7 +150,7 @@ func NewCmd() *cobra.Command {
131
150
}
132
151
133
152
//nolint:gocyclo,funlen
134
- func runDevstack (cmd * cobra.Command , ODs * devstack. DevStackOptions , webUIListen string ) error {
153
+ func runDevstack (cmd * cobra.Command , ODs * options ) error {
135
154
ctx := cmd .Context ()
136
155
137
156
cm := util .GetCleanupManager (ctx )
@@ -164,9 +183,7 @@ func runDevstack(cmd *cobra.Command, ODs *devstack.DevStackOptions, webUIListen
164
183
defer os .RemoveAll (baseRepoPath )
165
184
}
166
185
167
- options := ODs .Options ()
168
-
169
- stack , err := devstack .Setup (ctx , cm , options ... )
186
+ stack , err := devstack .Setup (ctx , cm , ODs .devstackOptions ()... )
170
187
if err != nil {
171
188
return err
172
189
}
@@ -177,7 +194,7 @@ func runDevstack(cmd *cobra.Command, ODs *devstack.DevStackOptions, webUIListen
177
194
if n .IsRequesterNode () {
178
195
webuiConfig := webui.Config {
179
196
APIEndpoint : n .APIServer .GetURI ().String (),
180
- Listen : webUIListen ,
197
+ Listen : ODs . WebUIListen ,
181
198
}
182
199
webuiServer , err := webui .NewServer (webuiConfig )
183
200
if err != nil {
0 commit comments