|
| 1 | +# Overview |
| 2 | + |
| 3 | +With the introduction |
| 4 | +of [KubeVirt Feature Lifecycle](https://github.com/kubevirt/community/blob/main/design-proposals/feature-lifecycle.md) |
| 5 | +policy, features reaching General Availability (GA) need to drop their use of feature gates. This applies also to |
| 6 | +configurable features that we may want to disable. |
| 7 | + |
| 8 | +## Motivation |
| 9 | + |
| 10 | +Users may want certain features to be in a given state, for example to make the best use out of given |
| 11 | +resources or for compliance reasons features may expose sensitive information from the host to the virtual machines |
| 12 | +instances (VMI) or add additional containers to the launcher pod, which are not required by the user. |
| 13 | + |
| 14 | +The downward metrics feature is a good example of why some clusters may want to have it enabled or disabled. |
| 15 | +The downward metrics feature exposes some metrics about the host node where the VMI is running to the guest. This |
| 16 | +information may be considered sensitive information. |
| 17 | +If there is no mechanism to disable the feature any VMI could request the metrics and inspect information that, in some |
| 18 | +cases, the admin would like to hide, creating a potential security issue. |
| 19 | + |
| 20 | +The behavior of other features might be changed by editing configurables, e.g. the maximum of CPU sockets allowed for |
| 21 | +each VMI can be configured. |
| 22 | + |
| 23 | +Before the introduction |
| 24 | +of [KubeVirt Feature Lifecycle](https://github.com/kubevirt/community/blob/main/design-proposals/feature-lifecycle.md) |
| 25 | +policy, many feature gates remained after feature's graduation to GA with the sole purpose of acting as a switch for the |
| 26 | +feature. Generally speaking, this is a bad practice, because feature gates should be reserved for controlling a feature |
| 27 | +until it reaches maturity. i.e., GA. Therefore, in the case that a developer wants to provide the ability to tune/change |
| 28 | +the state of the feature, configurables exposed in the KubeVirt CR should be provided. This should be |
| 29 | +accomplished while achieving [eventually consistency](https://en.wikipedia.org/wiki/Eventual_consistency). This forces |
| 30 | +us to avoid the feature state control checking on webhooks and moving the feature state control closer to the |
| 31 | +responsible code. Moreover, it has to be decided how the system should behave if a VMI is |
| 32 | +requiring a feature in a state different from what was configured in the KubeVirt CR, or what should happen if the |
| 33 | +configuration of a feature in use is changed. (see matrix below). |
| 34 | + |
| 35 | +## Goals |
| 36 | + |
| 37 | +- Establish how the features status swapping should work. |
| 38 | +- Describe how the system should react in these scenarios: |
| 39 | + - A feature in KubeVirt is set to state A and a VMI requests the feature to be in state B. |
| 40 | + - A feature in KubeVirt is set to state A, there are running VMIs using the feature in state A, and the feature is |
| 41 | + changed in KubeVirt to state B. |
| 42 | + - A feature in KubeVirt is set to state A, and pending VMIs want to use it. |
| 43 | + - A feature in KubeVirt is set to state A, and running VMIs using the feature in state B wants to live migrate. |
| 44 | +- Graduate features status swapping from features gates to configurables. |
| 45 | + |
| 46 | +## Non Goals |
| 47 | + |
| 48 | +- Describe how features protected with features gates should work. |
| 49 | + |
| 50 | +## Definition of Users |
| 51 | + |
| 52 | +Development contributors. |
| 53 | + |
| 54 | +Cluster administrators. |
| 55 | + |
| 56 | +## User Stories |
| 57 | + |
| 58 | +* As a cluster administrator, I want to be able to change the cluster-wide state of a feature by editing configurables. |
| 59 | + |
| 60 | +* As VMI owner, I want to use a given feature. |
| 61 | + |
| 62 | +## Repos |
| 63 | + |
| 64 | +Kubevirt/Kubevirt |
| 65 | + |
| 66 | +# Design |
| 67 | + |
| 68 | +In order to make a feature configurable, it must be done by adding new fields to the KubeVirt CR under |
| 69 | +`spec.configuration`. |
| 70 | + |
| 71 | + |
| 72 | +> **NOTE:** The inclusion of these new KubeVirt API fields should be carefully considered and justified. The feature |
| 73 | +> configurables should be avoided as much as possible. |
| 74 | +
|
| 75 | + |
| 76 | +This is current list of GA'd features present in KubeVirt/KubeVirt which are still using feature gates and are shown as |
| 77 | +configurables in [HCO](https://github.com/kubevirt/hyperconverged-cluster-operator/blob/main/controllers/operands/kubevirt.go#L166-L174): |
| 78 | + |
| 79 | +- DownwardMetrics |
| 80 | +- Root (not sure about this one) |
| 81 | +- DisableMDEVConfiguration |
| 82 | +- PersistentReservation |
| 83 | +- AutoResourceLimitsGate |
| 84 | +- AlignCPUs |
| 85 | + |
| 86 | +This is the current list of GA'd features present in KubeVirt/KubeVirt which are still using feature gates and are always |
| 87 | +enabled by [HCO](https://github.com/kubevirt/hyperconverged-cluster-operator/blob/main/controllers/operands/kubevirt.go#L125-L142): |
| 88 | + |
| 89 | +- CPUManager |
| 90 | +- Snapshot |
| 91 | +- HotplugVolumes |
| 92 | +- GPU |
| 93 | +- HostDevices |
| 94 | +- NUMA |
| 95 | +- VMExport |
| 96 | +- DisableCustomSELinuxPolicy |
| 97 | +- KubevirtSeccompProfile |
| 98 | +- HotplugNICs |
| 99 | +- VMPersistentState |
| 100 | +- NetworkBindingPlugins |
| 101 | +- VMLiveUpdateFeatures |
| 102 | + |
| 103 | +Please note that only feature gates included in KubeVirt/KubeVirt are listed here. |
| 104 | + |
| 105 | +## API Examples |
| 106 | +The proposal configuration field, for a given feature in the KubeVirt CR, may look like: |
| 107 | + |
| 108 | +```yaml |
| 109 | +apiVersion: kubevirt.io/v1 |
| 110 | +kind: KubeVirt |
| 111 | +[...] |
| 112 | +spec: |
| 113 | + certificateRotateStrategy: {} |
| 114 | + configuration: |
| 115 | + feature-A: {} |
| 116 | +[...] |
| 117 | +``` |
| 118 | +The VMI object may or may not include a configuration field inside the relevant spec. |
| 119 | + |
| 120 | +## Interactions with the VMIs requests |
| 121 | + |
| 122 | +In case that, the VMI exposes a configuration field to request the feature as well as the KubeVirt CRD, the system may |
| 123 | +encounter some inconsistent states that should be handled in the following way: |
| 124 | + |
| 125 | +- If the feature is set to state A in the KubeVirt CR and the VMI is requesting the feature in state B, the VMIs must |
| 126 | + stay in Pending state. The VMI status should be updated, showing a status message, highlighting the reason(s) for the |
| 127 | + Pending state. |
| 128 | +- Feature status checks should only be performed during the VMI reconciliation process, not at runtime. Therefore, the |
| 129 | + feature status changes in the KubeVirt CR should not affect running VMIs. Moreover, the VMI should still be able to |
| 130 | + live migrate, preserving its original feature state. |
| 131 | +- Optionally, it could enable the possibility to reject the KubeVirt CR change request if running VMIs are using the |
| 132 | + feature in a given state. However, by the default the request should be accepted. |
| 133 | + |
| 134 | +## Scalability |
| 135 | + |
| 136 | +The feature state swapping should not affect in a meaningful way the cluster resource usage. |
| 137 | + |
| 138 | +## Update/Rollback Compatibility |
| 139 | + |
| 140 | +The feature state swapping should not affect forward or backward compatibility once the feature GA. A given feature, |
| 141 | +after 3 releases in Beta, all feature gates must be dropped. Those features that need a configurable should define it ahead |
| 142 | +of time. |
| 143 | + |
| 144 | +## Functional Testing Approach |
| 145 | + |
| 146 | +The unit and functional testing frameworks should cover the relevant scenarios for each feature. |
| 147 | + |
| 148 | +# Implementation Phases |
| 149 | + |
| 150 | +The feature status check should be placed in the VMI reconciliation loop. In this way, the feature status evaluation is |
| 151 | +close to the VMI scheduling process, as well as allowing KubeVirt to reconcile itself if it is out of sync temporally. |
| 152 | + |
| 153 | +Regarding already existing features transitioning from feature gates as a way to set the feature status to configurable |
| 154 | +fields, this change is acceptable, but it should be marked as a breaking change and documented. Moreover, all feature |
| 155 | +gates should be evaluated to determine if they need to be dropped and transitioned to configurables. |
| 156 | + |
| 157 | +## About implementing the checking logic in the VM controller |
| 158 | + |
| 159 | +The checking in the VM controller could be added to let the user know if a VM has requested a feature in a state which |
| 160 | +is different from what it is specified in the KubeVirt CR. The VM will update the VM status, showing a status message |
| 161 | +highlighting the misconfiguration. |
0 commit comments