Skip to content

Instantly share code, notes, and snippets.

@dougbtv
Last active February 14, 2024 18:02
Show Gist options
  • Save dougbtv/423d7592d36a1b91c02cf5c688cffbd1 to your computer and use it in GitHub Desktop.
Save dougbtv/423d7592d36a1b91c02cf5c688cffbd1 to your computer and use it in GitHub Desktop.
Whereabouts reconciler cron schedule change + file deletion in OCP 4.12.z

Enable the reconciler...

oc edit networks.operator.openshift.io cluster and add the additionalNetworks section like:

  additionalNetworks:
  - name: whereabouts-shim
    namespace: openshift-multus
    rawCNIConfig: |-
      {
       	"cniVersion": "0.3.0",
        "type": "bridge",
        "bridge": "testcnibr0",
        "ipam": {
          "type": "whereabouts",
          "range": "192.168.1.0/24"
        }
      }
    type: Raw
  clusterNetwork:

Create some sample material...

---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: bridge-conf
spec:
  config: '{
    "cniVersion": "0.3.1",
    "name": "bridge-whereabouts",
    "type": "bridge",
    "bridge": "cni0",
    "mode": "bridge",
    "ipam": {
        "type": "whereabouts",
        "range": "10.10.0.0/16"
    }
}'
---
apiVersion: v1
kind: Pod
metadata:
  name: samplepod-bridge
  annotations:
    k8s.v1.cni.cncf.io/networks: bridge-conf
spec:
  containers:
  - name: samplepod-bridge
    command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
    image: alpine

Then add the config map

kubectl create configmap whereabouts-config -n openshift-multus --from-literal=reconciler_cron_expression='*/5 * * * *'

and you can patch it

oc patch configmap whereabouts-config -n openshift-multus --type merge -p '{"data":{"reconciler_cron_expression":"*/5 * * * *"}}'

Then I oc delete samplepod and I get:

oc get pods | grep recon | awk '{print $1}' | xargs -l1 oc logs
[...]
2024-02-14T17:58:45Z [debug] Used defaults from parsed flat file config @ /host/etc/cni/net.d/whereabouts.d/whereabouts.conf
2024-02-14T17:58:45Z [verbose] result of garbage collecting pods: failed to get the IPPool data: ippool.whereabouts.cni.cncf.io "10.10.0.0-16" not found
2024-02-14T17:58:45Z [error] dropping pod [openshift-multus/samplepod-bridge] deletion out of the queue - could not reconcile IP: failed to get the IPPool data: ippool.whereabouts.cni.cncf.io "10.10.0.0-16" not found
2024-02-14T17:58:45Z [verbose] Event(v1.ObjectReference{Kind:"Pod", Namespace:"openshift-multus", Name:"samplepod-bridge", UID:"a5eedf19-c7e9-4217-becb-22146d503a39", APIVersion:"v1", ResourceVersion:"71048", FieldPath:""}): type: 'Warning' reason: 'IPAddressGarbageCollectionFailed' failed to garbage collect addresses for pod openshift-multus/samplepod-bridge

For

$ oc version | grep Server
Server Version: 4.12.0-0.nightly-2024-02-14-031433
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment