Skip to content

Commit

Permalink
Handle ProcessNotFoundError in cf apps
Browse files Browse the repository at this point in the history
As a user calls `cf apps` in a large space it might happen that a app
was deleted while the CLI is putting all the different information (processes, stats & routes) together.
This leads to a failing `cf apps` command.
This change prevents this by catching `ProcessNotFoundError` errors and returning `nil` instead.
Related to #2734
  • Loading branch information
johha committed Feb 20, 2024
1 parent 5bacbb0 commit 7240bd3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions actor/v7action/application_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,56 @@ var _ = Describe("Application Summary Actions", func() {
Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(0))
})
})

When("an application is deleted in between", func() {

BeforeEach(func() {
fakeCloudControllerClient.GetApplicationsReturns(
[]resources.Application{
{
Name: "some-app-name",
GUID: "some-app-guid",
State: constant.ApplicationStarted,
},
},
nil,
nil,
)

fakeCloudControllerClient.GetProcessesReturns(
[]resources.Process{
{
GUID: "some-process-web-guid",
Type: "web",
Command: *types.NewFilteredString("[Redacted Value]"),
MemoryInMB: types.NullUint64{Value: 64, IsSet: true},
AppGUID: "some-app-guid",
},
},
nil,
nil,
)

fakeCloudControllerClient.GetProcessInstancesReturns(nil, nil, ccerror.ProcessNotFoundError{})
})

It("does not fail and has empty ProcessSummaries & Routes", func() {
Expect(executeErr).ToNot(HaveOccurred())

Expect(summaries).To(Equal([]ApplicationSummary{
{
Application: resources.Application{
Name: "some-app-name",
GUID: "some-app-guid",
State: constant.ApplicationStarted,
},
ProcessSummaries: nil,
Routes: nil,
},
}))

})
})
})

Describe("GetDetailedAppSummary", func() {
Expand Down

0 comments on commit 7240bd3

Please sign in to comment.