Skip to content

Commit

Permalink
fix: add wait_til support to cloud logs agent submodule (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocofaigh authored Nov 22, 2024
1 parent 496e9e3 commit bbfa716
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,7 @@ module "logs_agent" {
cloud_logs_ingress_endpoint = var.cloud_logs_ingress_endpoint
cloud_logs_ingress_port = var.cloud_logs_ingress_port
is_vpc_cluster = var.is_vpc_cluster
wait_till = var.wait_till
wait_till_timeout = var.wait_till_timeout
}
/** Logs Agent Configuration End **/
2 changes: 2 additions & 0 deletions modules/logs-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ No modules.
| <a name="input_logs_agent_selected_log_source_paths"></a> [logs\_agent\_selected\_log\_source\_paths](#input\_logs\_agent\_selected\_log\_source\_paths) | The list of specific log sources paths. Logs will only be collected from the specified log source paths. If no paths are specified, it will send logs from `/var/log/containers`. | `list(string)` | `[]` | no |
| <a name="input_logs_agent_tolerations"></a> [logs\_agent\_tolerations](#input\_logs\_agent\_tolerations) | List of tolerations to apply to Logs agent. The default value means a pod will run on every node. | <pre>list(object({<br/> key = optional(string)<br/> operator = optional(string)<br/> value = optional(string)<br/> effect = optional(string)<br/> tolerationSeconds = optional(number)<br/> }))</pre> | <pre>[<br/> {<br/> "operator": "Exists"<br/> }<br/>]</pre> | no |
| <a name="input_logs_agent_trusted_profile"></a> [logs\_agent\_trusted\_profile](#input\_logs\_agent\_trusted\_profile) | The IBM Cloud trusted profile ID. Used only when `logs_agent_iam_mode` is set to `TrustedProfile`. The trusted profile must have an IBM Cloud Logs `Sender` role. | `string` | `null` | no |
| <a name="input_wait_till"></a> [wait\_till](#input\_wait\_till) | To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` and `Normal` | `string` | `"Normal"` | no |
| <a name="input_wait_till_timeout"></a> [wait\_till\_timeout](#input\_wait\_till\_timeout) | Timeout for wait\_till in minutes. | `number` | `90` | no |

### Outputs

Expand Down
6 changes: 5 additions & 1 deletion modules/logs-agent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ data "ibm_container_vpc_cluster" "cluster" {
count = var.is_vpc_cluster ? 1 : 0
name = var.cluster_id
resource_group_id = var.cluster_resource_group_id
wait_till = var.wait_till
wait_till_timeout = var.wait_till_timeout
}

data "ibm_container_cluster" "cluster" {
count = var.is_vpc_cluster ? 0 : 1
name = var.cluster_id
resource_group_id = var.cluster_resource_group_id
wait_till = var.wait_till
wait_till_timeout = var.wait_till_timeout
}

# Download cluster config which is required to connect to cluster
data "ibm_container_cluster_config" "cluster_config" {
cluster_name_id = var.cluster_id
cluster_name_id = var.is_vpc_cluster ? data.ibm_container_vpc_cluster.cluster[0].name : data.ibm_container_cluster.cluster[0].name
resource_group_id = var.cluster_resource_group_id
config_dir = "${path.module}/kubeconfig"
endpoint_type = var.cluster_config_endpoint_type != "default" ? var.cluster_config_endpoint_type : null # null value represents default
Expand Down
22 changes: 22 additions & 0 deletions modules/logs-agent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ variable "is_vpc_cluster" {
default = true
}

variable "wait_till" {
description = "To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` and `Normal`"
type = string
default = "Normal"

validation {
error_message = "`wait_till` value must be one of `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` or `Normal`."
condition = contains([
"MasterNodeReady",
"OneWorkerNodeReady",
"IngressReady",
"Normal"
], var.wait_till)
}
}

variable "wait_till_timeout" {
description = "Timeout for wait_till in minutes."
type = number
default = 90
}

##############################################################################
# Logs Agents variables
##############################################################################
Expand Down

0 comments on commit bbfa716

Please sign in to comment.