Helix Swarm Guide (2018.3)

Multiple-Helix Server instances

Typically an organization only requires a single Helix Core Server but there are situations when you might have multiple-Helix Servers in your organization. A single Swarm server can be connected to a number of Helix Core Server (P4D) instances. This section describes how to configure Swarm to connect to multiple Helix Servers.

Note

Known limitations, only applies if you want to use Global Dashboard:

  • If Multi-factor authentication (MFA) is enabled for Swarm, you cannot log in to the Helix Server instances from the Global Dashboard.
  • Workaround: Log in to each instance individually by including the server instance name in the URL, for example: https://swarm.company.com/serverA.

  • If Helix SAML is enabled for Swarm and the Try to login to all available servers with these credentials checkbox is selected in the login dialog, Swarm will not try to log in to any of the other Helix Server instances that are configured for Helix SAML. Log in to them individually using the instance Log in button Image of the global dashboard log in button in the sidebar.
  • Swarm must be installed in its own virtual host.

Complete the following steps to connect Swarm to multiple-Helix Server instances:

Set up the Swarm configuration file for the Helix Servers

The Swarm Helix Server connection details are configured using the p4 item in the <swarm_root>/data/config.php configuration file.

When Swarm is configured for a single Helix Server instance the p4 item looks like this:

<?php
    return array(
        'p4' => array(
            'port'      => 'my-helix-core-server:1666',
            'user'      => 'admin_userid',
            'password'  => 'admin user ticket or password',
            'sso_enabled' => false, // defaults to false
         ),
    );

Where:

  • port is the P4PORT for your Helix Server.
  • user is a userid that has admin privileges for the Helix Server.
  • password is the ticket or password for the Helix Server user.
  • sso_enabled set to true if the Helix Server is configured for Helix SAML.
  • Important

    To use Helix SAML with Swarm:

Multiple Helix Server instances can be added to the p4 item in config.php but each Helix Server instance must have a label to identify the server instance. This enables Swarm to connect to the Helix Servers in the p4 item.

The first Helix Server in the p4 item is the primary Helix Server. If Swarm fails to connect to this Helix Server, Swarm will not be able to connect to any of the other Helix Server instances in p4.

Configure the Swarm configuration file for multiple Helix Server instances:

Enter a label for each Helix Server instance and enter the server connection details under the server label.

For example:

