Skip to content

Commit e2be128

Browse files
robo-caphyder
authored andcommitted
fix issue introduced by #909 with new clusters and #873
1 parent 9f96c38 commit e2be128

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

module-cluster.tf

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33

44
# Used to retrieve cluster CA certificate or configure local kube context
55

6-
data "oci_containerengine_clusters" "cluster" {
7-
count = local.cluster_enabled ? 1 : 0
6+
data "oci_containerengine_clusters" "existing_cluster" {
7+
count = var.cluster_id != null ? 1 : 0
88
compartment_id = local.compartment_id
99

1010
state = ["ACTIVE","UPDATING"]
1111
filter {
1212
name = "id"
13-
values = [local.cluster_id]
13+
values = [var.cluster_id]
1414
}
1515
}
1616

1717
data "oci_containerengine_cluster_kube_config" "public" {
18-
count = local.cluster_enabled && length(local.public_endpoint) > 0 ? 1 : 0
18+
count = local.cluster_enabled && local.public_endpoint_available ? 1 : 0
1919

2020
cluster_id = local.cluster_id
2121
endpoint = "PUBLIC_ENDPOINT"
2222
}
2323

2424
data "oci_containerengine_cluster_kube_config" "private" {
25-
count = local.cluster_enabled ? 1 : 0
25+
count = local.cluster_enabled && local.private_endpoint_available ? 1 : 0
2626

2727
cluster_id = local.cluster_id
2828
endpoint = "PRIVATE_ENDPOINT"
@@ -35,10 +35,11 @@ locals {
3535

3636
cluster-context = try(format("context-%s", substr(local.cluster_id, -11, -1)), "")
3737

38-
cluster_endpoints = one(flatten(data.oci_containerengine_clusters.cluster[*].clusters[*].endpoints))
39-
public_endpoint = local.cluster_endpoints != null ? lookup(local.cluster_endpoints, "public_endpoint", "") : ""
40-
kubeconfig_public = var.control_plane_is_public ? try(yamldecode(replace(lookup(one(data.oci_containerengine_cluster_kube_config.public), "content", ""), local.cluster-context, var.cluster_name)), tomap({})) : null
41-
kubeconfig_private = try(yamldecode(replace(lookup(one(data.oci_containerengine_cluster_kube_config.private), "content", ""), local.cluster-context, var.cluster_name)), tomap({}))
38+
existing_cluster_endpoints = coalesce(one(flatten(data.oci_containerengine_clusters.existing_cluster[*].clusters[*].endpoints)), tomap({}))
39+
public_endpoint_available = var.cluster_id != null ? length(lookup(local.existing_cluster_endpoints, "public_endpoint", "")) > 0 : var.control_plane_is_public && var.assign_public_ip_to_control_plane
40+
private_endpoint_available = var.cluster_id != null ? length(lookup(local.existing_cluster_endpoints, "private_endpoint", "")) > 0 : true
41+
kubeconfig_public = var.control_plane_is_public ? try(yamldecode(replace(lookup(one(data.oci_containerengine_cluster_kube_config.public), "content", ""), local.cluster-context, var.cluster_name)), tomap({})) : null
42+
kubeconfig_private = try(yamldecode(replace(lookup(one(data.oci_containerengine_cluster_kube_config.private), "content", ""), local.cluster-context, var.cluster_name)), tomap({}))
4243

4344
kubeconfig_clusters = try(lookup(local.kubeconfig_private, "clusters", []), [])
4445
apiserver_private_host = (var.create_cluster
@@ -143,13 +144,13 @@ output "cluster_id" {
143144

144145
output "cluster_endpoints" {
145146
description = "Endpoints for the OKE cluster"
146-
value = var.create_cluster ? one(module.cluster[*].endpoints) : null
147+
value = var.create_cluster ? one(module.cluster[*].endpoints) : local.existing_cluster_endpoints
147148
}
148149

149150
output "cluster_kubeconfig" {
150151
description = "OKE kubeconfig"
151152
value = var.output_detail ? (
152-
var.control_plane_is_public ? local.kubeconfig_public : local.kubeconfig_private
153+
local.public_endpoint_available ? local.kubeconfig_public : local.kubeconfig_private
153154
) : null
154155
}
155156

modules/extensions/rdma_cni_plugin.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ locals {
99
)
1010
rdma_cni_plugin_manifest_path = join("/", [local.yaml_manifest_path, "rdma-cni-daemonset.yaml"])
1111
rdma_cni_plugin_manifest_status_code = one(data.http.rdma_cni_plugin[*].status_code)
12-
rdma_cni_plugin_manifest_content = sensitive(one(data.http.rdma_cni_plugin[*].response_body))
12+
rdma_cni_plugin_manifest_content = one(data.http.rdma_cni_plugin[*].response_body)
1313
}
1414

1515
data "http" "rdma_cni_plugin" {

0 commit comments

Comments
 (0)