.. _neteye-upgrade-cluster:

Cluster Upgrade from 4.22 to 4.23
=================================

This guide will lead you through the steps specific for upgrading
a **NetEye Cluster** installation from version **4.22** to
**4.23**.

.. warning:: Remember that you must upgrade sequentially without
   skipping versions, therefore an upgrade to **4.23** is possible
   only from **4.22**; for example, if you have version **4.14**, you
   must first upgrade to the **4.15**, then **4.16**, and so on.

Before starting an upgrade, you should very carefully read the latest
release notes on `NetEye's blog
<https://www.neteye-blog.com/category/neteye/release-notes-2/>`_ and
check the feature changes and deprecations specific to the version
being upgraded.  You should check also the whole section
:ref:`cluster-breaking` below.

The remainder of this section is organised as follows. Section
:ref:`cluster-breaking` introduces substantial changes that users must
be aware of before starting the upgrade procedure and may require to
carry out some tasks **before** starting the upgrade; section
:ref:`cluster-prerequisites` provide information to be known before
starting the upgrade procedure; section :ref:`cluster-conv` defines
some notation used in this procedure; section :ref:`single-upgrade`
presents the actual procedure, including directions for special nodes;
section :ref:`cluster-reactivation` instructs on how to bring the
NetEye Cluster back to complete functionality, and finally section
:ref:`upgrade-additional-steps-single` shows which tasks must be
executed after the upgrade procedure has been successfully executed.

.. _cluster-breaking:

Breaking Changes
----------------

.. rubric:: New underlying operating system

We recall (see section :ref:`update-overview`) that the upgrade
procedure includes a change of operating system.
Therefore, the upgrade consists of 3 steps for each NetEye Cluster node:

#. Conversion from **CentOS 7** to **RHEL 7**
#. Conversion from **RHEL 7** to **RHEL 8**
#. NetEye upgrade finalization

A manual reboot of the system is required between each step.
The 3-steps procedure can take a long time and must be performed
**in its entirety in one session**, as systems in intermediate
state are not supported.

.. _cluster-prerequisites:

Prerequisites
-------------


.. rubric:: Time estimation
            
Upgrading a NetEye Cluster will take a nontrivial amount of
time. During the upgrade, individual nodes will be put into standby
mode and so overall performance will be degraded until the upgrade
procedure is completed and all nodes are removed from standby mode.

An estimate for the time needed for a full upgrade (update + upgrade)
when the NetEye Cluster is healthy, there is no additional NetEye
modules installed, and the procedure is successful is approximately
**2 hours per node** plus at least **30 minutes** of NetEye Cluster
downtime (see below).

.. warning:: The estimation **does not** take into account the time
   required to download the packages and for any manual intervention:
   for example migration of configurations due to breaking changes,
   failure of tasks during the execution of the :command:`neteye
   update` and :command:`neteye node system-upgrade` commands, and so
   on.  Moreover, also the time needed to address possible issues with
   customised services or custom Icinga 2 checks during the upgrade is
   not included.

.. rubric:: System, Network, and other requirements

.. include:: /includes/4.23_os_requirements.rst

Procedure Overview
------------------

The procedure will upgrade all nodes from *CentOS 7* to :abbr:`RHEL 8
(RedHat Enterprise Linux)`: each node will be removed from the
existing cluster and added to a new RHEL 8 cluster, which is
automatically created and configured like the previous one.  As soon
the quorum in the CentOS 7 cluster is lost, it will be stopped and the
nodes converted to RHEL 8 will be started, replacing the CentOS
cluster and taking over its duties.  During this transition there will
be a downtime of at least **30 minutes**.

Before starting the Cluster upgrade, the following files are backed up for
security and future reference:

* :file:`/var/lib/pacemaker/cib/cib.xml`
* :file:`/etc/corosync/corosync.conf`

During the creation of the RHEL 8 cluster, the password of the
`hacluster` user, necessary for a node to join the NetEye Cluster, is
saved in :file:`/root/.pwd_hacluster`.

.. _cluster-conv:

Conventions Used
----------------

