Skip to content

Commit 4b1e8d0

Browse files
committed
Update cluster config printing
1 parent ad76dca commit 4b1e8d0

File tree

3 files changed

+117
-107
lines changed

3 files changed

+117
-107
lines changed

cli/cmd/lib_cluster_config.go

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/cortexlabs/cortex/pkg/lib/errors"
2828
"github.com/cortexlabs/cortex/pkg/lib/prompt"
2929
s "github.com/cortexlabs/cortex/pkg/lib/strings"
30+
"github.com/cortexlabs/cortex/pkg/lib/table"
3031
)
3132

3233
type AWSCredentials struct {
@@ -204,18 +205,88 @@ func setAWSCredentials(awsCreds *AWSCredentials) error {
204205
}
205206

206207
func confirmClusterConfig(clusterConfig *clusterconfig.ClusterConfig, awsCreds *AWSCredentials) {
207-
fmt.Printf("instance type: %s\n", *clusterConfig.InstanceType)
208-
fmt.Printf("min instances: %d\n", *clusterConfig.MinInstances)
209-
fmt.Printf("max instances: %d\n", *clusterConfig.MaxInstances)
210-
fmt.Printf("cluster name: %s\n", clusterConfig.ClusterName)
211-
fmt.Printf("region: %s\n", clusterConfig.Region)
212-
fmt.Printf("bucket: %s\n", clusterConfig.Bucket)
213-
fmt.Printf("log group: %s\n", clusterConfig.LogGroup)
214-
fmt.Printf("AWS access key ID: %s\n", s.MaskString(awsCreds.AWSAccessKeyID, 4))
208+
defaultCC, _ := clusterconfig.GetFileDefaults()
209+
210+
var items []table.KV
211+
212+
items = append(items, table.KV{K: "instance type", V: *clusterConfig.InstanceType})
213+
items = append(items, table.KV{K: "min instances", V: *clusterConfig.MinInstances})
214+
items = append(items, table.KV{K: "max instances", V: *clusterConfig.MaxInstances})
215+
items = append(items, table.KV{K: "cluster name", V: clusterConfig.ClusterName})
216+
items = append(items, table.KV{K: "region", V: clusterConfig.Region})
217+
items = append(items, table.KV{K: "bucket", V: clusterConfig.Bucket})
218+
219+
if clusterConfig.LogGroup != defaultCC.LogGroup {
220+
items = append(items, table.KV{K: "log group", V: clusterConfig.LogGroup})
221+
}
222+
if clusterConfig.Telemetry != defaultCC.Telemetry {
223+
items = append(items, table.KV{K: "telemetry", V: clusterConfig.Telemetry})
224+
}
225+
226+
items = append(items, table.KV{K: "AWS access key ID", V: s.MaskString(awsCreds.AWSAccessKeyID, 4)})
215227
if awsCreds.CortexAWSAccessKeyID != awsCreds.AWSAccessKeyID {
216-
fmt.Printf("AWS access key ID: %s (cortex)\n", s.MaskString(awsCreds.CortexAWSAccessKeyID, 4))
228+
items = append(items, table.KV{K: "AWS access key ID", V: s.MaskString(awsCreds.CortexAWSAccessKeyID, 4) + " (cortex)"})
229+
}
230+
231+
if clusterConfig.ImagePredictorServe != defaultCC.ImagePredictorServe {
232+
items = append(items, table.KV{K: "image_predictor_serve", V: clusterConfig.ImagePredictorServe})
233+
}
234+
if clusterConfig.ImagePredictorServeGPU != defaultCC.ImagePredictorServeGPU {
235+
items = append(items, table.KV{K: "image_predictor_serve_gpu", V: clusterConfig.ImagePredictorServeGPU})
236+
}
237+
if clusterConfig.ImageTFServe != defaultCC.ImageTFServe {
238+
items = append(items, table.KV{K: "image_tf_serve", V: clusterConfig.ImageTFServe})
239+
}
240+
if clusterConfig.ImageTFServeGPU != defaultCC.ImageTFServeGPU {
241+
items = append(items, table.KV{K: "image_tf_serve_gpu", V: clusterConfig.ImageTFServeGPU})
242+
}
243+
if clusterConfig.ImageTFAPI != defaultCC.ImageTFAPI {
244+
items = append(items, table.KV{K: "image_tf_api", V: clusterConfig.ImageTFAPI})
245+
}
246+
if clusterConfig.ImageONNXServe != defaultCC.ImageONNXServe {
247+
items = append(items, table.KV{K: "image_onnx_serve", V: clusterConfig.ImageONNXServe})
248+
}
249+
if clusterConfig.ImageONNXServeGPU != defaultCC.ImageONNXServeGPU {
250+
items = append(items, table.KV{K: "image_onnx_serve_gpu", V: clusterConfig.ImageONNXServeGPU})
217251
}
218-
fmt.Println()
252+
if clusterConfig.ImageOperator != defaultCC.ImageOperator {
253+
items = append(items, table.KV{K: "image_operator", V: clusterConfig.ImageOperator})
254+
}
255+
if clusterConfig.ImageManager != defaultCC.ImageManager {
256+
items = append(items, table.KV{K: "image_manager", V: clusterConfig.ImageManager})
257+
}
258+
if clusterConfig.ImageDownloader != defaultCC.ImageDownloader {
259+
items = append(items, table.KV{K: "image_downloader", V: clusterConfig.ImageDownloader})
260+
}
261+
if clusterConfig.ImageClusterAutoscaler != defaultCC.ImageClusterAutoscaler {
262+
items = append(items, table.KV{K: "image_cluster_autoscaler", V: clusterConfig.ImageClusterAutoscaler})
263+
}
264+
if clusterConfig.ImageMetricsServer != defaultCC.ImageMetricsServer {
265+
items = append(items, table.KV{K: "image_metrics_server", V: clusterConfig.ImageMetricsServer})
266+
}
267+
if clusterConfig.ImageNvidia != defaultCC.ImageNvidia {
268+
items = append(items, table.KV{K: "image_nvidia", V: clusterConfig.ImageNvidia})
269+
}
270+
if clusterConfig.ImageFluentd != defaultCC.ImageFluentd {
271+
items = append(items, table.KV{K: "image_fluentd", V: clusterConfig.ImageFluentd})
272+
}
273+
if clusterConfig.ImageStatsd != defaultCC.ImageStatsd {
274+
items = append(items, table.KV{K: "image_statsd", V: clusterConfig.ImageStatsd})
275+
}
276+
if clusterConfig.ImageIstioProxy != defaultCC.ImageIstioProxy {
277+
items = append(items, table.KV{K: "image_istio_proxy", V: clusterConfig.ImageIstioProxy})
278+
}
279+
if clusterConfig.ImageIstioPilot != defaultCC.ImageIstioPilot {
280+
items = append(items, table.KV{K: "image_istio_pilot", V: clusterConfig.ImageIstioPilot})
281+
}
282+
if clusterConfig.ImageIstioCitadel != defaultCC.ImageIstioCitadel {
283+
items = append(items, table.KV{K: "image_istio_citadel", V: clusterConfig.ImageIstioCitadel})
284+
}
285+
if clusterConfig.ImageIstioGalley != defaultCC.ImageIstioGalley {
286+
items = append(items, table.KV{K: "image_istio_galley", V: clusterConfig.ImageIstioGalley})
287+
}
288+
289+
fmt.Println(table.AlignKeyValue(items, ":", 1) + "\n")
219290

220291
exitMessage := fmt.Sprintf("Cluster configuration can be modified via the cluster config file; see https://www.cortex.dev/v/%s/cluster-management/config", consts.CortexVersion)
221292
prompt.YesOrExit("Is the configuration above correct?", exitMessage)

pkg/lib/clusterconfig/clusterconfig.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/cortexlabs/cortex/pkg/lib/hash"
2727
"github.com/cortexlabs/cortex/pkg/lib/pointer"
2828
"github.com/cortexlabs/cortex/pkg/lib/prompt"
29+
"github.com/cortexlabs/cortex/pkg/lib/table"
2930
)
3031

3132
type ClusterConfig struct {
@@ -360,3 +361,38 @@ func (cc *ClusterConfig) SetBucket(awsAccessKeyID string, awsSecretAccessKey str
360361
cc.Bucket = "cortex-" + hash.String(awsAccountID)[:10]
361362
return nil
362363
}
364+
365+
func (cc *InternalClusterConfig) String() string {
366+
var items []table.KV
367+
368+
items = append(items, table.KV{K: "cluster version", V: cc.APIVersion})
369+
items = append(items, table.KV{K: "instance type", V: *cc.InstanceType})
370+
items = append(items, table.KV{K: "min instances", V: *cc.MinInstances})
371+
items = append(items, table.KV{K: "max instances", V: *cc.MaxInstances})
372+
items = append(items, table.KV{K: "cluster name", V: cc.ClusterName})
373+
items = append(items, table.KV{K: "region", V: cc.Region})
374+
items = append(items, table.KV{K: "bucket", V: cc.Bucket})
375+
items = append(items, table.KV{K: "log group", V: cc.LogGroup})
376+
items = append(items, table.KV{K: "telemetry", V: cc.Telemetry})
377+
items = append(items, table.KV{K: "image_predictor_serve", V: cc.ImagePredictorServe})
378+
items = append(items, table.KV{K: "image_predictor_serve_gpu", V: cc.ImagePredictorServeGPU})
379+
items = append(items, table.KV{K: "image_tf_serve", V: cc.ImageTFServe})
380+
items = append(items, table.KV{K: "image_tf_serve_gpu", V: cc.ImageTFServeGPU})
381+
items = append(items, table.KV{K: "image_tf_api", V: cc.ImageTFAPI})
382+
items = append(items, table.KV{K: "image_onnx_serve", V: cc.ImageONNXServe})
383+
items = append(items, table.KV{K: "image_onnx_serve_gpu", V: cc.ImageONNXServeGPU})
384+
items = append(items, table.KV{K: "image_operator", V: cc.ImageOperator})
385+
items = append(items, table.KV{K: "image_manager", V: cc.ImageManager})
386+
items = append(items, table.KV{K: "image_downloader", V: cc.ImageDownloader})
387+
items = append(items, table.KV{K: "image_cluster_autoscaler", V: cc.ImageClusterAutoscaler})
388+
items = append(items, table.KV{K: "image_metrics_server", V: cc.ImageMetricsServer})
389+
items = append(items, table.KV{K: "image_nvidia", V: cc.ImageNvidia})
390+
items = append(items, table.KV{K: "image_fluentd", V: cc.ImageFluentd})
391+
items = append(items, table.KV{K: "image_statsd", V: cc.ImageStatsd})
392+
items = append(items, table.KV{K: "image_istio_proxy", V: cc.ImageIstioProxy})
393+
items = append(items, table.KV{K: "image_istio_pilot", V: cc.ImageIstioPilot})
394+
items = append(items, table.KV{K: "image_istio_citadel", V: cc.ImageIstioCitadel})
395+
items = append(items, table.KV{K: "image_istio_galley", V: cc.ImageIstioGalley})
396+
397+
return table.AlignKeyValue(items, ":", 1)
398+
}

pkg/lib/clusterconfig/formatter.go

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)