---
# System prepended metadata

title: CYG mcp fix

---

# CYG mcp fix

還原問題

1. oc apply -f mcp.yaml
```
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigPool
metadata:
  name: worker-1
spec:
  machineConfigSelector:
    matchExpressions:
      - {key: machineconfiguration.openshift.io/role, operator: In, values: [worker]}
  nodeSelector:
    matchLabels:
      node-role.kubernetes.io/worker: ""
```

2. oc get mcp

原本的worker變成0了
![image](https://hackmd.io/_uploads/SJsL2qSAa.png)
worker全部跑到worker-1 mcp底下


```
[quickcluster@upi-0 ~]$ oc describe node worker-0.cubtest.lab.psi.pnq2.redhat.com | grep config
                    k8s.ovn.org/l3-gateway-config:
                    machineconfiguration.openshift.io/controlPlaneTopology: HighlyAvailable
                    machineconfiguration.openshift.io/currentConfig: rendered-worker-1-d8f922efa63a7cf59a9fabb0f72846c9
                    machineconfiguration.openshift.io/desiredConfig: rendered-worker-1-d8f922efa63a7cf59a9fabb0f72846c9
                    machineconfiguration.openshift.io/desiredDrain: uncordon-rendered-worker-1-d8f922efa63a7cf59a9fabb0f72846c9
                    machineconfiguration.openshift.io/lastAppliedDrain: uncordon-rendered-worker-1-d8f922efa63a7cf59a9fabb0f72846c9
                    machineconfiguration.openshift.io/lastSyncedControllerConfigResourceVersion: 30350
```

# 修復

0. 修改mcp/worker-1內的selector 解除針對worker的監控

![image](https://hackmd.io/_uploads/BywFa5HRa.png)

調整完後mcp/worker-1配對到的worker node變成0
(原本的worker mcp仍舊是0)

![image](https://hackmd.io/_uploads/By_3a5r06.png)


1. 確認目前mcp/worker的config

```
[quickcluster@upi-0 ~]$ oc get mcp worker
NAME     CONFIG                                             UPDATED   UPDATING   DEGRADED   MACHINECOUNT   READYMACHINECOUNT   UPDATEDMACHINECOUNT   DEGRADEDMACHINECOUNT   AGE
worker   rendered-worker-d8f922efa63a7cf59a9fabb0f72846c9   True      False      False      0              0                   0                     0                      109m
```
期望的config為`rendered-worker-d8f922efa63a7cf59a9fabb0f72846c9`

2. 調整worker node內的annotation

```
machineconfiguration.openshift.io/currentConfig: rendered-worker-d8f922efa63a7cf59a9fabb0f72846c9
machineconfiguration.openshift.io/desiredConfig: rendered-worker-d8f922efa63a7cf59a9fabb0f72846c9
machineconfiguration.openshift.io/reason: ""
machineconfiguration.openshift.io/state: Done
```

或是用patch 搭配loop指令，一次執行所有worker節點
```
for node in $(oc get nodes -o name | grep worker);
do
  oc patch $node -p '{"metadata":{"annotations":{"machineconfiguration.openshift.io/currentConfig":"rendered-worker-d8f922efa63a7cf59a9fabb0f72846c9", "machineconfiguration.openshift.io/desiredConfig":"rendered-worker-d8f922efa63a7cf59a9fabb0f72846c9", "machineconfiguration.openshift.io/reason":"", "machineconfiguration.openshift.io/state":"Done"}}}'
done
```

![image](https://hackmd.io/_uploads/ryMmRcB0p.png)


完成修復
![image](https://hackmd.io/_uploads/HyqNAcHRT.png)


最後移除mcp/worker-1
oc delete mcp worker-1
![image](https://hackmd.io/_uploads/Bki8RcHR6.png)