A NetEye Cluster can be composed by different types of nodes,
including `Elastic-only` and `Voting-only` nodes. The following
notation has been devised, to identify nodes in the Cluster.

* `(ALL)` is the set of **all** Cluster Nodes
* `(NN)` indicates the **NetEye Cluster Nodes**
* `(E)` is an `Elastic-only` node
* `(V)` is a `Voting-only` node

For example if we take the sample NetEye Cluster defined in
:ref:`ne-elected-master`:

.. please leave the \(E) and \(V) as it is otherwise they will be misinterpreted!

* (ALL) is ``my-neteye-01``, ``my-neteye-02``, ``my-neteye-03``,
  ``my-neteye-04``, and ``my-neteye-05``
* (NN) is composed by ``my-neteye-01``, ``my-neteye-02``,
  ``my-neteye-03``, and ``my-neteye-04``
* \(E) is ``my-neteye-05``
* \(V) is ``my-neteye-06``

In the remainder we will refer to the *NetEye Cluster* before the
migration (i.e., the nodes still running NetEye 4.22) as the **CentOS
Cluster**, while the NetEye Cluster after the migration (ie., the
nodes already migrated to NetEye 4.23) will be referred to as **RHEL 8
Cluster**.


.. _cluster-upgrade:

Running the Upgrade
-------------------

To perform the Cluster Upgrade, the following procedure must be
executed and completed on each node **strictly in the following order**:

* (NN) nodes following the order set in :file:`/etc/neteye-cluster`
* \(V) nodes
* \(E) nodes

The procedure for upgrading the node number **(NN + V)/2 + 1** (i.e.,
the node that would cause the CentOS Cluster lose the quorum) is
slightly different and requires the execution of the ``neteye cluster
enable 4.23`` command.

This command stops the CentOS 7 Cluster by putting all its nodes in
standby, then enables the `cluster maintenance mode
<https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_high_availability_clusters/assembly_cluster-maintenance-configuring-and-managing-high-availability-clusters#proc_setting-maintenance-mode-cluster-maintenance>`_,
and finally activates the RHEL 8 Cluster by removing its nodes from
standby and disabling the cluster maintenance mode.

You can proceed with the upgrade only as soon as all resources are
correctly started on the RHEL 8 Cluster.  The status of the resources
can be verified by executing the ``pcs status`` command **on the 1st
node**. At this point you can also ensure that all the NetEye services
and all your custom services and/or custom Icinga 2 checks are working
fine on the RHEL 8 Cluster.

If some resource or other services cannot be correctly started on the
RHEL 8 Cluster (for example a missing library), you have the possibility
to stop the RHEL 8 Cluster and re-enable the CentOS 7 Cluster by executing

.. code:: bash

   cluster# neteye cluster enable 4.22

This command prevents downtimes and allow to fix existing issues on
the RHEL 8 Cluster in the meantime and execute again the command
``neteye cluster enable 4.23`` to activate again the RHEL 8 Cluster.

.. topic:: Example of an Upgrade of a NetEye Cluster with 4 (NN) nodes
           and a (V) node (5 nodes in total):

   #. Run the upgrade of the 1st (NN) node

   #. Run the upgrade of the 2nd (NN) node

   #. Enable the NetEye 4.23 (RHEL 8) Cluster by executing on the 3rd (NN) node:

      .. code:: bash

         cluster# neteye cluster enable 4.23

   #. Run the upgrade of the 3rd (NN) node

   #. Run the upgrade of the 4th (NN) node

   #. Run the upgrade of the 5th (V) node

Step 1: Conversion from CentOS 7 to RHEL 7
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This step is the same for all nodes, **except** for node number
``(NN + V)/2 + 1`` (i.e., the 2nd node on a 3-nodes cluster and the
3rd node on a 5-nodes cluster).

**Only on this node**, execute the following command. On all other
nodes, skip to the next command.

  .. code:: bash

     cluster# neteye cluster enable 4.23

To perform the conversion of the current node to RHEL 7, run:

  .. code:: bash

     cluster# (nohup neteye node system-upgrade --org <organization_id> --key <activation_key> --name <name> &) && tail --retry -f nohup.out

