Skip to content

Commit 60b907b

Browse files
authored
Misc UI improvements (#2229)
1 parent 7cb3ebf commit 60b907b

File tree

8 files changed

+24
-89
lines changed

8 files changed

+24
-89
lines changed

cli/cmd/cluster.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,7 @@ func printInfoPricing(infoResponse *schema.InfoResponse, clusterConfig clusterco
896896
totalInstancePrice += nodeInfo.Price
897897
}
898898

899-
rows = append(rows, []interface{}{fmt.Sprintf("nodegroup %s: %d (out of %d) %s for your apis", ng.Name, numInstances, ng.MaxInstances, s.PluralS("instance", numInstances)), s.DollarsAndTenthsOfCents(totalInstancePrice) + " total"})
900-
rows = append(rows, []interface{}{fmt.Sprintf("nodegroup %s: %d (out of %d) %dgb ebs %s for your apis", ng.Name, numInstances, ng.MaxInstances, ng.InstanceVolumeSize, s.PluralS("volume", numInstances)), s.DollarsAndTenthsOfCents(totalEBSPrice) + " total"})
899+
rows = append(rows, []interface{}{fmt.Sprintf("nodegroup %s: %d (out of %d) %s", ng.Name, numInstances, ng.MaxInstances, s.PluralS("instance", numInstances)), s.DollarsAndTenthsOfCents(totalInstancePrice+totalEBSPrice) + " total"})
901900

902901
totalNodeGroupsPrice += totalEBSPrice + totalInstancePrice
903902
}
@@ -911,9 +910,8 @@ func printInfoPricing(infoResponse *schema.InfoResponse, clusterConfig clusterco
911910
totalPrice := eksPrice + totalNodeGroupsPrice + 2*(operatorInstancePrice+operatorEBSPrice) + metricsEBSPrice + nlbPrice*2 + natTotalPrice
912911
fmt.Printf(console.Bold("\nyour cluster currently costs %s per hour\n\n"), s.DollarsAndCents(totalPrice))
913912

914-
rows = append(rows, []interface{}{"2 t3.medium instances for cortex", s.DollarsMaxPrecision(operatorInstancePrice * 2)})
915-
rows = append(rows, []interface{}{"2 20gb ebs volumes for the operator", s.DollarsAndTenthsOfCents(operatorEBSPrice * 2)})
916-
rows = append(rows, []interface{}{"1 40+2gb ebs volumes for metrics (prometheus and grafana)", s.DollarsAndTenthsOfCents(metricsEBSPrice)})
913+
operatorPrice := 2*(operatorInstancePrice+operatorEBSPrice) + metricsEBSPrice
914+
rows = append(rows, []interface{}{"2 t3.medium instances (cortex system)", s.DollarsAndTenthsOfCents(operatorPrice)})
917915
rows = append(rows, []interface{}{"2 network load balancers", s.DollarsMaxPrecision(nlbPrice*2) + " total"})
918916

919917
if clusterConfig.NATGateway == clusterconfig.SingleNATGateway {

cli/cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func deleteInit() {
4747

4848
var _deleteCmd = &cobra.Command{
4949
Use: "delete API_NAME [JOB_ID]",
50-
Short: "delete any kind of api or stop a batch job",
50+
Short: "delete an api or stop a job",
5151
Args: cobra.RangeArgs(1, 2),
5252
Run: func(cmd *cobra.Command, args []string) {
5353
envName, err := getEnvFromFlag(_flagDeleteEnv)

cli/cmd/deploy.go

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ import (
2525
"github.com/cortexlabs/cortex/pkg/lib/exit"
2626
"github.com/cortexlabs/cortex/pkg/lib/files"
2727
libjson "github.com/cortexlabs/cortex/pkg/lib/json"
28-
"github.com/cortexlabs/cortex/pkg/lib/pointer"
2928
"github.com/cortexlabs/cortex/pkg/lib/print"
30-
"github.com/cortexlabs/cortex/pkg/lib/table"
3129
"github.com/cortexlabs/cortex/pkg/lib/telemetry"
3230
"github.com/cortexlabs/cortex/pkg/operator/schema"
33-
"github.com/cortexlabs/cortex/pkg/types/userconfig"
3431
"github.com/spf13/cobra"
3532
)
3633

@@ -106,10 +103,7 @@ var _deployCmd = &cobra.Command{
106103
}
107104
fmt.Print(string(bytes))
108105
case flags.PrettyOutputType:
109-
message, err := deployMessage(deployResults, env.Name)
110-
if err != nil {
111-
exit.Error(err)
112-
}
106+
message := mergeResultMessages(deployResults)
113107
if didAnyResultsError(deployResults) {
114108
print.StderrBoldFirstBlock(message)
115109
} else {
@@ -155,21 +149,6 @@ func getDeploymentBytes(configPath string) (map[string][]byte, error) {
155149
return uploadBytes, nil
156150
}
157151

158-
func deployMessage(results []schema.DeployResult, envName string) (string, error) {
159-
statusMessage := mergeResultMessages(results)
160-
161-
if didAllResultsError(results) {
162-
return statusMessage, nil
163-
}
164-
165-
apiCommandsMessage, err := getAPICommandsMessage(results, envName)
166-
if err != nil {
167-
return "", err
168-
}
169-
170-
return statusMessage + "\n\n" + apiCommandsMessage, nil
171-
}
172-
173152
func mergeResultMessages(results []schema.DeployResult) string {
174153
var okMessages []string
175154
var errMessages []string
@@ -215,38 +194,3 @@ func didAnyResultsError(results []schema.DeployResult) bool {
215194
}
216195
return false
217196
}
218-
219-
func getAPICommandsMessage(results []schema.DeployResult, envName string) (string, error) {
220-
apiName := "<api_name>"
221-
if len(results) == 1 {
222-
apiName = results[0].API.Spec.Name
223-
}
224-
225-
defaultEnv, err := getDefaultEnv()
226-
if err != nil {
227-
return "", err
228-
}
229-
var envArg string
230-
if defaultEnv == nil || envName != *defaultEnv {
231-
envArg = " --env " + envName
232-
}
233-
234-
var items table.KeyValuePairs
235-
items.Add("cortex get"+envArg, "(show api statuses)")
236-
items.Add(fmt.Sprintf("cortex get %s%s", apiName, envArg), "(show api info)")
237-
238-
for _, result := range results {
239-
if len(result.Error) > 0 {
240-
continue
241-
}
242-
if result.API != nil && result.API.Spec.Kind == userconfig.RealtimeAPIKind {
243-
items.Add(fmt.Sprintf("cortex logs %s%s", apiName, envArg), "(access logs)")
244-
break
245-
}
246-
}
247-
248-
return strings.TrimSpace(items.String(&table.KeyValuePairOpts{
249-
Delimiter: pointer.String(""),
250-
NumSpaces: pointer.Int(2),
251-
})), nil
252-
}

cli/cmd/lib_cluster_config.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,40 +185,33 @@ func confirmInstallClusterConfig(clusterConfig *clusterconfig.Config, awsClient
185185
apiEBSPrice += libmath.MaxFloat64(0, (aws.EBSMetadatas[clusterConfig.Region][ng.InstanceVolumeType.String()].PriceThroughput-125)*float64(*ng.InstanceVolumeThroughput)/30/24)
186186
}
187187

188-
totalMinPrice += float64(ng.MinInstances) * (apiInstancePrice + apiEBSPrice)
189188
totalMaxPrice += float64(ng.MaxInstances) * (apiInstancePrice + apiEBSPrice)
190189

191-
instanceStr := "instances"
192-
volumeStr := "volumes"
193-
if ng.MinInstances == 1 && ng.MaxInstances == 1 {
194-
instanceStr = "instance"
195-
volumeStr = "volume"
196-
}
197-
workerInstanceStr := fmt.Sprintf("nodegroup %s: %d - %d %s %s for your apis", ng.Name, ng.MinInstances, ng.MaxInstances, ng.InstanceType, instanceStr)
198-
ebsInstanceStr := fmt.Sprintf("nodegroup %s: %d - %d %dgb ebs %s for your apis", ng.Name, ng.MinInstances, ng.MaxInstances, ng.InstanceVolumeSize, volumeStr)
190+
workerInstanceStr := fmt.Sprintf("nodegroup %s: %d-%d %s instances", ng.Name, ng.MinInstances, ng.MaxInstances, ng.InstanceType)
199191
if ng.MinInstances == ng.MaxInstances {
200-
workerInstanceStr = fmt.Sprintf("nodegroup %s: %d %s %s for your apis", ng.Name, ng.MinInstances, ng.InstanceType, instanceStr)
201-
ebsInstanceStr = fmt.Sprintf("nodegroup %s:%d %dgb ebs %s for your apis", ng.Name, ng.MinInstances, ng.InstanceVolumeSize, volumeStr)
192+
workerInstanceStr = fmt.Sprintf("nodegroup %s: %d %s %s", ng.Name, ng.MinInstances, ng.InstanceType, s.PluralS("instance", ng.MinInstances))
202193
}
203194

204-
workerPriceStr := s.DollarsMaxPrecision(apiInstancePrice) + " each"
195+
workerPriceStr := s.DollarsAndTenthsOfCents(apiInstancePrice+apiEBSPrice) + " each"
205196
if ng.Spot {
206197
ngNameToSpotInstancesUsed[ng.Name]++
207198
spotPrice, err := awsClient.SpotInstancePrice(ng.InstanceType)
208199
workerPriceStr += " (spot pricing unavailable)"
209200
if err == nil && spotPrice != 0 {
210-
workerPriceStr = fmt.Sprintf("%s - %s each (varies based on spot price)", s.DollarsMaxPrecision(spotPrice), s.DollarsMaxPrecision(apiInstancePrice))
211-
totalMinPrice = fixedPrice + float64(ng.MinInstances)*(spotPrice+apiEBSPrice)
201+
workerPriceStr = fmt.Sprintf("%s - %s each (varies based on spot price)", s.DollarsAndTenthsOfCents(spotPrice+apiEBSPrice), s.DollarsAndTenthsOfCents(apiInstancePrice+apiEBSPrice))
202+
totalMinPrice += float64(ng.MinInstances) * (spotPrice + apiEBSPrice)
203+
} else {
204+
totalMinPrice += float64(ng.MinInstances) * (apiInstancePrice + apiEBSPrice)
212205
}
206+
} else {
207+
totalMinPrice += float64(ng.MinInstances) * (apiInstancePrice + apiEBSPrice)
213208
}
214209

215210
rows = append(rows, []interface{}{workerInstanceStr, workerPriceStr})
216-
rows = append(rows, []interface{}{ebsInstanceStr, s.DollarsAndTenthsOfCents(apiEBSPrice) + " each"})
217211
}
218212

219-
rows = append(rows, []interface{}{"2 t3.medium instances for cortex", s.DollarsMaxPrecision(operatorInstancePrice * 2)})
220-
rows = append(rows, []interface{}{"2 20gb ebs volumes for the operator", s.DollarsAndTenthsOfCents(operatorEBSPrice * 2)})
221-
rows = append(rows, []interface{}{"1 40+2gb ebs volumes for metrics (prometheus and grafana)", s.DollarsAndTenthsOfCents(metricsEBSPrice)})
213+
operatorPrice := 2*(operatorInstancePrice+operatorEBSPrice) + metricsEBSPrice
214+
rows = append(rows, []interface{}{"2 t3.medium instances (cortex system)", s.DollarsAndTenthsOfCents(operatorPrice)})
222215
rows = append(rows, []interface{}{"2 network load balancers", s.DollarsMaxPrecision(nlbPrice) + " each"})
223216

224217
if clusterConfig.NATGateway == clusterconfig.SingleNATGateway {

cli/cmd/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func logsInit() {
4646

4747
var _logsCmd = &cobra.Command{
4848
Use: "logs API_NAME [JOB_ID]",
49-
Short: "get the logs for an API or a job",
49+
Short: "get the logs for a workload",
5050
Args: cobra.RangeArgs(1, 2),
5151
Run: func(cmd *cobra.Command, args []string) {
5252
envName, err := getEnvFromFlag(_flagLogsEnv)

docs/clients/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Flags:
3535
## logs
3636

3737
```text
38-
get the logs for an API or a job
38+
get the logs for a workload
3939
4040
Usage:
4141
cortex logs API_NAME [JOB_ID] [flags]
@@ -65,7 +65,7 @@ Flags:
6565
## delete
6666

6767
```text
68-
delete any kind of api or stop a batch job
68+
delete an api or stop a job
6969
7070
Usage:
7171
cortex delete API_NAME [JOB_ID] [flags]

docs/clusters/observability/logging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ fields @timestamp, message
5050
| limit 1000
5151
```
5252

53-
## Streaming logs for an API or a running job
53+
## Streaming logs from the CLI
5454

55-
You can stream logs directly from a random pod of an API or a running job to iterate and debug quickly. These logs will not be as comprehensive as the logs that are available in CloudWatch.
55+
You can stream logs directly from a random pod of a running workload to iterate and debug quickly. These logs will not be as comprehensive as the logs that are available in CloudWatch.
5656

5757
```bash
5858
# RealtimeAPI

pkg/operator/operator/workload_logging.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ func waitForPodToBeNotPending(podName string, cancelListener chan struct{}, sock
207207
return false
208208
}
209209
if pod == nil {
210-
writeAndCloseSocket(socket, "unable to find replica/worker")
210+
writeAndCloseSocket(socket, "unable to find pod")
211211
return false
212212
}
213213
podStatus := k8s.GetPodStatus(pod)
214214
if podStatus == k8s.PodStatusPending {
215215
if !wrotePending {
216-
writeString(socket, "waiting for replica/worker to initialize ...\n")
216+
writeString(socket, "waiting for pod to initialize ...\n")
217217
}
218218
wrotePending = true
219219
timer.Reset(_pendingPodCheckInterval)
@@ -294,7 +294,7 @@ func StreamLogsFromRandomPod(podSearchLabels map[string]string, socket *websocke
294294
return
295295
}
296296
if len(pods) == 0 {
297-
writeAndCloseSocket(socket, "there are currently no replicas/workers running for this api or job; please visit your logging dashboard for historical logs\n")
297+
writeAndCloseSocket(socket, "there are currently no pods running for this workload; please visit your logging dashboard for historical logs\n")
298298
return
299299
}
300300

0 commit comments

Comments
 (0)