Skip to content

Commit 7e2fe31

Browse files
committed
MGMT-20682: Enable disabling of Console capability
This commit is the first step in expanding support for disabling openshift capabilities in hypershift. Currently, only the ImageRegistry capability can be disabled. This change adds support for disabling the Console capability, who managed by the Cluster Version Operator. Additional capabilities will be supported in future updates.
1 parent e940d2d commit 7e2fe31

File tree

38 files changed

+180
-34
lines changed

38 files changed

+180
-34
lines changed

api/hypershift/v1beta1/hostedcluster_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,13 @@ const (
369369
PruneRetentionPolicy RetentionPolicy = "Prune"
370370
)
371371

372-
// +kubebuilder:validation:Enum=ImageRegistry
372+
// +kubebuilder:validation:Enum=ImageRegistry;Console
373373
type OptionalCapability string
374374

375375
const ImageRegistryCapability OptionalCapability = OptionalCapability(configv1.ClusterVersionCapabilityImageRegistry)
376376

377+
const ConsoleCapability OptionalCapability = OptionalCapability(configv1.ClusterVersionCapabilityConsole)
378+
377379
// capabilities allows disabling optional components at install time.
378380
// Once set, it cannot be changed.
379381
type Capabilities struct {

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/AAA_ungated.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/AutoNodeKarpenter.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ spec:
216216
items:
217217
enum:
218218
- ImageRegistry
219+
- Console
219220
type: string
220221
maxItems: 25
221222
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ClusterVersionOperatorConfiguration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/DynamicResourceAllocation.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDC.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDCWithUIDAndExtraClaimMappings.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ImageStreamImportMode.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/KMSEncryptionProvider.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/NetworkDiagnosticsConfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/OpenStack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ spec:
169169
items:
170170
enum:
171171
- ImageRegistry
172+
- Console
172173
type: string
173174
maxItems: 25
174175
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/AAA_ungated.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/AutoNodeKarpenter.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ spec:
184184
items:
185185
enum:
186186
- ImageRegistry
187+
- Console
187188
type: string
188189
maxItems: 25
189190
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ClusterVersionOperatorConfiguration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/DynamicResourceAllocation.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDC.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDCWithUIDAndExtraClaimMappings.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ImageStreamImportMode.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/KMSEncryptionProvider.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/NetworkDiagnosticsConfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/OpenStack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ spec:
137137
items:
138138
enum:
139139
- ImageRegistry
140+
- Console
140141
type: string
141142
maxItems: 25
142143
type: array

cmd/cluster/core/create.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"io"
88
"os"
9-
"reflect"
109
"sort"
1110
"strconv"
1211
"strings"
@@ -30,6 +29,7 @@ import (
3029
apierrors "k8s.io/apimachinery/pkg/api/errors"
3130
"k8s.io/apimachinery/pkg/api/resource"
3231
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32+
"k8s.io/apimachinery/pkg/util/sets"
3333
"k8s.io/apimachinery/pkg/util/validation"
3434
"k8s.io/apimachinery/pkg/util/wait"
3535
kubeclient "k8s.io/client-go/kubernetes"
@@ -106,7 +106,7 @@ func bindCoreOptions(opts *RawCreateOptions, flags *pflag.FlagSet) {
106106
flags.StringVar(&opts.PausedUntil, "pausedUntil", opts.PausedUntil, "If a date is provided in RFC3339 format, HostedCluster creation is paused until that date. If the boolean true is provided, HostedCluster creation is paused until the field is removed.")
107107
flags.StringVar(&opts.ReleaseStream, "release-stream", opts.ReleaseStream, "The OCP release stream for the cluster (e.g. 4-stable-multi), this flag is ignored if release-image is set")
108108
flags.StringVar(&opts.FeatureSet, "feature-set", opts.FeatureSet, "The predefined feature set to use for the cluster (TechPreviewNoUpgrade or DevPreviewNoUpgrade)")
109-
flags.StringSliceVar(&opts.DisableClusterCapabilities, "disable-cluster-capabilities", nil, "Optional cluster capabilities to disabled. The only currently supported value is ImageRegistry.")
109+
flags.StringSliceVar(&opts.DisableClusterCapabilities, "disable-cluster-capabilities", nil, "Optional cluster capabilities to disabled. The only currently supported values are ImageRegistry,Console")
110110
flags.StringVar(&opts.KubeAPIServerDNSName, "kas-dns-name", opts.KubeAPIServerDNSName, "The custom DNS name for the kube-apiserver service. Make sure the DNS name is valid and addressable.")
111111
}
112112

@@ -693,9 +693,11 @@ func (opts *RawCreateOptions) Validate(ctx context.Context) (*ValidatedCreateOpt
693693
}
694694

695695
if len(opts.DisableClusterCapabilities) > 0 {
696-
acceptedValues := []string{"ImageRegistry"}
697-
if !reflect.DeepEqual(opts.DisableClusterCapabilities, acceptedValues) {
698-
return nil, fmt.Errorf("unknown capability, accepted values are: %v", acceptedValues)
696+
acceptedValues := sets.NewString("ImageRegistry", "Console")
697+
for _, cap := range opts.DisableClusterCapabilities {
698+
if !acceptedValues.Has(cap) {
699+
return nil, fmt.Errorf("unknown capability: %s, accepted values are: %v", cap, acceptedValues.List())
700+
}
699701
}
700702
}
701703

cmd/cluster/core/create_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func TestValidate(t *testing.T) {
204204
Arch: "amd64",
205205
DisableClusterCapabilities: []string{"UnsupportedCapability"},
206206
},
207-
expectedErr: "unknown capability, accepted values are:",
207+
expectedErr: "unknown capability: UnsupportedCapability, accepted values are:",
208208
},
209209
{
210210
name: "passes with ImageRegistry capability",
@@ -217,6 +217,17 @@ func TestValidate(t *testing.T) {
217217
},
218218
expectedErr: "",
219219
},
220+
{
221+
name: "passes with Console capability",
222+
rawOpts: &RawCreateOptions{
223+
Name: "test-hc",
224+
Namespace: "test-hc",
225+
PullSecretFile: pullSecretFile,
226+
Arch: "amd64",
227+
DisableClusterCapabilities: []string{"Console"},
228+
},
229+
expectedErr: "",
230+
},
220231
{
221232
name: "fails with an invalid DNS name as KubeAPIServerDNSName",
222233
rawOpts: &RawCreateOptions{

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedclusters-CustomNoUpgrade.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ spec:
219219
items:
220220
enum:
221221
- ImageRegistry
222+
- Console
222223
type: string
223224
maxItems: 25
224225
type: array

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Default.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ spec:
172172
items:
173173
enum:
174174
- ImageRegistry
175+
- Console
175176
type: string
176177
maxItems: 25
177178
type: array

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedclusters-TechPreviewNoUpgrade.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ spec:
219219
items:
220220
enum:
221221
- ImageRegistry
222+
- Console
222223
type: string
223224
maxItems: 25
224225
type: array

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-CustomNoUpgrade.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ spec:
187187
items:
188188
enum:
189189
- ImageRegistry
190+
- Console
190191
type: string
191192
maxItems: 25
192193
type: array

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Default.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ spec:
140140
items:
141141
enum:
142142
- ImageRegistry
143+
- Console
143144
type: string
144145
maxItems: 25
145146
type: array

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-TechPreviewNoUpgrade.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ spec:
187187
items:
188188
enum:
189189
- ImageRegistry
190+
- Console
190191
type: string
191192
maxItems: 25
192193
type: array

control-plane-operator/controllers/hostedcontrolplane/v2/cvo/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (cvo *clusterVersionOperator) adaptDeployment(cpContext component.WorkloadC
6969
ClusterID: configv1.ClusterID(cpContext.HCP.Spec.ClusterID),
7070
},
7171
}
72-
if !capabilities.IsImageRegistryCapabilityEnabled(cpContext.HCP.Spec.Capabilities) {
72+
if capabilities.HasDisabledCapabilities(cpContext.HCP.Spec.Capabilities) {
7373
cv.Spec.Capabilities = &configv1.ClusterVersionCapabilitiesSpec{
7474
BaselineCapabilitySet: configv1.ClusterVersionCapabilitySetNone,
7575
AdditionalEnabledCapabilities: capabilities.CalculateEnabledCapabilities(cpContext.HCP.Spec.Capabilities),

control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ func (r *reconciler) reconcileClusterVersion(ctx context.Context, hcp *hyperv1.H
12401240
if _, err := r.CreateOrUpdate(ctx, r.client, clusterVersion, func() error {
12411241
clusterVersion.Spec.ClusterID = configv1.ClusterID(hcp.Spec.ClusterID)
12421242
clusterVersion.Spec.Capabilities = nil
1243-
if !capabilities.IsImageRegistryCapabilityEnabled(hcp.Spec.Capabilities) {
1243+
if capabilities.HasDisabledCapabilities(hcp.Spec.Capabilities) {
12441244
clusterVersion.Spec.Capabilities = &configv1.ClusterVersionCapabilitiesSpec{
12451245
BaselineCapabilitySet: configv1.ClusterVersionCapabilitySetNone,
12461246
AdditionalEnabledCapabilities: capabilities.CalculateEnabledCapabilities(hcp.Spec.Capabilities),

control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ func TestReconcileClusterVersionWithDisabledCapabilities(t *testing.T) {
961961
ClusterID: "test-cluster-id",
962962
Capabilities: &hyperv1.Capabilities{
963963
Disabled: []hyperv1.OptionalCapability{
964-
hyperv1.ImageRegistryCapability,
964+
hyperv1.ImageRegistryCapability, hyperv1.ConsoleCapability,
965965
},
966966
},
967967
},
@@ -1015,7 +1015,7 @@ func TestReconcileClusterVersionWithDisabledCapabilities(t *testing.T) {
10151015
configv1.ClusterVersionCapabilityCSISnapshot,
10161016
configv1.ClusterVersionCapabilityCloudControllerManager,
10171017
configv1.ClusterVersionCapabilityCloudCredential,
1018-
configv1.ClusterVersionCapabilityConsole,
1018+
//configv1.ClusterVersionCapabilityConsole,
10191019
configv1.ClusterVersionCapabilityDeploymentConfig,
10201020
// configv1.ClusterVersionCapabilityImageRegistry,
10211021
configv1.ClusterVersionCapabilityIngress,

docs/content/reference/api.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9728,7 +9728,9 @@ ClusterVersionOperatorSpec
97289728
<th>Description</th>
97299729
</tr>
97309730
</thead>
9731-
<tbody><tr><td><p>&#34;ImageRegistry&#34;</p></td>
9731+
<tbody><tr><td><p>&#34;Console&#34;</p></td>
9732+
<td></td>
9733+
</tr><tr><td><p>&#34;ImageRegistry&#34;</p></td>
97329734
<td></td>
97339735
</tr></tbody>
97349736
</table>

support/capabilities/hosted_control_plane_capabilities.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import (
1111
"k8s.io/apimachinery/pkg/util/sets"
1212
)
1313

14+
// HasDisabledCapabilities returns true if any capabilities are disabled; otherwise, it returns false.
15+
func HasDisabledCapabilities(capabilities *hyperv1.Capabilities) bool {
16+
if capabilities == nil {
17+
return false
18+
}
19+
return len(capabilities.Disabled) > 0
20+
}
21+
1422
// IsImageRegistryCapabilityEnabled returns true if the Image Registry
1523
// capability is enabled, or false if disabled.
1624
//

0 commit comments

Comments
 (0)