File tree Expand file tree Collapse file tree 2 files changed +1
-38
lines changed
lib/cloud_controller/diego
spec/unit/lib/cloud_controller/diego Expand file tree Collapse file tree 2 files changed +1
-38
lines changed Original file line number Diff line number Diff line change @@ -6,16 +6,7 @@ def create_or_update_app(process, client)
6
6
if ( existing_lrp = client . get_app ( process ) )
7
7
client . update_app ( process , existing_lrp )
8
8
else
9
- begin
10
- client . desire_app ( process )
11
- rescue CloudController ::Errors ::ApiError => e # catch race condition if Diego Process Sync creates an LRP in the meantime
12
- if e . name == 'RunnerError' && e . message [ 'the requested resource already exists' ]
13
- existing_lrp = client . get_app ( process )
14
- client . update_app ( process , existing_lrp )
15
- elsif e . name == 'UnprocessableEntity'
16
- raise
17
- end
18
- end
9
+ client . desire_app ( process )
19
10
end
20
11
end
21
12
end
Original file line number Diff line number Diff line change @@ -35,34 +35,6 @@ module Diego
35
35
expect ( client ) . not_to have_received ( :desire_app )
36
36
end
37
37
end
38
-
39
- context 'race condition when the Diego::ProcessesSync runs and creates a process ahead of the DesireAppHandler' do
40
- let ( :desired_lrp_update ) { double ( :desired_lrp_update ) }
41
- let ( :get_app_response ) { nil }
42
-
43
- before do
44
- allow ( client ) . to receive ( :update_app )
45
- allow ( client ) . to receive ( :desire_app ) . and_raise CloudController ::Errors ::ApiError . new_from_details ( 'RunnerError' , 'the requested resource already exists' )
46
- end
47
-
48
- it 'catches the error and updates the app' do
49
- DesireAppHandler . create_or_update_app ( process , client )
50
- expect ( client ) . to have_received ( :update_app )
51
- expect ( client ) . to have_received ( :get_app ) . exactly ( 2 ) . times
52
- end
53
- end
54
-
55
- context 'when root user is not permitted' do
56
- it 'raises a CloudController::Errors::ApiError' do
57
- allow ( client ) . to receive ( :desire_app ) . and_raise ( CloudController ::Errors ::ApiError . new_from_details ( 'UnprocessableEntity' ,
58
- 'Attempting to run process as root user, which is not permitted.' ) )
59
- expect { DesireAppHandler . create_or_update_app ( process , client ) } . to ( raise_error do |error |
60
- expect ( error ) . to be_a ( CloudController ::Errors ::ApiError )
61
- expect ( error . name ) . to eq ( 'UnprocessableEntity' )
62
- expect ( error . message ) . to include ( 'Attempting to run process as root user, which is not permitted' )
63
- end )
64
- end
65
- end
66
38
end
67
39
end
68
40
end
You can’t perform that action at this time.
0 commit comments