JetBrains CodeCanvas 2024.1 Help

Warm-up

Dev environments can significantly increase the speed of development by removing the IDE warm-up phase: a period of time when the IDE builds indexes, and does other background activities like resolving project dependencies. You can put all these routines into a dev environment warm-up and run it on schedule. The result of the warm-up is a warm-up snapshot (a Docker volume) that is then mounted to a dev environment. Make sure the warm-up is run regularly: The fresher the index data is, the faster a dev environment will be ready for work.

When creating a dev environment, users will be able to choose the warm-up snapshot to start from.

Configure the warm-up

To configure warm-up, use the Performance and costs | Warm-up section of a dev environment template.

Warm-up

Here:

  • Instance type – the resources allocated to the dev environment that will be used for creating the warm-up snapshot. As performance is not critical for the warm-up dev environments, you can choose a smaller instance type than for user dev environments.

  • Create project indexes – if enabled, the warm-up will build project indexes for the IDE specified in the template. Note that if you disable this option, you should provide a warm-up script in Script path. Otherwise, the warm-up will be useless.

  • Script path   – a path to your custom shell script that will be run before the warm-up runs the IDE to build indexes. For example, you can use it to build your project with ./gradlew build or to configure the IDE. Don't use the script to install additional tools (e.g., with apt get )  – this data will not be saved in the snapshot. Before specifying this path, create the script file in the project repository. Learn more

  • Parameters – environment variables that will be available in the warm-up. Use them to provide sensitive data to the warm-up environment like user credentials or access tokens. Learn more

  • Execution timeout (minutes)   – CodeCanvas stops the warm-up and considers it failed if it takes longer than the specified time.

  • Cron triggers   – the schedule for the warm-up. Use the crontab format to specify the schedule (UTC timezone). For example, 0 1 * * 1-5 runs the warm-up every day at 1:00AM except for weekends. Learn more

How the warm-up works

When the warm-up is triggered, CodeCanvas creates a dev environment based on the template settings: the specified container image, environment variables, and so on. Important: the environment can't be personalized for a particular user, that is, it can't use personal parameters. If you need to provide sensitive data to the warm-up, use warm-up parameters.

In this warm-up environment, CodeCanvas:

  1. Checks out the project source code.

  2. Runs your custom shell script if you specified it in the Script field. The warm-up will proceed to the next step only if the script exits successfully with a zero status code.

  3. Runs the IDE specified in the template and builds project indexes.

    Project indexes are specific for each IDE and most often for each IDE version. For the warm-up, CodeCanvas uses the IDE version specified in the IDE version parameter of the template. If it's Default, the warm-up will build indexes for the default IDE version.

    If you don't want the warm-up to build project indexes, clear the Create project indexes checkbox.

  4. Saves a snapshot of the file system  – a warm-up snapshot.

Warm-up snapshot

Technically, a warm-up snapshot is a Docker volume that contains the /root (the container always runs under the root user), the /mnt/jetbrains, and the var/lib/docker directories:

/ ├─── root // user directory with project indexes (saved during the warm-up or stop) │... ├─── mnt │ └─── jetbrains // saved during the warm-up or stop │ ├─── system // non-user system files │ └─── work │ └─── {git-repo-name} // cloned git repository (working directory) │... ├─── var │ └─── lib │ └─── docker // Docker data ...

Everything outside these directories is discarded. For this reason you shouldn't use the warm-up, for example, to install additional tools with apt get. For this purpose, use custom dev environment images.

Important notes:

  • CodeCanvas stores only the latest warm-up snapshot for each combination of an IDE and a Git branch. An IDE version is not taken into account. For example, a project has two branches: main and feature-branch. Suppose some developers use JetBrains Rider and some use IntelliJ IDEA. There can be four snapshots maximum: main + Rider, main + IDEA, feature-branch + Rider, and feature-branch + IDEA.

  • Dev environments started from the same snapshot are independent of each other and don't share their state in any way.

  • The way snapshots are taken depends on the infrastructure. For example, in AWS, dev environment disks and snapshotting are based on EBS.

To view warm-up snapshots available in a namespace

  1. Find the namespace.

  2. On the sidebar namespace menu, select Warm-up Snapshots.

To delete a warm-up snapshot

  1. Find the namespace.

  2. On the sidebar namespace menu, select Warm-up Snapshots.

  3. Find the snapshot and click Delete dev environment Delete.

Trigger the warm-up

There are two ways to trigger the warm-up: manually in the CodeCanvas UI and by schedule.

  1. Find the namespace.

  2. On the sidebar namespace menu, select Warm-up Snapshots.

  3. Click New warm-up snapshot.

  4. In the dialog, specify the required dev environment template and repository branch, and click Create.

The Cron triggers parameter of a dev environment template specifies the warm-up schedule. During the warm-up, CodeCanvas will use the environment settings (including the branch) specified in the template.

When specifying the schedule, use the UTC timezone and the crontab format (MIN HOUR DAY MONTH DAYOFWEEK). For example, to run warm-up every Friday at 23:59 UTC, specify 59 23 * * FRI.

To add one more trigger, click Add another and specify the schedule.

Provide sensitive data to a warm-up dev environment

Your project might require sensitive data, like user credentials or access tokens, for example, for getting dependencies from a private repository or for accessing a database. While you can use personal user parameters for individual user dev environments, warm-up dev environments also require this data for their work. You define the required warm-up parameters on the namespace level and then assign them to the corresponding environment variables in the warm-up settings.

To define a warm-up parameter

  1. Find the namespace.

  2. On the sidebar namespace menu, select Settings, then Warm-up Parameters.

  3. Click New parameter.

  4. Specify

    • Key: a parameter name. You will use this name to reference this parameter in the warm-up settings.

    • Value: a parameter value.

    Notes:

    • Parameters are stored in the encrypted form.

    • Parameters are used only during the warm-up with no user access to them.

    • Parameters exist only in the scope of a particular namespace. So, if you create a parameter in one namespace, you can't use them in other namespaces.

    • Parameter keys must be unique within a namespace.

    • A key must be no longer than 128 characters and can only contain alphanumeric characters ([a-z], [A-Z], [0-9]), dashes (-), or underscores (_).

    • Keys are case-insensitive.

    • Max secret's or parameter's value size is 30KB.

To add a parameter to a template

  1. In the template settings, open the Performance and costs section.

  2. In the warm-up settings, under Parameters, click Add parameter.

  3. Specify parameter settings:

    • Type– select the type of the variable: Variable (environment variable) or File.

    • Name – the name of the environment variable or an absolute path to a file on the warm-up environment.

    • Warm-up parameter – a reference to a warm-up parameter defined on the namespace level.

Examples

Create indexes on schedule

  • [v] Create project indexes

  • Cron triggers: 0 4,12 * * * (every day at 4:00 and 12:00)

Build the project and create indexes on schedule

  • [v] Create project indexes

  • Script: ./build.sh

  • Cron triggers: 0 4,12 * * * (every day at 4:00 and 12:00)

Last modified: 02 July 2024