Skip to content

Commit cfcea0f

Browse files
jdgonzalezactlongmkocherrroberts2222Benjamintf1
authored
logging rate limits flag introduction (#2313)
* 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 <[email protected]> Co-authored-by: Matthew Kocher <[email protected]> Co-authored-by: Rebecca Roberts <[email protected]> Co-authored-by: Benjamin Fuller <[email protected]>
1 parent 19e480d commit cfcea0f

File tree

70 files changed

+1382
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1382
-318
lines changed

actor/v7action/organization_quota.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type QuotaLimits struct {
1515
TotalServiceInstances *types.NullInt
1616
TotalRoutes *types.NullInt
1717
TotalReservedPorts *types.NullInt
18+
TotalLogVolume *types.NullInt
1819
}
1920

2021
func (actor Actor) ApplyOrganizationQuotaByName(quotaName string, orgGUID string) (Warnings, error) {
@@ -119,6 +120,7 @@ func createQuotaStruct(name string, limits QuotaLimits) resources.OrganizationQu
119120
TotalMemory: limits.TotalMemoryInMB,
120121
InstanceMemory: limits.PerProcessMemoryInMB,
121122
TotalAppInstances: limits.TotalInstances,
123+
TotalLogVolume: limits.TotalLogVolume,
122124
}
123125
ServiceLimit := resources.ServiceLimit{
124126
TotalServiceInstances: limits.TotalServiceInstances,
@@ -164,6 +166,7 @@ func convertUnlimitedToNil(apps *resources.AppLimit, routes *resources.RouteLimi
164166
apps.TotalMemory,
165167
apps.InstanceMemory,
166168
apps.TotalAppInstances,
169+
apps.TotalLogVolume,
167170
services.TotalServiceInstances,
168171
routes.TotalRoutes,
169172
routes.TotalReservedPorts,

actor/v7action/organization_quota_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ var _ = Describe("Organization Quota Actions", func() {
399399
PaidServicesAllowed: &trueValue,
400400
TotalRoutes: &types.NullInt{Value: 6, IsSet: true},
401401
TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true},
402+
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
402403
}
403404
})
404405

@@ -438,6 +439,7 @@ var _ = Describe("Organization Quota Actions", func() {
438439
TotalMemory: &types.NullInt{Value: 0, IsSet: true},
439440
InstanceMemory: nil,
440441
TotalAppInstances: nil,
442+
TotalLogVolume: nil,
441443
},
442444
Services: resources.ServiceLimit{
443445
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -480,6 +482,7 @@ var _ = Describe("Organization Quota Actions", func() {
480482
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
481483
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
482484
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
485+
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
483486
}
484487
ccv3Quota = resources.OrganizationQuota{
485488
Quota: resources.Quota{
@@ -488,6 +491,7 @@ var _ = Describe("Organization Quota Actions", func() {
488491
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
489492
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
490493
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
494+
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
491495
},
492496
Services: resources.ServiceLimit{
493497
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -506,7 +510,7 @@ var _ = Describe("Organization Quota Actions", func() {
506510
)
507511
})
508512

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

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

519-
When("The create org quota endpoint succeeds", func() {
523+
When("the create org quota endpoint succeeds", func() {
520524
var (
521525
ccv3Quota resources.OrganizationQuota
522526
)
@@ -528,6 +532,7 @@ var _ = Describe("Organization Quota Actions", func() {
528532
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
529533
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
530534
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
535+
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
531536
},
532537
Services: resources.ServiceLimit{
533538
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -546,7 +551,7 @@ var _ = Describe("Organization Quota Actions", func() {
546551
)
547552
})
548553

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

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

582588
fakeCloudControllerClient.GetOrganizationQuotasReturns(
@@ -622,6 +628,7 @@ var _ = Describe("Organization Quota Actions", func() {
622628
TotalMemory: nil,
623629
InstanceMemory: nil,
624630
TotalAppInstances: nil,
631+
TotalLogVolume: nil,
625632
},
626633
Services: resources.ServiceLimit{
627634
TotalServiceInstances: nil,
@@ -669,6 +676,7 @@ var _ = Describe("Organization Quota Actions", func() {
669676
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
670677
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
671678
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
679+
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
672680
}
673681
ccv3Quota = resources.OrganizationQuota{
674682
Quota: resources.Quota{
@@ -677,6 +685,7 @@ var _ = Describe("Organization Quota Actions", func() {
677685
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
678686
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
679687
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
688+
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
680689
},
681690
Services: resources.ServiceLimit{
682691
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -722,6 +731,7 @@ var _ = Describe("Organization Quota Actions", func() {
722731
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
723732
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
724733
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
734+
TotalLogVolume: &types.NullInt{Value: 64, IsSet: true},
725735
},
726736
Services: resources.ServiceLimit{
727737
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},

actor/v7action/space_quota.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func (actor Actor) CreateSpaceQuota(spaceQuotaName string, orgGuid string, limit
3131
TotalMemory: limits.TotalMemoryInMB,
3232
InstanceMemory: limits.PerProcessMemoryInMB,
3333
TotalAppInstances: limits.TotalInstances,
34+
TotalLogVolume: limits.TotalLogVolume,
3435
},
3536
Services: resources.ServiceLimit{
3637
TotalServiceInstances: limits.TotalServiceInstances,
@@ -137,6 +138,7 @@ func (actor Actor) UpdateSpaceQuota(currentName, orgGUID, newName string, limits
137138
TotalMemory: limits.TotalMemoryInMB,
138139
InstanceMemory: limits.PerProcessMemoryInMB,
139140
TotalAppInstances: limits.TotalInstances,
141+
TotalLogVolume: limits.TotalLogVolume,
140142
},
141143
Services: resources.ServiceLimit{
142144
TotalServiceInstances: limits.TotalServiceInstances,

actor/v7action/space_quota_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ var _ = Describe("Space Quota Actions", func() {
151151
TotalServiceInstances: &types.NullInt{IsSet: true, Value: 6},
152152
TotalRoutes: &types.NullInt{IsSet: true, Value: 8},
153153
TotalReservedPorts: &types.NullInt{IsSet: true, Value: 9},
154+
TotalLogVolume: &types.NullInt{IsSet: true, Value: 10},
154155
}
155156
})
156157

@@ -167,6 +168,7 @@ var _ = Describe("Space Quota Actions", func() {
167168
TotalMemory: &types.NullInt{IsSet: true, Value: 2},
168169
InstanceMemory: &types.NullInt{IsSet: true, Value: 3},
169170
TotalAppInstances: &types.NullInt{IsSet: true, Value: 4},
171+
TotalLogVolume: &types.NullInt{IsSet: true, Value: 10},
170172
},
171173
Services: resources.ServiceLimit{
172174
TotalServiceInstances: &types.NullInt{IsSet: true, Value: 6},
@@ -201,6 +203,7 @@ var _ = Describe("Space Quota Actions", func() {
201203
TotalMemory: &types.NullInt{Value: 0, IsSet: true},
202204
InstanceMemory: nil,
203205
TotalAppInstances: nil,
206+
TotalLogVolume: nil,
204207
},
205208
Services: resources.ServiceLimit{
206209
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -244,6 +247,7 @@ var _ = Describe("Space Quota Actions", func() {
244247
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
245248
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
246249
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
250+
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
247251
}
248252
ccv3Quota = resources.SpaceQuota{
249253
Quota: resources.Quota{
@@ -252,6 +256,7 @@ var _ = Describe("Space Quota Actions", func() {
252256
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
253257
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
254258
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
259+
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
255260
},
256261
Services: resources.ServiceLimit{
257262
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -607,6 +612,7 @@ var _ = Describe("Space Quota Actions", func() {
607612
PaidServicesAllowed: &trueValue,
608613
TotalRoutes: &types.NullInt{Value: 6, IsSet: true},
609614
TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true},
615+
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
610616
}
611617

612618
fakeCloudControllerClient.GetSpaceQuotasReturns(
@@ -652,6 +658,7 @@ var _ = Describe("Space Quota Actions", func() {
652658
TotalMemory: nil,
653659
InstanceMemory: nil,
654660
TotalAppInstances: nil,
661+
TotalLogVolume: nil,
655662
},
656663
Services: resources.ServiceLimit{
657664
TotalServiceInstances: nil,
@@ -699,6 +706,7 @@ var _ = Describe("Space Quota Actions", func() {
699706
TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true},
700707
TotalRoutes: &types.NullInt{Value: -1, IsSet: true},
701708
TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true},
709+
TotalLogVolume: &types.NullInt{Value: -1, IsSet: true},
702710
}
703711

704712
ccv3Quota = resources.SpaceQuota{
@@ -708,6 +716,7 @@ var _ = Describe("Space Quota Actions", func() {
708716
TotalMemory: &types.NullInt{Value: 0, IsSet: false},
709717
InstanceMemory: &types.NullInt{Value: 0, IsSet: false},
710718
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
719+
TotalLogVolume: &types.NullInt{Value: 0, IsSet: false},
711720
},
712721
Services: resources.ServiceLimit{
713722
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false},
@@ -754,6 +763,7 @@ var _ = Describe("Space Quota Actions", func() {
754763
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
755764
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
756765
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
766+
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
757767
},
758768
Services: resources.ServiceLimit{
759769
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},
@@ -802,6 +812,7 @@ var _ = Describe("Space Quota Actions", func() {
802812
TotalMemory: &types.NullInt{Value: 2048, IsSet: true},
803813
InstanceMemory: &types.NullInt{Value: 1024, IsSet: true},
804814
TotalAppInstances: &types.NullInt{Value: 0, IsSet: false},
815+
TotalLogVolume: &types.NullInt{Value: 512, IsSet: true},
805816
},
806817
Services: resources.ServiceLimit{
807818
TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true},

actor/v7pushaction/actor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func NewActor(v3Actor V7Actor, sharedActor SharedActor) *Actor {
5050
HandleHealthCheckTimeoutOverride,
5151
HandleMemoryOverride,
5252
HandleDiskOverride,
53+
HandleLogRateLimitOverride,
5354
HandleNoRouteOverride,
5455
HandleRandomRouteOverride,
5556
HandleTaskOverride,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package v7pushaction
2+
3+
import (
4+
"code.cloudfoundry.org/cli/command/translatableerror"
5+
"code.cloudfoundry.org/cli/util/manifestparser"
6+
)
7+
8+
func HandleLogRateLimitOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) {
9+
if overrides.LogRateLimit != "" {
10+
if manifest.ContainsMultipleApps() {
11+
return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{}
12+
}
13+
14+
webProcess := manifest.GetFirstAppWebProcess()
15+
if webProcess != nil {
16+
webProcess.LogRateLimit = overrides.LogRateLimit
17+
} else {
18+
app := manifest.GetFirstApp()
19+
app.LogRateLimit = overrides.LogRateLimit
20+
}
21+
}
22+
23+
return manifest, nil
24+
}

0 commit comments

Comments
 (0)