Skip to content

Commit eb3399b

Browse files
author
Andrea Falzetti
committed
feat(supervisor): add resource status severity
1 parent 47c64d4 commit eb3399b

25 files changed

+953
-630
lines changed

components/gitpod-cli/cmd/top.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313

1414
supervisor_helper "github.com/gitpod-io/gitpod/gitpod-cli/pkg/supervisor-helper"
15+
"github.com/gitpod-io/gitpod/supervisor/api"
1516
supervisor "github.com/gitpod-io/gitpod/supervisor/api"
1617

1718
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/utils"
@@ -35,8 +36,8 @@ func outputTable(workspaceResources *supervisor.ResourcesStatusResponse) {
3536
colors := []tablewriter.Colors{}
3637

3738
if !noColor && utils.ColorsEnabled() {
38-
cpuColor := getColor(cpuFraction)
39-
memoryColor := getColor(memFraction)
39+
cpuColor := getColor(workspaceResources.Cpu.Severity)
40+
memoryColor := getColor(workspaceResources.Memory.Severity)
4041
colors = []tablewriter.Colors{{cpuColor}, {memoryColor}}
4142
}
4243

@@ -45,12 +46,11 @@ func outputTable(workspaceResources *supervisor.ResourcesStatusResponse) {
4546
table.Render()
4647
}
4748

48-
// TODO: retrieve thresholds from supervisor once we implement this: https://github.com/gitpod-io/gitpod/issues/12075
49-
func getColor(value int64) int {
50-
switch {
51-
case value >= 95:
49+
func getColor(severity api.ResourceStatusSeverity) int {
50+
switch severity {
51+
case api.ResourceStatusSeverity_danger:
5252
return tablewriter.FgRedColor
53-
case value >= 80:
53+
case api.ResourceStatusSeverity_warning:
5454
return tablewriter.FgYellowColor
5555
default:
5656
return tablewriter.FgHiGreenColor

components/supervisor-api/generate.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ local_java_protoc() {
5353
--java_out=java/src/main/java \
5454
./*.proto
5555
# remove trailing spaces
56-
find components/supervisor-api/java/src/main/java/io/gitpod/supervisor/api -maxdepth 1 -name "*.java" -exec sed -i -e "s/[[:space:]]*$//" {} \;
56+
find "${COMPONENTS_DIR}"/supervisor-api/java/src/main/java/io/gitpod/supervisor/api -maxdepth 1 -name "*.java" -exec sed -i -e "s/[[:space:]]*$//" {} \;
5757
# revert Java reserved keywords
5858
sed -i 's/private_visibility = 0;/private = 0;/g' status.proto
5959
sed -i 's/public_visibility = 1;/public = 1;/g' status.proto

components/supervisor-api/go/control.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/go/control_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/go/info.pb.go

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/go/info_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/go/notification.pb.go

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/go/notification_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/go/port.pb.go

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/supervisor-api/go/port_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)