Commit 7c45eb0
dataplane: Make MachineConfig CRD dependency optional
Problem:
When deploying the openstack-operator on clusters where the OpenShift
Machine Config Operator (MCO) is not installed, the
openstackdataplanenodeset controller fails to start with the error:
ERROR setup problem running manager {"error": "failed to wait for
openstackdataplanenodeset caches to sync: timed out waiting for cache
to be synced for Kind *v1.MachineConfig"}
This occurs because the controller unconditionally sets up a watch for
MachineConfig resources in SetupWithManager(). When the MachineConfig
CRD doesn't exist (e.g., on non-OpenShift Kubernetes clusters or
clusters without MCO), the informer cache sync times out and the
controller fails to start.
Similarly, the disconnected environment detection code
(IsDisconnectedOCP) would fail if ImageContentSourcePolicy or
ImageDigestMirrorSet CRDs don't exist.
Solution:
Implement conditional/dynamic CRD watching for MachineConfig:
1. Remove the MachineConfig watch from SetupWithManager() so the
controller can start without the CRD being present
2. Add ensureMachineConfigWatch() function that:
- Checks if the MachineConfig CRD exists by querying
apiextensions.k8s.io/v1/CustomResourceDefinition
- Dynamically adds the watch using Controller.Watch() if the CRD
exists
- Tracks watched resources to avoid duplicate watch registration
- Logs an informational message if the CRD is not available
3. Call ensureMachineConfigWatch() at the start of each reconciliation
to attempt setting up the watch when the CRD becomes available
4. Update IsDisconnectedOCP() to handle missing ICSP/IDMS CRDs
gracefully instead of returning an error
5. Update inventory generation error handling to distinguish between:
- IsNoMatchError (CRD not installed): Log warning and continue.
This is expected on non-OpenShift clusters or clusters without MCO.
- IsNotFound (CRD exists but resource missing): Return error.
If MCO is installed and a disconnected environment is detected,
the registry MachineConfig should exist. Missing resource indicates
misconfiguration.
This allows the operator to:
- Start successfully even without the MachineConfig CRD
- Work on non-OpenShift Kubernetes clusters
- Gracefully degrade disconnected environment support
- Automatically enable MachineConfig watching if the CRD becomes
available later
- Report actual misconfigurations when MCO is present but registry
MachineConfig is missing
The MachineConfig watch is used for disconnected/mirrored environments
to detect changes to the 99-master-generated-registries MachineConfig
and propagate registry configuration to dataplane nodes. This feature
is now optional rather than required.
Manual registry configuration without MCO:
If the MachineConfig CRD is not available but you need to configure
container registries on dataplane nodes, you can set the ansible
variables directly in the OpenStackDataPlaneNodeSet spec:
spec:
nodeTemplate:
ansible:
ansibleVars:
edpm_podman_disconnected_ocp: true
edpm_podman_registries_conf: |
unqualified-search-registries = ["registry.access.redhat.com"]
[[registry]]
prefix = ""
location = "quay.io/openstack-k8s-operators"
[[registry.mirror]]
location = "my-registry.example.com/openstack-k8s-operators"
Fixes: cache sync timeout when MachineConfig CRD is not installed
Related: OSPRH-24026
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Martin Schuppert <mschuppert@redhat.com>1 parent 42a817d commit 7c45eb0
3 files changed
Lines changed: 145 additions & 20 deletions
File tree
- internal
- controller/dataplane
- dataplane
- util
Lines changed: 93 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
71 | | - | |
72 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
| |||
141 | 149 | | |
142 | 150 | | |
143 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
144 | 156 | | |
145 | 157 | | |
146 | 158 | | |
| |||
669 | 681 | | |
670 | 682 | | |
671 | 683 | | |
672 | | - | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
673 | 690 | | |
674 | 691 | | |
675 | 692 | | |
| |||
692 | 709 | | |
693 | 710 | | |
694 | 711 | | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
699 | 721 | | |
700 | 722 | | |
701 | 723 | | |
| |||
734 | 756 | | |
735 | 757 | | |
736 | 758 | | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
737 | 823 | | |
738 | 824 | | |
739 | 825 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
150 | 164 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
154 | 169 | | |
155 | 170 | | |
156 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
| 62 | + | |
52 | 63 | | |
53 | 64 | | |
54 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
55 | 73 | | |
56 | 74 | | |
57 | | - | |
58 | | - | |
| 75 | + | |
| 76 | + | |
59 | 77 | | |
60 | 78 | | |
61 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
62 | 86 | | |
63 | 87 | | |
64 | 88 | | |
| |||
0 commit comments