Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit f05a752

Browse files
committed
use detected start command when scheduling kpack droplets
- `@process.command` only covers commands set through the API - `@process.started_command` is what we use when scheduling LRPs on BOSH since it also includes detected start commands and commands from a `Procfile` - this worked before for the `web` process because the kpack-built image's `Entrypoint` knows the detected start command -- it did not work for multi-process apps, however [#175081086](https://www.pivotaltracker.com/story/show/175081086) Authored-by: Tim Downey <tdowney@vmware.com>
1 parent a4f5a97 commit f05a752

2 files changed

Lines changed: 55 additions & 15 deletions

File tree

lib/cloud_controller/opi/apps_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def initialize(process)
112112
end
113113

114114
def to_hash
115-
command = if @process.command.presence
116-
['/bin/sh', '-c', "#{CNB_LAUNCHER_PATH} #{@process.command}"]
115+
command = if @process.started_command.presence
116+
['/bin/sh', '-c', "#{CNB_LAUNCHER_PATH} #{@process.started_command}"]
117117
else
118118
[]
119119
end

spec/unit/lib/cloud_controller/opi/apps_client_spec.rb

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -385,20 +385,60 @@
385385

386386
context 'when droplet has a kpack lifecycle' do
387387
let(:lifecycle_type) { :kpack }
388-
it 'sends a PUT request' do
389-
response = client.desire_app(lrp)
390388

391-
expect(response.status_code).to equal(201)
392-
expect(WebMock).to have_requested(:put, "#{opi_url}/apps/process-guid-#{lrp.version}").with { |request|
393-
actual_body = MultiJson.load(request.body, symbolize_keys: true)
394-
expected_body_with_lifecycle = expected_body.merge(lifecycle: {
395-
docker_lifecycle: {
396-
image: 'http://example.org/image1234',
397-
command: ['/bin/sh', '-c', '/cnb/lifecycle/launcher ls -la']
398-
}
399-
})
400-
actual_body == expected_body_with_lifecycle
401-
}
389+
context 'when the process has a specified start command' do
390+
it 'sends a PUT request with the specified command' do
391+
response = client.desire_app(lrp)
392+
393+
expect(response.status_code).to equal(201)
394+
expect(WebMock).to have_requested(:put, "#{opi_url}/apps/process-guid-#{lrp.version}").with { |request|
395+
actual_body = MultiJson.load(request.body, symbolize_keys: true)
396+
expected_body_with_lifecycle = expected_body.merge(lifecycle: {
397+
docker_lifecycle: {
398+
image: 'http://example.org/image1234',
399+
command: ['/bin/sh', '-c', '/cnb/lifecycle/launcher ls -la']
400+
}
401+
})
402+
actual_body == expected_body_with_lifecycle
403+
}
404+
end
405+
end
406+
407+
context 'when the process has a detected start command' do
408+
let(:lrp) do
409+
lrp = ::VCAP::CloudController::ProcessModel.make(:process,
410+
app: app_model,
411+
state: 'STARTED',
412+
diego: false,
413+
guid: 'process-guid',
414+
type: 'web',
415+
health_check_timeout: 12,
416+
instances: 21,
417+
memory: 128,
418+
disk_quota: 256,
419+
file_descriptors: 32,
420+
health_check_type: 'port',
421+
enable_ssh: false,
422+
)
423+
lrp.this.update(updated_at: Time.at(2))
424+
lrp.reload
425+
end
426+
427+
it 'sends a PUT request with the detected command' do
428+
response = client.desire_app(lrp)
429+
430+
expect(response.status_code).to equal(201)
431+
expect(WebMock).to have_requested(:put, "#{opi_url}/apps/process-guid-#{lrp.version}").with { |request|
432+
actual_body = MultiJson.load(request.body, symbolize_keys: true)
433+
expected_body_with_lifecycle = expected_body.merge(lifecycle: {
434+
docker_lifecycle: {
435+
image: 'http://example.org/image1234',
436+
command: ['/bin/sh', '-c', '/cnb/lifecycle/launcher $HOME/boot.sh']
437+
}
438+
})
439+
actual_body == expected_body_with_lifecycle
440+
}
441+
end
402442
end
403443
end
404444
end

0 commit comments

Comments
 (0)