Skip to content

Commit efde2d3

Browse files
nabramovitznorman-abramovitz
authored andcommitted
Adopt fw-capi quota contract fixes
fw-capi corrected three CF v3 contract discrepancies found by a docs-contract audit and verified live: quota delete methods now return the async job ref, the quota apps field names match real CF (per_process_memory_in_mb / per_app_tasks), and empty spaces relationships are omitted on create. Jetstream: delete handlers discard the job for now (UI contract stays 204-on-accepted), read mappers use the corrected accessors, and test mocks simulate real CF payload field names. Frontend: quota wire bodies send the correct field names. Stratos's own outward API field names are unchanged. Verified end to end against a real CF through make dev: org and space quota create (201) and delete (204) through the UI.
1 parent 29da099 commit efde2d3

8 files changed

Lines changed: 19 additions & 15 deletions

File tree

src/frontend/packages/cloud-foundry/src/features/cf/quota-definition-form/quota-form-mapping.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function formToOrgQuotaWriteBody(values: OrgQuotaFormValues): OrgQuotaWri
3232
name: values.name,
3333
apps: {
3434
total_memory_in_mb: limitToWire(values.memoryLimit),
35-
total_instance_memory_in_mb: limitToWire(values.instanceMemoryLimit),
35+
per_process_memory_in_mb: limitToWire(values.instanceMemoryLimit),
3636
total_instances: limitToWire(values.appInstanceLimit),
37-
total_app_tasks: limitToWire(values.appTasksLimit),
37+
per_app_tasks: limitToWire(values.appTasksLimit),
3838
},
3939
services: {
4040
paid_services_allowed: !!values.nonBasicServicesAllowed,
@@ -63,9 +63,9 @@ export function formToSpaceQuotaUpdateBody(values: SpaceQuotaFormValues): SpaceQ
6363
name: values.name,
6464
apps: {
6565
total_memory_in_mb: limitToWire(values.memoryLimit),
66-
total_instance_memory_in_mb: limitToWire(values.instanceMemoryLimit),
66+
per_process_memory_in_mb: limitToWire(values.instanceMemoryLimit),
6767
total_instances: limitToWire(values.appInstanceLimit),
68-
total_app_tasks: limitToWire(values.appTasksLimit),
68+
per_app_tasks: limitToWire(values.appTasksLimit),
6969
},
7070
services: {
7171
paid_services_allowed: !!values.nonBasicServicesAllowed,

src/frontend/packages/cloud-foundry/src/services/endpoint-data/quota-data.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export interface OrgQuotaWriteBody {
2222
name?: string;
2323
apps?: {
2424
total_memory_in_mb?: number | null;
25-
total_instance_memory_in_mb?: number | null;
25+
per_process_memory_in_mb?: number | null;
2626
total_instances?: number | null;
27-
total_app_tasks?: number | null;
27+
per_app_tasks?: number | null;
2828
};
2929
services?: {
3030
paid_services_allowed?: boolean;

src/jetstream/plugins/cloudfoundry/native_org_quotas_reads.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ func toStOrgQuota(q capi.OrganizationQuota, cnsiGUID string) StOrgQuota {
135135
}
136136
if q.Apps != nil {
137137
out.TotalMemoryInMB = nilIntToUnlimited(q.Apps.TotalMemoryInMB)
138-
out.TotalInstanceMemoryInMB = nilIntToUnlimited(q.Apps.TotalInstanceMemoryInMB)
138+
out.TotalInstanceMemoryInMB = nilIntToUnlimited(q.Apps.PerProcessMemoryInMB)
139139
out.TotalInstances = nilIntToUnlimited(q.Apps.TotalInstances)
140-
out.TotalAppTasks = nilIntToUnlimited(q.Apps.TotalAppTasks)
140+
out.TotalAppTasks = nilIntToUnlimited(q.Apps.PerAppTasks)
141141
}
142142
if q.Services != nil {
143143
if q.Services.PaidServicesAllowed != nil {

src/jetstream/plugins/cloudfoundry/native_org_quotas_reads_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestGetNativeOrgQuotas_ReturnsMappedQuotas(t *testing.T) {
4242
"created_at":"2026-04-22T12:00:00Z",
4343
"updated_at":"2026-04-22T12:00:00Z",
4444
"name":"default",
45-
"apps":{"total_memory_in_mb":102400,"total_instance_memory_in_mb":2048,"total_instances":1000,"total_app_tasks":500},
45+
"apps":{"total_memory_in_mb":102400,"per_process_memory_in_mb":2048,"total_instances":1000,"per_app_tasks":500},
4646
"services":{"paid_services_allowed":true,"total_service_instances":250,"total_service_keys":250},
4747
"routes":{"total_routes":1000,"total_reserved_ports":100},
4848
"domains":{"total_domains":10},

src/jetstream/plugins/cloudfoundry/native_org_quotas_writes.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ func (c *CloudFoundrySpecification) deleteNativeOrgQuota(ctx echo.Context) error
126126
return err
127127
}
128128

129-
if delErr := cfClient.OrganizationQuotas().Delete(ctx.Request().Context(), quotaGUID); delErr != nil {
129+
// fw-capi >= v3.217 returns the async job ref; the UI contract here
130+
// stays 204-on-accepted, so the job is not yet surfaced.
131+
if _, delErr := cfClient.OrganizationQuotas().Delete(ctx.Request().Context(), quotaGUID); delErr != nil {
130132
return handleCapiError(ctx, delErr)
131133
}
132134

src/jetstream/plugins/cloudfoundry/native_space_quotas_reads.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ func toStSpaceQuota(q capi.SpaceQuotaV3, cnsiGUID string) StSpaceQuota {
122122
}
123123
if q.Apps != nil {
124124
out.TotalMemoryInMB = nilIntToUnlimited(q.Apps.TotalMemoryInMB)
125-
out.TotalInstanceMemoryInMB = nilIntToUnlimited(q.Apps.TotalInstanceMemoryInMB)
125+
out.TotalInstanceMemoryInMB = nilIntToUnlimited(q.Apps.PerProcessMemoryInMB)
126126
out.TotalInstances = nilIntToUnlimited(q.Apps.TotalInstances)
127-
out.TotalAppTasks = nilIntToUnlimited(q.Apps.TotalAppTasks)
127+
out.TotalAppTasks = nilIntToUnlimited(q.Apps.PerAppTasks)
128128
}
129129
if q.Services != nil {
130130
if q.Services.PaidServicesAllowed != nil {

src/jetstream/plugins/cloudfoundry/native_space_quotas_reads_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestGetNativeSpaceQuotas_ReturnsMappedQuotas(t *testing.T) {
4141
"created_at":"2026-04-22T12:00:00Z",
4242
"updated_at":"2026-04-22T12:00:00Z",
4343
"name":"small",
44-
"apps":{"total_memory_in_mb":2048,"total_instance_memory_in_mb":1024,"total_instances":50,"total_app_tasks":25},
44+
"apps":{"total_memory_in_mb":2048,"per_process_memory_in_mb":1024,"total_instances":50,"per_app_tasks":25},
4545
"services":{"paid_services_allowed":true,"total_service_instances":10,"total_service_keys":10},
4646
"routes":{"total_routes":50,"total_reserved_ports":5},
4747
"relationships":{
@@ -287,7 +287,7 @@ func TestGetNativeSpaceQuotaDetail_ReturnsMappedQuota(t *testing.T) {
287287
"created_at":"2026-04-22T12:00:00Z",
288288
"updated_at":"2026-04-22T12:00:00Z",
289289
"name":"small",
290-
"apps":{"total_memory_in_mb":2048,"total_instance_memory_in_mb":1024,"total_instances":50,"total_app_tasks":25},
290+
"apps":{"total_memory_in_mb":2048,"per_process_memory_in_mb":1024,"total_instances":50,"per_app_tasks":25},
291291
"services":{"paid_services_allowed":true,"total_service_instances":10,"total_service_keys":10},
292292
"routes":{"total_routes":50,"total_reserved_ports":5},
293293
"relationships":{

src/jetstream/plugins/cloudfoundry/native_space_quotas_writes.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ func (c *CloudFoundrySpecification) deleteNativeSpaceQuota(ctx echo.Context) err
111111
return err
112112
}
113113

114-
if delErr := cfClient.SpaceQuotas().Delete(ctx.Request().Context(), quotaGUID); delErr != nil {
114+
// fw-capi >= v3.217 returns the async job ref; the UI contract here
115+
// stays 204-on-accepted, so the job is not yet surfaced.
116+
if _, delErr := cfClient.SpaceQuotas().Delete(ctx.Request().Context(), quotaGUID); delErr != nil {
115117
return handleCapiError(ctx, delErr)
116118
}
117119

0 commit comments

Comments
 (0)