|
| 1 | +.. _https_services: |
| 2 | + |
| 3 | +================================== |
| 4 | +Installing HTTPs services in DIRAC |
| 5 | +================================== |
| 6 | + |
| 7 | +.. contents:: |
| 8 | + |
| 9 | +Background |
| 10 | +********** |
| 11 | + |
| 12 | +For many years, DIRAC services have been exposed through the historical DISET (``dips://``) protocol. |
| 13 | +Few years ago DIRAC developers started exposing DIRAC services using the HTTPs protocol. |
| 14 | +This page explains how to migrate existing DIPs protocol to HTTPs. For a developer view, refer to :ref:`httpsTornado`. |
| 15 | + |
| 16 | +For a summary presentation you can check `this <https://indico.cern.ch/event/852597/contributions/4331720/attachments/2241040/3799728/HttpsInDIRAC.pdf>`_. |
| 17 | + |
| 18 | +NB: not all DIPs services can be exposed through HTTPs. For a comprehensve list, please refer to :ref:`scalingLimitations`. |
| 19 | + |
| 20 | +General principle |
| 21 | +================= |
| 22 | + |
| 23 | +Contrary to the DISET protocol where each service would have its own process and port opened, HTTPs services are served by a unique process and port, based on Tornado. |
| 24 | + |
| 25 | +There are exceptions to that, due to the use of global variables in some parts of DIRAC. Namely: |
| 26 | + |
| 27 | +* Master CS |
| 28 | + |
| 29 | +All other services can follow the standard procedure described below. |
| 30 | + |
| 31 | +First, the following configuration subsections have to be added to CS:: |
| 32 | + |
| 33 | + # "Main" section |
| 34 | + DIRAC |
| 35 | + { |
| 36 | + Setups |
| 37 | + { |
| 38 | + ... |
| 39 | + Tornado = Production |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + # Add Tornado to Systems section |
| 44 | + Systems |
| 45 | + { |
| 46 | + ... |
| 47 | + Tornado |
| 48 | + { |
| 49 | + Production |
| 50 | + { |
| 51 | + Port = 443 |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + |
| 57 | +Installation of an HTTPs based service |
| 58 | +====================================== |
| 59 | + |
| 60 | +This procedure is to be used if you are want to serve a new service with HTTPs. |
| 61 | + |
| 62 | + |
| 63 | +Case 1: you do NOT run the equivalent DISET service |
| 64 | +--------------------------------------------------- |
| 65 | + |
| 66 | +This is the most trivial case. Just run ``dirac-install-tornado-service`` with the service you are interested in. This will install an ``runit`` component running ``tornado-start-all``. |
| 67 | + |
| 68 | +Case 2: you run the equivalent DISET service |
| 69 | +-------------------------------------------- |
| 70 | + |
| 71 | +Because the CS already contains the handler definition for DISET, ``dirac-install-tornado-service`` will not modify it. Thus, you have to update it yourself, before running the command, otherwise ``tornado-start-all`` will not find any service to run, and the installation will be shown as failed. |
| 72 | + |
| 73 | +Procedure: |
| 74 | + |
| 75 | +#. Update by hand the CS of the desired service: |
| 76 | + |
| 77 | + * Remove the port definition |
| 78 | + * Modify the handler to point to the Tornado handler |
| 79 | + * add ``Protocol=https`` |
| 80 | + |
| 81 | +The example the follows is for the "DIRAC File Catalog" (DFC) service. This would normally be in CS as:: |
| 82 | + |
| 83 | + Systems |
| 84 | + { |
| 85 | + ... |
| 86 | + DataManagement |
| 87 | + { |
| 88 | + Production |
| 89 | + { |
| 90 | + URLs |
| 91 | + { |
| 92 | + ... |
| 93 | + FileCatalog = dips://my.server.org:9197/DataManagement/FileCatalog |
| 94 | + } |
| 95 | + Services |
| 96 | + { |
| 97 | + ... |
| 98 | + FileCatalog |
| 99 | + { |
| 100 | + ... |
| 101 | + Port = 9197 |
| 102 | + Protocol = dips |
| 103 | + ... |
| 104 | + } |
| 105 | + } |
| 106 | + ... |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + |
| 112 | +And you need to change it to:: |
| 113 | + |
| 114 | + Systems |
| 115 | + { |
| 116 | + ... |
| 117 | + DataManagement |
| 118 | + { |
| 119 | + Production |
| 120 | + { |
| 121 | + URLs |
| 122 | + { |
| 123 | + ... |
| 124 | + FileCatalog = https://my.server.org:8443/DataManagement/FileCatalog |
| 125 | + } |
| 126 | + Services |
| 127 | + { |
| 128 | + ... |
| 129 | + FileCatalog |
| 130 | + { |
| 131 | + ... |
| 132 | + Protocol = https |
| 133 | + HandlerPath = DIRAC/DataManagementSystem/Service/TornadoFileCatalogHandler.py |
| 134 | + ... |
| 135 | + } |
| 136 | + } |
| 137 | + ... |
| 138 | + } |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + |
| 143 | +#. Run ``dirac-install-tornado-service`` or restart the tornado component if already running. |
| 144 | + |
| 145 | +.. note:: |
| 146 | + This means that from now on, the DISET service cannot be restarted anymore, as its configuration would be wrong. |
| 147 | + So, go ahead and remove (by hand, for now) the `runit`-related directories of the DISET service. |
| 148 | + |
| 149 | +Example of configuration before/after: |
| 150 | + |
| 151 | +.. literalinclude:: /../../src/DIRAC/WorkloadManagementSystem/ConfigTemplate.cfg |
| 152 | + :start-after: ##BEGIN JobMonitoring |
| 153 | + :end-before: ##END |
| 154 | + :dedent: 2 |
| 155 | + :caption: JobMonitoring configuration for DISET |
| 156 | + |
| 157 | +.. literalinclude:: /../../src/DIRAC/WorkloadManagementSystem/ConfigTemplate.cfg |
| 158 | + :start-after: ##BEGIN TornadoJobMonitoring |
| 159 | + :end-before: ##END |
| 160 | + :dedent: 2 |
| 161 | + :caption: JobMonitoring configuration for HTTPs |
| 162 | + |
| 163 | +In any case, do not forget to update the URL of the service you just installed, such that other services can reach it. |
| 164 | + |
| 165 | + |
| 166 | +Adding more tornado instances on a different machine |
| 167 | +==================================================== |
| 168 | + |
| 169 | +Simply use ``dirac-install-tornado-service`` with no arguments on the new machine. |
| 170 | + |
| 171 | + |
| 172 | +MasterCS special case |
| 173 | +===================== |
| 174 | + |
| 175 | +The master Configuration Server is different and needs to be run in a separate process. In order to do so: |
| 176 | + |
| 177 | +* Do NOT specify ``Protocol=https`` in the service description, otherwise it will be ran with all the other Tornado services. |
| 178 | +* If you run on the same machine as other TornadoService, specify a ``Port`` in the service description (you can keep the existing 9135, if already there). |
| 179 | +* Modify the content of the Configuration so that URLs are updated to use HTTPs instead of DIPs. |
| 180 | +* Add `HandlerPath = DIRAC/ConfigurationSystem/Service/TornadoConfigurationHandler.py` in the etc/dirac.cfg configuration file of the machine where the master CS is running (needed for bootstrap). |
| 181 | + |
| 182 | +Finally, there is no automatic installations script. So just install a CS as you normally would do, and then edit the ``run`` file like that:: |
| 183 | + |
| 184 | + #!/bin/bash |
| 185 | + rcfile=/opt/dirac/bashrc |
| 186 | + [ -e $rcfile ] && source $rcfile |
| 187 | + # |
| 188 | + export DIRAC_USE_TORNADO_IOLOOP=Yes |
| 189 | + exec 2>&1 |
| 190 | + # |
| 191 | + [ "service" = "agent" ] && renice 20 -p $$ |
| 192 | + # |
| 193 | + # |
| 194 | + exec tornado-start-CS -ddd |
0 commit comments