// Module included in the following assemblies:
//
// *scalability_and_performance/cnf-numa-aware-scheduling.adoc

:_module-type: PROCEDURE
[id="cnf-reporting-more-exact-resource-availability_{context}"]
= Reporting more exact resource availability

Enable the `cacheResyncPeriod` specification to help the NUMA Resources Operator report more exact resource availability by monitoring pending resources on nodes and synchronizing this information in the scheduler cache at a defined interval. This also helps to minimize Topology Affinity Error errors because of sub-optimal scheduling decisions. The lower the interval, the greater the network load. The `cacheResyncPeriod` specification is disabled by default.

.Prerequisites

* Install the OpenShift CLI (`oc`).
* Log in as a user with `cluster-admin` privileges.

.Procedure

. Delete the currently running `NUMAResourcesScheduler` resource:

.. Get the active `NUMAResourcesScheduler` by running the following command:
+
[source,terminal]
----
$ oc get NUMAResourcesScheduler
----
+
.Example output
[source,terminal]
----
NAME                     AGE
numaresourcesscheduler   92m
----

.. Delete the secondary scheduler resource by running the following command:
+
[source,terminal]
----
$ oc delete NUMAResourcesScheduler numaresourcesscheduler
----
+
.Example output
[source,terminal]
----
numaresourcesscheduler.nodetopology.openshift.io "numaresourcesscheduler" deleted
----

. Save the following YAML in the file `nro-scheduler-cacheresync.yaml`. This example changes the log level to `Debug`:
+
[source,yaml,subs="attributes+"]
----
apiVersion: nodetopology.openshift.io/v1
kind: NUMAResourcesScheduler
metadata:
  name: numaresourcesscheduler
spec:
  imageSpec: "registry.redhat.io/openshift4/noderesourcetopology-scheduler-container-rhel8:v{product-version}"
  cacheResyncPeriod: "5s" <1>
----
+
<1> Enter an interval value in seconds for synchronization of the scheduler cache. A value of `5s` is typical for most implementations.

. Create the updated `NUMAResourcesScheduler` resource by running the following command:
+
[source,terminal]
----
$ oc create -f nro-scheduler-cacheresync.yaml
----
+
.Example output
[source,terminal]
----
numaresourcesscheduler.nodetopology.openshift.io/numaresourcesscheduler created
----

.Verification steps

. Check that the NUMA-aware scheduler was successfully deployed:

.. Run the following command to check that the CRD is created successfully:
+
[source,terminal]
----
$ oc get crd | grep numaresourcesschedulers
----
+
.Example output
[source,terminal]
----
NAME                                                              CREATED AT
numaresourcesschedulers.nodetopology.openshift.io                 2022-02-25T11:57:03Z
----

.. Check that the new custom scheduler is available by running the following command:
+
[source,terminal]
----
$ oc get numaresourcesschedulers.nodetopology.openshift.io
----
+
.Example output
[source,terminal]
----
NAME                     AGE
numaresourcesscheduler   3h26m
----

. Check that the logs for the scheduler show the increased log level:

.. Get the list of pods running in the `openshift-numaresources` namespace by running the following command:
+
[source,terminal]
----
$ oc get pods -n openshift-numaresources
----
+
.Example output
[source,terminal]
----
NAME                                               READY   STATUS    RESTARTS   AGE
numaresources-controller-manager-d87d79587-76mrm   1/1     Running   0          46h
numaresourcesoperator-worker-5wm2k                 2/2     Running   0          45h
numaresourcesoperator-worker-pb75c                 2/2     Running   0          45h
secondary-scheduler-7976c4d466-qm4sc               1/1     Running   0          21m
----

.. Get the logs for the secondary scheduler pod by running the following command:
+
[source,terminal]
----
$ oc logs secondary-scheduler-7976c4d466-qm4sc -n openshift-numaresources
----
+
.Example output
[source,terminal]
----
...
I0223 11:04:55.614788       1 reflector.go:535] k8s.io/client-go/informers/factory.go:134: Watch close - *v1.Namespace total 11 items received
I0223 11:04:56.609114       1 reflector.go:535] k8s.io/client-go/informers/factory.go:134: Watch close - *v1.ReplicationController total 10 items received
I0223 11:05:22.626818       1 reflector.go:535] k8s.io/client-go/informers/factory.go:134: Watch close - *v1.StorageClass total 7 items received
I0223 11:05:31.610356       1 reflector.go:535] k8s.io/client-go/informers/factory.go:134: Watch close - *v1.PodDisruptionBudget total 7 items received
I0223 11:05:31.713032       1 eventhandlers.go:186] "Add event for scheduled pod" pod="openshift-marketplace/certified-operators-thtvq"
I0223 11:05:53.461016       1 eventhandlers.go:244] "Delete event for scheduled pod" pod="openshift-marketplace/certified-operators-thtvq"
----
