Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add ready column to cf app #3351

Draft
wants to merge 2 commits into
base: v8
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/cloudcontroller/ccv3/process_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type ProcessInstance struct {
LogRate uint64
// State is the state of the instance.
State constant.ProcessInstanceState
// Routeable is the readiness state of the instance, can be true, false or null.
Routable *bool
// Type is the process type for the instance.
Type string
// Uptime is the duration that the instance has been running.
Expand All @@ -56,6 +58,7 @@ func (instance *ProcessInstance) UnmarshalJSON(data []byte) error {
MemQuota uint64 `json:"mem_quota"`
LogRateLimit int64 `json:"log_rate_limit"`
State string `json:"state"`
Routable *bool `json:"routable"`
Type string `json:"type"`
Uptime int64 `json:"uptime"`
Usage struct {
Expand Down Expand Up @@ -84,6 +87,7 @@ func (instance *ProcessInstance) UnmarshalJSON(data []byte) error {
instance.LogRateLimit = inputInstance.LogRateLimit
instance.LogRate = inputInstance.Usage.LogRate
instance.State = constant.ProcessInstanceState(inputInstance.State)
instance.Routable = inputInstance.Routable
instance.Type = inputInstance.Type
instance.Uptime, err = time.ParseDuration(fmt.Sprintf("%ds", inputInstance.Uptime))
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions command/v7/shared/app_summary_displayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,21 @@ func formatCPUEntitlement(cpuEntitlement types.NullFloat64) string {
return fmt.Sprintf("%.1f%%", cpuEntitlement.Value*100)
}

func formatRoutable(b *bool) string {
if b == nil {
return "-"
}

return fmt.Sprintf("%t", *b)
}

func (display AppSummaryDisplayer) displayAppInstancesTable(processSummary v7action.ProcessSummary) {
table := [][]string{
{
"",
display.UI.TranslateText("state"),
display.UI.TranslateText("since"),
display.UI.TranslateText("ready"),
display.UI.TranslateText("cpu"),
display.UI.TranslateText("memory"),
display.UI.TranslateText("disk"),
Expand All @@ -100,6 +109,7 @@ func (display AppSummaryDisplayer) displayAppInstancesTable(processSummary v7act
fmt.Sprintf("#%d", instance.Index),
display.UI.TranslateText(strings.ToLower(string(instance.State))),
display.appInstanceDate(instance.StartTime()),
formatRoutable(instance.Routable),
fmt.Sprintf("%.1f%%", instance.CPU*100),
display.UI.TranslateText("{{.MemUsage}} of {{.MemQuota}}", map[string]interface{}{
"MemUsage": bytefmt.ByteSize(instance.MemoryUsage),
Expand Down
12 changes: 10 additions & 2 deletions command/v7/shared/app_summary_displayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var _ = Describe("app summary displayer", func() {

const instanceStatsTitles = `state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement\s+details`
const instanceStatsTitles = `state\s+since\s+ready\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement\s+details`

var (
appSummaryDisplayer *AppSummaryDisplayer
Expand Down Expand Up @@ -48,6 +48,10 @@ var _ = Describe("app summary displayer", func() {

BeforeEach(func() {
uptime = time.Since(time.Unix(267321600, 0))
var (
bTrue = true
bFalse = false
)
summary = v7action.DetailedApplicationSummary{
ApplicationSummary: v7action.ApplicationSummary{
Application: resources.Application{
Expand All @@ -67,6 +71,7 @@ var _ = Describe("app summary displayer", func() {
v7action.ProcessInstance{
Index: 0,
State: constant.ProcessInstanceRunning,
Routable: nil,
CPUEntitlement: types.NullFloat64{Value: 0, IsSet: true},
MemoryUsage: 1000000,
DiskUsage: 1000000,
Expand All @@ -80,6 +85,7 @@ var _ = Describe("app summary displayer", func() {
v7action.ProcessInstance{
Index: 1,
State: constant.ProcessInstanceRunning,
Routable: &bTrue,
CPUEntitlement: types.NullFloat64{Value: 0, IsSet: false},
MemoryUsage: 2000000,
DiskUsage: 2000000,
Expand All @@ -93,6 +99,7 @@ var _ = Describe("app summary displayer", func() {
v7action.ProcessInstance{
Index: 2,
State: constant.ProcessInstanceRunning,
Routable: &bFalse,
CPUEntitlement: types.NullFloat64{Value: 0.03, IsSet: true},
MemoryUsage: 3000000,
DiskUsage: 3000000,
Expand All @@ -116,6 +123,7 @@ var _ = Describe("app summary displayer", func() {
v7action.ProcessInstance{
Index: 0,
State: constant.ProcessInstanceRunning,
Routable: &bTrue,
MemoryUsage: 1000000,
DiskUsage: 1000000,
LogRate: 128,
Expand Down Expand Up @@ -655,7 +663,7 @@ var _ = Describe("app summary displayer", func() {

When("there is an active deployment", func() {
var LastStatusChangeTimeString = "2024-07-29T17:32:29Z"
var dateTimeRegexPattern = `[a-zA-Z]{3}\s\d{2}\s[a-zA-Z]{3}\s\d{2}\:\d{2}\:\d{2}\s[A-Z]{3}\s\d{4}`
var dateTimeRegexPattern = `[a-zA-Z]{3}\s\d{2}\s[a-zA-Z]{3}\s\d{2}\:\d{2}\:\d{2}\s[A-Z]+\s\d{4}`
var maxInFlightDefaultValue = 1

When("the deployment strategy is rolling", func() {
Expand Down
12 changes: 7 additions & 5 deletions integration/helpers/app_instance_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type AppInstanceRow struct {
Index string
State string
Ready string
Since string
CPU string
Memory string
Expand Down Expand Up @@ -57,7 +58,7 @@ func ParseV3AppProcessTable(input []byte) AppTable {

switch {
case strings.HasPrefix(row, "#"):
const columnCount = 9
const columnCount = 10

// instance row
columns := splitColumns(row)
Expand All @@ -73,10 +74,11 @@ func ParseV3AppProcessTable(input []byte) AppTable {
Index: columns[0],
State: columns[1],
Since: columns[2],
CPU: columns[3],
Memory: columns[4],
Disk: columns[5],
LogRate: columns[6],
Ready: columns[3],
CPU: columns[4],
Memory: columns[5],
Disk: columns[6],
LogRate: columns[7],
CPUEntitlement: cpuEntitlement,
Details: details,
}
Expand Down
Loading