Skip to content

How we pick stack and buildpacks for staging

Lisa Cho edited this page May 4, 2018 · 32 revisions

Saving Lifecycle on the App

  • AppLifeCycleProvider chooses docker vs buildpacks here
  • Creates an lifecycle (AppBuildpackLifecle) and passes it to AppCreate to be saved in DB.
  • Finds the stack in DB
  • Fetches the requested buildpacks from the DB
  • Some buildpacks aren't found in the DB because they are github urls or nonexistent.
  • Preserves requested buildpack order
  • Allow matching buildpacks on 'nil' unknown stacks and exact stack matches.
  • Maps to BuildpackInfos
  • Validates the combination of buildpacks and stacks.
  • Small class
  • Primary responsibility is to set buildpack_url for git buildpacks

Saving in DB

  • Lifecycle data is actually saved in buildpack_lifecycle_data and buildpack_lifecycle_buildpacks tables.
  • BuildpackLifecycleData has a buildpack field, but it's for legacy use.
  • Normally, BuildpackLifecycleData is linked to either an app or a build & droplet. The buildpack_lifecycle_data has many BuildpackLifecycleBuildpacks.
  • Additional validation on these models.

End result is that buildpacks and stack get saved on lifecycle on the app in the DB

Staging / Creating a build

  • basic string validation is in BuildpackLifecycleDataMessage
  • LifecycleProvider switches between buildpacks and docker similar to AppLifecycleProvider here
  • Calls Buildcreate with lifecycle
  • Similar to AppBuildPackLifecycle (creates lifecycle from a message object)
  • Key difference: buildpacks and stack can be requested on the message on stage request, or fall back to the what is saved on the app's lifecycle.
  • Calculates staging_details from the package (along with memory, disk, environment variables, etc).
  • lifecycle is nested on the staging_details.
  • Calls the Stager with the staging_details
  • Responsibility (once was to hold Diego staging logic vs DEA staging logic?)
  • Calls the Messenger with staging_details
  • Creates a task definition using the TaskRecipeBuilder and staging_details and passes off to BbsStagerClient
  • Responsibility: Defines all the fields to pass to Diego
  • The stack is called root_fs
  • Buildpacks are passed in the action
  • These two fields are calculated using the LifecycleProtocol, which then chooses BuildpacksLifecycleProtocol
  • Responsibility:
  • The stack comes from staging_details
  • The buildpacks are calculated using staging_details and BuildpackEntryGenerator
  • Handles user-specified buildpacks vs autodetection
  • For autodetection, return all the admin buildpacks.
  • For user-defined buildpacks, adds skip_detect field and return those.
  • Translates arguments into download actions and stage action commands
Clone this wiki locally