From 48c1a6cb48454b83c1ade036316df62db94afade Mon Sep 17 00:00:00 2001 From: joschi36 Date: Thu, 24 Apr 2025 17:18:51 +0200 Subject: [PATCH 1/3] first try with implementing no-cni --- provider/clusterrosa/hcp/datasource.go | 4 ++++ provider/clusterrosa/hcp/resource.go | 18 ++++++++++++++++++ provider/clusterrosa/hcp/state.go | 1 + 3 files changed, 23 insertions(+) diff --git a/provider/clusterrosa/hcp/datasource.go b/provider/clusterrosa/hcp/datasource.go index 979b829c..33a427e8 100644 --- a/provider/clusterrosa/hcp/datasource.go +++ b/provider/clusterrosa/hcp/datasource.go @@ -191,6 +191,10 @@ func (r *ClusterRosaHcpDatasource) Schema(ctx context.Context, req datasource.Sc Description: "Length of the prefix of the subnet assigned to each node. " + common.ValueCannotBeChangedStringDescription, Computed: true, }, + "no_cni": schema.BoolAttribute{ + Description: "Disable CNI creation to let users bring their own CNI. " + common.ValueCannotBeChangedStringDescription, + Computed: true, + }, "channel_group": schema.StringAttribute{ Description: deprecatedMessage, Computed: true, diff --git a/provider/clusterrosa/hcp/resource.go b/provider/clusterrosa/hcp/resource.go index 9b721bd2..bea175a4 100644 --- a/provider/clusterrosa/hcp/resource.go +++ b/provider/clusterrosa/hcp/resource.go @@ -287,6 +287,14 @@ func (r *ClusterRosaHcpResource) Schema(ctx context.Context, req resource.Schema int64planmodifier.UseStateForUnknown(), }, }, + "no_cni": schema.BoolAttribute{ + Description: "Disable CNI creation to let users bring their own CNI. " + common.ValueCannotBeChangedStringDescription, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Bool{ + boolplanmodifier.UseStateForUnknown(), + }, + }, "channel_group": schema.StringAttribute{ Description: "Name of the channel group where you select the OpenShift cluster version, for example 'stable'. " + "For ROSA, only 'stable' is supported. " + common.ValueCannotBeChangedStringDescription, @@ -621,6 +629,9 @@ func createHcpClusterObject(ctx context.Context, if common.HasValue(state.HostPrefix) { network.HostPrefix(int(state.HostPrefix.ValueInt64())) } + if common.BoolWithFalseDefault(state.NoCNI) { + network.Type("Other") + } if !network.Empty() { builder.Network(network) } @@ -949,6 +960,7 @@ func validateNoImmutableAttChange(state, plan *ClusterRosaHcpState) diag.Diagnos common.ValidateStateAndPlanEquals(state.ServiceCIDR, plan.ServiceCIDR, "service_cidr", &diags) common.ValidateStateAndPlanEquals(state.PodCIDR, plan.PodCIDR, "pod_cidr", &diags) common.ValidateStateAndPlanEquals(state.HostPrefix, plan.HostPrefix, "host_prefix", &diags) + common.ValidateStateAndPlanEquals(state.NoCNI, plan.Private, "no_cni", &diags) common.ValidateStateAndPlanEquals(state.ChannelGroup, plan.ChannelGroup, "channel_group", &diags) // STS field validations @@ -1603,6 +1615,12 @@ func populateRosaHcpClusterState(ctx context.Context, object *cmv1.Cluster, stat } else { state.HostPrefix = types.Int64Null() } + networkType, ok := object.Network().GetType() + if ok && networkType == "Other" { + state.NoCNI = types.BoolValue(true) + } else { + state.NoCNI = types.BoolNull() + } channel_group, ok := object.Version().GetChannelGroup() if ok { state.ChannelGroup = types.StringValue(channel_group) diff --git a/provider/clusterrosa/hcp/state.go b/provider/clusterrosa/hcp/state.go index b398a47b..5302e076 100644 --- a/provider/clusterrosa/hcp/state.go +++ b/provider/clusterrosa/hcp/state.go @@ -40,6 +40,7 @@ type ClusterRosaHcpState struct { MachineCIDR types.String `tfsdk:"machine_cidr"` ServiceCIDR types.String `tfsdk:"service_cidr"` HostPrefix types.Int64 `tfsdk:"host_prefix"` + NoCNI types.Bool `tfsdk:"no_cni"` Proxy *proxy.Proxy `tfsdk:"proxy"` // Standard machine pools fields From 3ce2f5b7099ddae56cc23604e270515d32d2cff3 Mon Sep 17 00:00:00 2001 From: joschi36 Date: Fri, 25 Apr 2025 11:32:54 +0200 Subject: [PATCH 2/3] fix copy paste mistake --- provider/clusterrosa/hcp/resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/clusterrosa/hcp/resource.go b/provider/clusterrosa/hcp/resource.go index bea175a4..85235559 100644 --- a/provider/clusterrosa/hcp/resource.go +++ b/provider/clusterrosa/hcp/resource.go @@ -960,7 +960,7 @@ func validateNoImmutableAttChange(state, plan *ClusterRosaHcpState) diag.Diagnos common.ValidateStateAndPlanEquals(state.ServiceCIDR, plan.ServiceCIDR, "service_cidr", &diags) common.ValidateStateAndPlanEquals(state.PodCIDR, plan.PodCIDR, "pod_cidr", &diags) common.ValidateStateAndPlanEquals(state.HostPrefix, plan.HostPrefix, "host_prefix", &diags) - common.ValidateStateAndPlanEquals(state.NoCNI, plan.Private, "no_cni", &diags) + common.ValidateStateAndPlanEquals(state.NoCNI, plan.NoCNI, "no_cni", &diags) common.ValidateStateAndPlanEquals(state.ChannelGroup, plan.ChannelGroup, "channel_group", &diags) // STS field validations From 5f22dc06aa966b2ef0e0604292ad247c9c3006ec Mon Sep 17 00:00:00 2001 From: joschi36 Date: Tue, 8 Jul 2025 19:42:56 +0200 Subject: [PATCH 3/3] make generate --- docs/data-sources/cluster_rosa_hcp.md | 1 + docs/resources/cluster_rosa_hcp.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/data-sources/cluster_rosa_hcp.md b/docs/data-sources/cluster_rosa_hcp.md index 57964420..336fce54 100644 --- a/docs/data-sources/cluster_rosa_hcp.md +++ b/docs/data-sources/cluster_rosa_hcp.md @@ -60,6 +60,7 @@ data "rhcs_cluster_rosa_hcp" "cluster" { - `max_hcp_cluster_wait_timeout_in_minutes` (Number) This attribute is not supported for cluster data source. Therefore, it will not be displayed as an output of the datasource - `max_machinepool_wait_timeout_in_minutes` (Number) This attribute is not supported for cluster data source. Therefore, it will not be displayed as an output of the datasource - `name` (String) Name of the cluster. Cannot exceed 54 characters in length. After the creation of the resource, it is not possible to update the attribute value. +- `no_cni` (Boolean) Disable CNI creation to let users bring their own CNI. After the creation of the resource, it is not possible to update the attribute value. - `ocm_properties` (Map of String) Merged properties defined by OCM and the user defined 'properties'. - `pod_cidr` (String) Block of IP addresses for pods. After the creation of the resource, it is not possible to update the attribute value. - `private` (Boolean) Provides private connectivity from your cluster's VPC to Red Hat SRE, without exposing traffic to the public internet. After the creation of the resource, it is not possible to update the attribute value. diff --git a/docs/resources/cluster_rosa_hcp.md b/docs/resources/cluster_rosa_hcp.md index a87507a5..af179180 100644 --- a/docs/resources/cluster_rosa_hcp.md +++ b/docs/resources/cluster_rosa_hcp.md @@ -77,6 +77,7 @@ resource "rhcs_cluster_rosa_hcp" "rosa_sts_cluster" { - `machine_cidr` (String) Block of IP addresses for nodes. After the creation of the resource, it is not possible to update the attribute value. - `max_hcp_cluster_wait_timeout_in_minutes` (Number) This value sets the maximum duration in minutes to wait for a HCP cluster to be in a ready state. - `max_machinepool_wait_timeout_in_minutes` (Number) This value sets the maximum duration in minutes to wait for machine pools to be in a ready state. +- `no_cni` (Boolean) Disable CNI creation to let users bring their own CNI. After the creation of the resource, it is not possible to update the attribute value. - `pod_cidr` (String) Block of IP addresses for pods. After the creation of the resource, it is not possible to update the attribute value. - `private` (Boolean) Provides private connectivity from your cluster's VPC to Red Hat SRE, without exposing traffic to the public internet. After the creation of the resource, it is not possible to update the attribute value. - `properties` (Map of String) User defined properties. It is essential to include property 'role_creator_arn' with the value of the user creating the cluster. Example: properties = {rosa_creator_arn = data.aws_caller_identity.current.arn}