Skip to content

Commit

Permalink
logging rate limits flag introduction (#2313)
Browse files Browse the repository at this point in the history
* Feat: create and update org quotas with log volume (#2298)

* Show org and space quotas (#2299)

* org-quota and space-quota now show log volume

* code currently assumes responses with log limits. Consider
  backward compatibility before shipping.

* add log volume to space-quotas and org-quotas commands

* will show "unlimited" for old CC API's which is technically correct

* Fix unit tests in ccv3

* Create and update space quotas (#2300)

* create-space-quota accepts log volume flag

* update-space-quota accepts log volume flag

* Update create-space-quota flag description

* Make it clear that the log volume measured is in bytes rather than log
  lines.

* Push and scale app and run-task 

* Bump rack from 2.2.3 to 2.2.3.1 in /fixtures/applications/example-app

* `cf push` command accepts log rate limit flag

* since `cf push` uses manifests this commit also adds support for log
  rate limit in manifests

* `cf scale` command accepts log rate limit flag

* app summary displayer can now handle rendering log rate and log rate
  limit metrics for running instances

* app summaries will show `0 of 0` if the cloud controller does not
  support log rate limit container metrics

* `cf run-task` command accepts log rate limit flag

* update help text to suggest using ='s with -1 to avoid flag parsing problem

* Flag parser accepts 0B, -1B, 0T, etc for flags

* this affects non-manifest based commands

* Extract constants for instance stats columns

* Extract constant for column count

Co-authored-by: Carson Long <lcarson@vmware.com>
Co-authored-by: Matthew Kocher <mkocher@vmware.com>
Co-authored-by: Rebecca Roberts <robertsre@vmware.com>
Co-authored-by: Benjamin Fuller <Benjamintf1@gmail.com>
  • Loading branch information
5 people authored and Juan Diego Gonzalez committed Sep 8, 2022
1 parent 6715868 commit 94619ee
Showing 70 changed files with 1,382 additions and 318 deletions.
3 changes: 3 additions & 0 deletions actor/v7action/organization_quota.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ type QuotaLimits struct {
TotalServiceInstances *types.NullInt
TotalRoutes *types.NullInt
TotalReservedPorts *types.NullInt
TotalLogVolume *types.NullInt
}

func (actor Actor) ApplyOrganizationQuotaByName(quotaName string, orgGUID string) (Warnings, error) {
@@ -119,6 +120,7 @@ func createQuotaStruct(name string, limits QuotaLimits) resources.OrganizationQu
TotalMemory: limits.TotalMemoryInMB,
InstanceMemory: limits.PerProcessMemoryInMB,
TotalAppInstances: limits.TotalInstances,
TotalLogVolume: limits.TotalLogVolume,
}
ServiceLimit := resources.ServiceLimit{
TotalServiceInstances: limits.TotalServiceInstances,
@@ -164,6 +166,7 @@ func convertUnlimitedToNil(apps *resources.AppLimit, routes *resources.RouteLimi
apps.TotalMemory,
apps.InstanceMemory,
apps.TotalAppInstances,
apps.TotalLogVolume,
services.TotalServiceInstances,
routes.TotalRoutes,
routes.TotalReservedPorts,
16 changes: 13 additions & 3 deletions actor/v7action/organization_quota_test.go
Original file line number Diff line number Diff line change
@@ -399,6 +399,7 @@ var _ = Describe("Organization Quota Actions", func() {
PaidServicesAllowed: &trueValue,
TotalRoutes: &types.NullInt{Value: 6, IsSet: true},
TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
}
})

@@ -438,6 +439,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 0, IsSet: true},
InstanceMemory: nil,
TotalAppInstances: nil,
TotalLogVolume: nil,
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -480,6 +482,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
}
ccv3Quota = resources.OrganizationQuota{
Quota: resources.Quota{
@@ -488,6 +491,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -506,7 +510,7 @@ var _ = Describe("Organization Quota Actions", func() {
)
})

It("call the create endpoint with the respective values and returns warnings", func() {
It("calls the create endpoint with the respective values and returns warnings", func() {
Expect(fakeCloudControllerClient.CreateOrganizationQuotaCallCount()).To(Equal(1))

Expect(warnings).To(ConsistOf("some-quota-warning"))
@@ -516,7 +520,7 @@ var _ = Describe("Organization Quota Actions", func() {
})
})

When("The create org quota endpoint succeeds", func() {
When("the create org quota endpoint succeeds", func() {
var (
ccv3Quota resources.OrganizationQuota
)
@@ -528,6 +532,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -546,7 +551,7 @@ var _ = Describe("Organization Quota Actions", func() {
)
})

It("call the create endpoint with the respective values and returns warnings", func() {
It("calls the create endpoint with the respective values and returns warnings", func() {
Expect(fakeCloudControllerClient.CreateOrganizationQuotaCallCount()).To(Equal(1))

Expect(warnings).To(ConsistOf("some-quota-warning"))
@@ -577,6 +582,7 @@ var _ = Describe("Organization Quota Actions", func() {
PaidServicesAllowed: &trueValue,
TotalRoutes: &types.NullInt{Value: 6, IsSet: true},
TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 64, IsSet: true},
}

fakeCloudControllerClient.GetOrganizationQuotasReturns(
@@ -622,6 +628,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalMemory: nil,
InstanceMemory: nil,
TotalAppInstances: nil,
TotalLogVolume: nil,
},
Services: resources.ServiceLimit{
TotalServiceInstances: nil,
@@ -669,6 +676,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
}
ccv3Quota = resources.OrganizationQuota{
Quota: resources.Quota{
@@ -677,6 +685,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -722,6 +731,7 @@ var _ = Describe("Organization Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 64, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
2 changes: 2 additions & 0 deletions actor/v7action/space_quota.go
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ func (actor Actor) CreateSpaceQuota(spaceQuotaName string, orgGuid string, limit
TotalMemory: limits.TotalMemoryInMB,
InstanceMemory: limits.PerProcessMemoryInMB,
TotalAppInstances: limits.TotalInstances,
TotalLogVolume: limits.TotalLogVolume,
},
Services: resources.ServiceLimit{
TotalServiceInstances: limits.TotalServiceInstances,
@@ -137,6 +138,7 @@ func (actor Actor) UpdateSpaceQuota(currentName, orgGUID, newName string, limits
TotalMemory: limits.TotalMemoryInMB,
InstanceMemory: limits.PerProcessMemoryInMB,
TotalAppInstances: limits.TotalInstances,
TotalLogVolume: limits.TotalLogVolume,
},
Services: resources.ServiceLimit{
TotalServiceInstances: limits.TotalServiceInstances,
11 changes: 11 additions & 0 deletions actor/v7action/space_quota_test.go
Original file line number Diff line number Diff line change
@@ -151,6 +151,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalServiceInstances: &types.NullInt{IsSet: true, Value: 6},
TotalRoutes: &types.NullInt{IsSet: true, Value: 8},
TotalReservedPorts: &types.NullInt{IsSet: true, Value: 9},
TotalLogVolume: &types.NullInt{IsSet: true, Value: 10},
}
})

@@ -167,6 +168,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalMemory: &types.NullInt{IsSet: true, Value: 2},
InstanceMemory: &types.NullInt{IsSet: true, Value: 3},
TotalAppInstances: &types.NullInt{IsSet: true, Value: 4},
TotalLogVolume: &types.NullInt{IsSet: true, Value: 10},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{IsSet: true, Value: 6},
@@ -201,6 +203,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 0, IsSet: true},
InstanceMemory: nil,
TotalAppInstances: nil,
TotalLogVolume: nil,
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -244,6 +247,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
}
ccv3Quota = resources.SpaceQuota{
Quota: resources.Quota{
@@ -252,6 +256,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -607,6 +612,7 @@ var _ = Describe("Space Quota Actions", func() {
PaidServicesAllowed: &trueValue,
TotalRoutes: &types.NullInt{Value: 6, IsSet: true},
TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true},
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
}

fakeCloudControllerClient.GetSpaceQuotasReturns(
@@ -652,6 +658,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalMemory: nil,
InstanceMemory: nil,
TotalAppInstances: nil,
TotalLogVolume: nil,
},
Services: resources.ServiceLimit{
TotalServiceInstances: nil,
@@ -699,6 +706,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
}

ccv3Quota = resources.SpaceQuota{
@@ -708,6 +716,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -754,6 +763,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -802,6 +812,7 @@ var _ = Describe("Space Quota Actions", func() {
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
},
Services: resources.ServiceLimit{
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
1 change: 1 addition & 0 deletions actor/v7pushaction/actor.go
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ func NewActor(v3Actor V7Actor, sharedActor SharedActor) *Actor {
HandleHealthCheckTimeoutOverride,
HandleMemoryOverride,
HandleDiskOverride,
HandleLogRateLimitOverride,
HandleNoRouteOverride,
HandleRandomRouteOverride,
HandleTaskOverride,
24 changes: 24 additions & 0 deletions actor/v7pushaction/handle_log_rate_limit_override.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package v7pushaction

import (
"code.cloudfoundry.org/cli/command/translatableerror"
"code.cloudfoundry.org/cli/util/manifestparser"
)

func HandleLogRateLimitOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) {
if overrides.LogRateLimit != "" {
if manifest.ContainsMultipleApps() {
return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{}
}

webProcess := manifest.GetFirstAppWebProcess()
if webProcess != nil {
webProcess.LogRateLimit = overrides.LogRateLimit
} else {
app := manifest.GetFirstApp()
app.LogRateLimit = overrides.LogRateLimit
}
}

return manifest, nil
}
Loading

0 comments on commit 94619ee

Please sign in to comment.