<?php
    return array(
        'p4' => array(
            'serverA' => array(
            'port'      => 'p4d-A:1666',
            'user'      => 'admin_userid_serverA',
            'password'  => 'admin user ticket or password for serverA',
            'sso_enabled' => false, // defaults to false
        ),
        'serverB' => array(
            'port'      => 'p4d-B:1666',
            'user'      => 'admin_userid_serverB',
            'password'  => 'admin user ticket or password for serverB',
            'sso_enabled' => true, // defaults to false
        ),		
    );

Where:

  • serverA and serverB are labels that identify the individual Helix Servers. The labels must be URL-friendly labels, the labels must not contain any spaces or any characters that require URL encoding.
  • The port, user, password, and sso_enabled items are specific to the Helix Server instance they are nested under.

Set the Swarm trigger token and Swarm host variable for each Helix Server

Helix Server uses a Swarm trigger token to confirm that trigger requests from Swarm are valid. Each Helix Server instance must have a valid Swarm trigger token in its swarm-trigger.conf file. The swarm-trigger.conf file also contains the Swarm host URL for the Helix Server instance.

Set the Swarm trigger token and Swarm host variable for each Helix Server instance:

  1. Navigate to the Swarm URL for the instance.
  2. For example: https://swarm.company.com/serverA

  3. Log in to Swarm as a super user.
  4. Click your userid, in the main toolbar and select About Swarm.
  5. The About Swarm dialog is displayed with a Trigger Token. Swarm generates the trigger token if it doesn't already exist.

  6. Copy the trigger token value from the dialog.
  7. Open the swarm-trigger.conf file for the Helix Server instance.
  8. Tip

    For more information about the location of the swarm-trigger.conf file, see Set up Swarm triggers with a Windows or Linux-hosted Helix Server.

  9. In the swarm-trigger.conf file:
    1. Set the SWARM_HOST URL.
    2. Set the SWARM_TOKEN by pasting the Swarm trigger token you copied in the steps above.
  10. For example:

    # SWARM_HOST (required)
    # Hostname of your Swarm instance, with leading "http://" or "https://".
    SWARM_HOST="https://swarm.company.com/serverA"
    
    # SWARM_TOKEN (required)
    # The token used when talking to Swarm to offer some security. To obtain the
    # value, log in to Swarm as a super user and select 'About Swarm' to see the
    # token value.
    SWARM_TOKEN="TRIGGER-TOKEN-FOR-SERVERA"
    

  11. Save the swarm-trigger.conf file.
  12. Repeat these steps for each Helix Server.
Tip

Alternatively, you can simply touch a file in each <Swarm root>/data/servers/<serverid>/tokens folder. The file content is ignored, the filename itself is the token.

This allows you to specify a common token that is used by all of the Helix Server instances.

However, we recommend that you use a separate token for each Helix Server instance. This makes it easier to invalidate a token for a specific Helix Server by deleting the file in the tokens folder for that server if you need to.

Configure a cron job for each Helix Server instance

To automatically spawn workers for each of the servers connected to Swarm, you must manually configure a cron job for each of the servers.

Swarm package and OVA installations only

The swarm-cron-hosts.conf file specifies the connection type (HTTP or HTTPS), hostname, port number and, server label for Swarm cron jobs.

If you have installed Swarm via packages or you are running the Swarm OVA, you must specify all of the Helix Server URLs within /opt/perforce/etc/swarm-cron-hosts.conf.

  1. Edit the swarm-cron-hosts.conf file so that it contains the actual Swarm hostname, ports, and server labels you have configured for Swarm.
  2. The following format is used with one Helix Server on each line:

    [http[s]://]<swarm-host>[:<port>][/<base-url>]
    

    Default if value not specified:

    • [http[s]://] http
    • <swarm-host> must be specified
    • [:<port>] 80
    • [/<base-url>] server label, must be specified

    For example, for serverA and serverB configured earlier on a Swarm host of https://swarm.company.com with a default port value of 80. The entries in the swarm-cron-hosts.conf file would be:

    https://swarm.company.com/serverA
    https://swarm.company.com/serverB					
    
  3. Save the swarm-cron-hosts.conf file.
  4. Swarm is now configured to connect to multiple-Helix Server instances.
  5. Tip

    To check or modify Swarm worker configuration, see Worker configuration.

Swarm Tarball installation only

If you have installed Swarm from a tarball or configured cron manually, you need create a file called helix-swarm and add all of the Helix Server instances connected to Swarm.

  1. Create a file named helix-swarm in /etc/cron.d if it does not already exist.
  2. Edit the helix-swarm file so that it has the following content:
  3. #
    # Cron job to start Swarm workers every minute
    #
    * * * * * nobody [ -x /opt/perforce/swarm/p4-bin/scripts/swarm-cron.sh ] && /opt/perforce/swarm/p4-bin/scripts/swarm-cron.sh

  4. Save the helix-swarm file.
  5. Edit the swarm-cron-hosts.conf file so that it contains the actual Swarm hostname, ports, and server labels you have configured for Swarm.
  6. The following format is used with one Helix Server on each line:

    [http[s]://]<swarm-host>[:<port>][/<base-url>]
    

    Default if value not specified:

    • [http[s]://] http
    • <swarm-host> must be specified
    • :<port> 80
    • [/<base-url>] server label, must be specified

    For example, for serverA and serverB configured earlier on a Swarm host of https://swarm.company.com with a default port value of 80. The entries in the swarm-cron-hosts.conf file would be:

    https://swarm.company.com/serverA
    https://swarm.company.com/serverB					
    
  7. Save the swarm-cron-hosts.conf file.
  8. Swarm is now configured to connect to multiple-Helix Server instances.
  9. Tip

    To check or modify Swarm worker configuration, see Worker configuration.

Further information

Users

  • To visit the Global Dashboard, enter the basic Swarm URL without a Helix Server instance name, for example: https://swarm.company.com
  • To visit a specific Helix Server instance in Swarm without going via the global dashboard, include the server name in the URL, for example: https://swarm.company.com/serverA.

Once you are viewing the Helix Server in Swarm, Swarm works as a standard single Helix ServerSwarm system.

Tip
  • To browse jobs on serverA, navigate to: https://swarm.company.com/serverA/jobs
  • To browse reviews on serverB, navigate to: https://swarm.company.com/serverB/reviews
  • To view the dashboard for serverB, navigate to https://swarm.company.com/serverB/#actionable-reviews
  • If you don't include the server label in the URL you will be taken to the specified page for the primary Helix Server.
  • For example: navigating to https://swarm.company.com/reviews will redirect you to https://swarm.company.com/serverA/reviews because serverA is the Primary Helix Server in the p4 configuration item.

Administrators

On the web server hosting Swarm, Swarm automatically creates a data folder for each Helix Server instance in <Swarm_root>/data/servers. This is because each Helix Server request is a field.

For example:

# ls -la /opt/perforce/swarm/data/servers/serverA
total 362296			
drwx------ 6 apache apache    4096 Sep  8 17:15 .
drwx------ 6 apache apache    4096 Sep  6 15:41 ..
drwx------ 2 apache apache    4096 Sep 20 18:08 cache
drwx------ 3 apache apache    4096 Sep  7 13:25 clients
-rw-r--r-- 1 apache apache 3709543 Sep 26 14:19 log
-r-------- 1 apache apache      84 Sep  6 15:41 p4trust
drwx------ 4 apache apache    4096 Sep 20 14:27 queue
drwx------ 2 apache apache    4096 Sep 20 11:18 sessions
Tip

It is important to understand that there will be a Swarm log file for each Helix Server instance.

Developers

To get a list of projects via the Swarm API for serverA, run bash:

  • If you are using wget:

    $ wget -u "apiuser:password" https://swarm.company.com/serverA/api/v3/projects
  • If you are using curl:

    $ curl -u "apiuser:password" https://swarm.company.com/serverA/api/v3/projects

Tip

If you don't include the server label in the URL you will be taken to the projects page for the primary Helix Server.

For example: navigating to https://swarm.company.com/api/v3/projects will redirect you to https://swarm.company.com/api/v3/serverA/projects because serverA is the Primary Helix Server in the p4 configuration item.