Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Latest commit

 

History

History
60 lines (49 loc) · 3.74 KB

build-flow.md

File metadata and controls

60 lines (49 loc) · 3.74 KB

Build Scheduling Process

  1. Creates BuildChain from payload (BuildChainService method createFromPayload())

    1. Create build chain for logged in user
    2. Add the build options to the build chain
    3. Extract payload into a pre determined folder (based on build chain id)
    4. Parse build info (.apb.yml)
    5. Create one request for every Platform and Flavor combination found in the yml Note: if the flavor parameter is passed, only one request for the created flavor is created
    6. Populates all created Build Request with it's flavor, platform, engine and BuildChain

    Note: If any of the previous steps fails, a CANCELLED Build Request is created, and the process stops.


  2. For each BuildRequest created, asynchronously schedule it ((BuildRequestService method schedule()))

    1. Find the actual platform in the database that this Build Request should be built against
    2. Find the actual flavor this request represents in the configuration file (apb.yml)
    3. Find the actual engine in the database that this Build Request should be built against
    4. Validates that all the required variables are passed
    5. Find a BuildAgent capable of building this request.
      • Note: This respects the build agent current load, if there are more than 1 build agent that can build the request, the less loaded will be chosen.
    6. Queue the request for execution on the BuildAgent.

    Note: If any of the previous steps fails, the Build Request is cancelled.


  3. Scheduling of the BuildRequest (starts on BuildAgentQueueService method queue() called from the previous step)

    1. BuildAgentQueueService Finds or create a BuildAgentQueueController which is the component that manages the build agents queues.
    2. Submit the new task to the BuildAgentQueueController
    3. The BuildRequest is added to the queue BuildAgent queue.

Build Execution Process

When a new BuildAgentQueueController is created (on demand based on the Scheduling Process step 3.1) to manage a Build Agent, the following steps are executed:

  1. A FIFO queue of BuildRequest is created with the capacity defined in the BuildAgent queue.size variable or system default if not defined.
  2. BuildExecutorWorkers are created respecting the max.concurrent.builds variable defined in the BuildAgent or system default.
    • NOTE: Currently only SSHBuildExecutorWorker are supported, but the architecture is enabled to support any kind of worker.
  3. The BuildExecutorWorkers start watching the FIFO queue and execute when a new BuildRequest arrives.`
  4. When a Request Arrives ( Scheduling Process step 3.3) the execution begins
    1. The BuildRequest is marked as RUNNINGand the startTime is populated.
    2. A new Logger is created to handle the build process logging.
    3. Steps when SSHBuildExecutorWorker is used
      1. Connects to remote agent via ssh
      2. Create the necessary folders in the remote agent
      3. Uploads the compressed input file
      4. Extracts the compressed input file
      5. Builds the BuildCommand using the BuildCommandBuilderService (currently only docker commands are supported)
      6. Executes the BuildCommand on the agent, forwarding the output (stdout and stderr) to the build log.
      7. Tries to Downloads artifacts if the artifacts properties are populated.
      8. Finishes the request and disconnect from the agent.
      9. Cleanup the input files in the agent.
      10. Close any connected log consumers. NOTE: If any error occurs that blocks the build, the build is marked as FAILED;