This command is responsible for checking the system status, putting the node
into standby, temporarily stopping the DRBD, and performing the conversion
to **RHEL 7**.
We recall that the *organization ID* and the *activation key* can be obtained upon
request to our service desk.

If it is the first node to be upgraded, then the configurations of the pcs
resources will be exported and used later for their creation on the new RHEL 8 cluster.

At the end of the conversion a success message is shown and you
will be prompted to restart the system.
To reboot the system run::

  cluster# reboot

In case of any errors, the command will show the reason of the
failure. After fixing the problem, please repeat Step 1 from the
beginning.

Step 2: Upgrade from RHEL 7 to RHEL 8
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After the previous reboot, it is time to upgrade from **RHEL 7** to **RHEL 8** by running
command::

  cluster# (nohup neteye node system-upgrade --org <organization_id> --key <activation_key> --name <name> &) && tail --retry -f nohup.out

During the upgrade the following kernel modules will be removed because they are not compatible
with RHEL 8:

* *pata_acpi*: pata_acpi is used for device configuration and power management of P-ATA storage devices
* *pam_pkcs11*: this Linux-PAM login module allows a X.509 certificate based user login

The command will perform a pre-upgrade in order to check the status of the system;
any of the following conditions may prompt a manual intervention:

* A newer kernel version is installed but currently not running: it is necessary
  to reboot the system, then execute the :command:`neteye node system-upgrade` command again
* Some packages not provided by NetEye have been installed and are not compatible with RHEL 8:
  packages that are not compatible with RHEL 8 must be removed or can be updated by
  saving a RHEL 8 compatible update package in the folder :file:`/var/www/html/rhel8-rpms-migration`.
  Alternatively, additional repositories to be used only during the upgrade can be added to file
  :file:`/etc/leapp/files/leapp_upgrade_repositories.repo`.
* Other system-specific cases: in this case a detailed report of the causes will be generated in
  :file:`/var/log/leapp/leapp-report.txt`

In case of any errors, the command will show the reason of the
failure. After fixing the problem, please repeat Step 2 from the
beginning.

During this step the node is removed from the running CentOS 7
cluster.

At the end of the upgrade a success message is shown and you
will be informed to restart the system.
During the reboot further tasks will be performed in order to complete the upgrade to RHEL 8.

.. warning:: The whole reboot procedure will take at least **35-40 minutes**.

To reboot the system run the following command::

  cluster# reboot

Step 3: Upgrade finalization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To complete the procedure and finalize the NetEye upgrade,
run::

  cluster# (nohup neteye node system-upgrade --org <organization_id> --key <activation_key> --name <name> &) && tail --retry -f nohup.out

When the first node is converted, then the RHEL 8 cluster will be
created by configuring the previously exported pcs resources;
otherwise the node will simply be added to the RHEL 8 cluster.
If the RHEL 8 cluster was already enabled, then pcs
will distribute the resources across the RHEL 8 cluster nodes.

.. _cluster-single-purpose-nodes:

Single Purpose Nodes
~~~~~~~~~~~~~~~~~~~~

In the context of the Upgrade procedure, Single Purpose Nodes are
`Voting-only` (V) and `Elastic-only` (E) Nodes. They need to be
upgraded with the same procedure and order (all Voting-only first,
then all Elastic-only nodes) described above.

.. _upgrade-additional-steps-cluster:

Additional Tasks
----------------

In this upgrade, no additional manual step is required.

.. _cluster-reactivation:

Cluster Reactivation
--------------------

When the procedure has been completed also on the last node,
all nodes of the cluster will run a finalized **NetEye 4.23**;
they are **not** in standby, and the operating system will be **RHEL 8**.

Optionally, run the checks in the section :ref:`Checking that the Cluster Status
is Normal <check-cluster-status>`.  If any of the above checks fail,
please call :ref:`our service and support team <neteye-support>`
before proceeding.

The **mandatory task** to execute on the last (NN) node is to
re-enable fencing if it was already enable on the CentOS 7 cluster
before the migration::

    # pcs property set stonith-enabled=true
