Skip to content

Commit

Permalink
We no longer need the openshift client in the code because
Browse files Browse the repository at this point in the history
1. For gathering metrics we make a request call and for that we can set the
openshift token an an environment variable.
2. We no longer gather namespace annotations, instead we are getting allocation
attributes from coldfront.
  • Loading branch information
naved001 committed Feb 8, 2024
1 parent b700822 commit dec5827
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 13 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ This was a fork of https://github.com/OCP-on-NERC/xdmod-openshift-scripts

## Usage

In order to run the scripts, you need to run `oc login` or set the following environment variables:
In order to run the scripts, you need to set the following environment variables:

- `OPENSHIFT_TOKEN` for both scripts.
- `OPENSHIFT_API_URL=https://api.shift.nerc.mghpcc.org:6443` for `merge.py`.
- `OPENSHIFT_TOKEN` for `openshift_prometheus_metrics.py` when collecting metrics from thanos/prometheus.
- Keycloak `CLIENT_ID` and `CLIENT_SECRET`, `COLDFRONT_URL` (defaults to MGHPCC coldfront) for `merge.py`.

We are using the token for `xdmod-reader` service account in `xdmod-reader` namespace on nerc-prod cluster. You can extract the token with:
`oc get secrets -n xdmod-reader --as system:admin xdmod-reader-token-m6s2m -o yaml | yq .data.token -r |base64 -d` .

Note that if you are logged in with `oc login` then you don't need to manually set the OPENSHIFT_TOKEN or OPENSHIFT_API_URL.

When running the scripts, there are two methods of specifying the OpenShift Prometheus
endpoint. The first is through an environment variable:

Expand Down
5 changes: 0 additions & 5 deletions openshift_metrics/openshift_prometheus_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import sys
import json

import openshift

import utils


Expand Down Expand Up @@ -73,9 +71,6 @@ def main():

token = os.environ.get("OPENSHIFT_TOKEN")

if token is None:
token = openshift.get_auth_token()

metrics_dict = {}
metrics_dict["start_date"] = report_start_date
metrics_dict["end_date"] = report_end_date
Expand Down
2 changes: 0 additions & 2 deletions openshift_metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import csv
import requests

import openshift


# GPU types
GPU_A100 = "nvidia.com/gpu_A100"
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
requests>=2.18.4
openshift-client==1.0.21

0 comments on commit dec5827

Please sign in to comment.