Applying Hot Fixes with the Patcher (prior to 6.2.4)
This article describes how to apply patches using the Patcher. An example on applying a patch for MI Simple Installation in the web container is provided at the end of the article.
The Patcher is a utility that automatically checks for required patches any time the container is started, moves the files to the correct location, and proceeds with normal operation. Any time the container is restarted, the same checks occur.
The hot fixes are baked into the Docker images of future releases (for example, 6.2.4) and this process is no longer necessary until the next set of new patches needs to be applied, which will later be baked into the next release (6.2.5).
Patcher Overview
The Patcher can be used to apply patches to existing code. For the web service/container, the tool will check for new patches every 60 seconds and apply them automatically. Other services must be manually restarted.
The Patcher is included in all Metric Insights containers, with the exception of MySQL.
Apply a Patch
The procedure of applying patches is the same for Simple Installations and Orchestrated Environments.
1. Access a Container
Access any container, except MySQL:
- Simple Installation and Docker Swarm:
docker exec -it <container name> bash
- Kubernetes:
kubectl exec -n <namespace> -it <pod> -- bash
- OpenShift:
- Single-container pod:
oc exec -it <pod> bash
- Multi-container pod:
oc exec -it <pod> -с <container> bash
- Single-container pod:
2. Access the Service Folder
cd /opt/mi/patch/<service>
Available services:
- web
- seed
- dataprocessor
- monitoring
- data-analyzer
3. Download the Patch File
wget <patch URL>
4. Extract Tar File
tar -zxf <patch file> -C /opt/mi/patch/web/
5. Wait 1 Minute for Patch to Be Applied (or Restart the Container)
- Web container: wait 1 minute for the patch to be applied
- Any other container: restart the container:
- Simple Installation:
exit
docker restart <container ID>
- Orchestrated Environments:
Instructions on restarting a container depend on your deployment type.- Example for Kubernetes:
- List all the pods:
kubectl get pods -n <namespace>
- Delete the launched pod and wait for Kubernetes to restart it:
kubectl delete pod -n <namespace> <pod id>
- List all the pods:
- Example for Kubernetes:
- Simple Installation:
Example of Applying a Patch for Simple Installation in Web Container
1. Access Web Container
Access the web container by executing mi-console
.
2. Check the File that Will Be Patched
The hot fix will patch the file File.php
located in the /opt/mi/iv/engine/Zend/Cache/Backend
directory.
- Access the file's directory:
cd /opt/mi/iv/engine/libs/Zend/Cache/Backend
- List file in a long format:
ls -l File.php
- Note the date and time when the initial file was changed (Dec 22 09:45)
3. Access the Patch Directory
Execute cd /opt/mi/patch/
.
5. Extract Tar File
Execute the tar command: tar -zxf <patch file> -C /opt/mi/patch/web/
.
6. Wait 1 Minute for Patch to Be Applied
The described operations are executed inside the web container that doesn't need to be restarted in order for the patch to be applied.
7. Check the Patched File
We can check whether the file has been changed by viewing the date of its' last change:
- Access the file's directory:
cd /opt/mi/iv/engine/libs/Zend/Cache/Backend
- List file in a long format:
ls -l File.php
- Note the date and time have changed (from Dec 22 09:45 to Mar 10 19:14), which means that the file has been successfully patched