insights-client is a wrapper for Insights Core (the egg).
Follow these instructions to prepare your system for development.
-
Fork both this and insights-core repository.
-
Clone both of them to the same directory:
$ git clone [email protected]:$YOU/insights-client.git $ git clone [email protected]:$YOU/insights-core.git
-
Make sure your virtual environment uses system site packages.
- For existing one, set
include-system-site-packages = truein virtual environment'spyvenv.cfg. - For new one, create it with
--system-site-packagesflag. - Make sure both repositories share the virtual environment.
- For existing one, set
-
Install the
insights-coreas a Python package.First, make sure the following directories and files exist, otherwise the code will scream at you:
$ sudo mkdir -p /etc/insights-client $ sudo ln -s `pwd`/data/redhattools.pub.gpg /etc/insights-client/ $ sudo ln -s `pwd`/data/cert-api.access.redhat.com.pem /etc/insights-client/
Then you can install the package using pip:
$ cd insights-client $ python3 -m pip install --upgrade pip wheel $ python3 -m pip install -e ../insights-core/.[client-develop] -
Run the client.
$ sudo PYTHONPATH=./src:../insights-core python3 src/insights_client/__init__.py --help
- Every relevant change should have a test, if possible.
- Every commit containing Python code should be formatted with
black. - Every commit/PR will be checked for those in CI.
- Read TESTING.md for more information.
insights-client product consists of two parts: insights-client (wrapper) and insights-core. Historically, the Core (also named the Egg) has been distributed through CDN, with an older, frozen version packaged within insights-client itself. Later, the Core delivery model was changed to be RPM as well.
Wrapper is the entry point providing CLI on $PATH, and ensures phases are run.
Egg is a bundle that contains the insights package with all the main functionality. All flags and configurations are passed to the egg by the wrapper.
insights-client runs in four phases.
- pre-update: Execute flags that exit immediately (
--version,--test-connection,--checkin). - update: Download new Core from CDN. This phase is not used anymore.
- post-update: Process flags (like registration options), and exit if the operation requires registration and the system is not registered.
- collect & upload: Run data collection, compress the results and upload them to ConsoleDot.
The configuration uses the values in the following hierarchy:
- CLI flags
/etc/insights-client/insights-client.conf- environment variables (in a form of
INSIGHTS_xxxxxx, wherexxxxxxis the configuration variable name, in all caps)
The client utilizes several directories on the system for its operation:
/etc/insights-client/- The primary directory for configuration. It containsinsights-client.conf, redaction files (file-redaction.yaml,file-content-redaction.yaml), and security certificates./var/log/insights-client/- The default directory for log files./var/lib/insights/- Stores information about the core module (egg), includinglast_stable.egg./var/cache/insights-client/- The default location where the archive is stored when the--keep-archive,--no-uploadand--offlineflag is used./var/tmp/- Used as a temporary location for building the archive before upload.
The developer logs its activity to provide a record of its operations, which is essential for troubleshooting. All of the following switches were already explained in the Configuration section.
By default, all log output is sent to /var/log/insights-client/insights-client.log.
The level of detail in the logs can be controlled.
- The
--verboseflag increases the verbosity toDEBUGlevel for a single run. (More logs) - The
--quietflag decreases verbosity to only showERRORmessages.
When you run insights-client, it connects to several Red Hat services. Connectivity to these services is required for a standard, non-offline execution.
This are the primary services the client communicates with.
Purpose: To upload the collected system data archive, download updated insights-core, and retrieve analysis results. It can also optionally connect to services for Compliance and Malware detection.
Hostnames: The default hostname is cert-api.access.redhat.com. For newer infrastructure, cert.cloud.redhat.com is also used.
If the system is registered to RHSM, the insights-client may reconfigure itself to use Satellite hostname.
If registered to a Red Hat Satellite server: The client will automatically reconfigure itself. It uses the Satellite's hostname as the destination for data uploads.
If not registered to a Satellite server: The client operates in its default mode. It connects directly to the primary Red Hat Insights API, which is the standard behavior for systems registered with Red Hat.
This entire auto-detection process is based on reading local config files only (managed by RHSM).
examples what you could see in logs if auto_config=True:
DEBUG insights.client.auto_config:159 Connected to staging RHSM, using cert.cloud.stage.redhat.com
DEBUG insights.client.auto_config:81 Not connected to Satellite, skipping branch_info