From 4691be41e531d9f8c00ee9b99f24994d0524a259 Mon Sep 17 00:00:00 2001
From: Isaac Chung <69920967+ichung08@users.noreply.github.com>
Date: Tue, 6 Aug 2024 14:16:16 -0700
Subject: [PATCH] Add a new scheduler size to deployment schema (#122)
---
Makefile | 20 +++-
docs/data-sources/cluster.md | 21 ++++
docs/data-sources/clusters.md | 21 ++++
docs/resources/cluster.md | 21 ++++
internal/clients/platform/api.gen.go | 91 +++++++++++----
internal/provider/models/cluster.go | 64 ++++++++++-
internal/provider/resources/common_cluster.go | 4 +-
.../resources/resource_deployment_test.go | 30 ++---
internal/provider/schemas/cluster.go | 104 ++++++++++++++++++
internal/provider/schemas/clusters.go | 11 +-
internal/provider/schemas/deployment.go | 1 +
11 files changed, 334 insertions(+), 54 deletions(-)
diff --git a/Makefile b/Makefile
index 2347bf31..d6776ec9 100644
--- a/Makefile
+++ b/Makefile
@@ -48,8 +48,18 @@ build:
go generate ./...
.PHONY: api_client_gen
-api_client_gen: $(ENVTEST_ASSETS_DIR)
- # Install correct oapi-codegen version if not installed
- @{ $(OAPI_CODEGEN) --version | grep $(DESIRED_OAPI_CODEGEN_VERSION) > /dev/null; } || go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@$(DESIRED_OAPI_CODEGEN_VERSION)
- $(OAPI_CODEGEN) -include-tags=User,Invite,Team,ApiToken -generate=types,client -package=iam "${CORE_IAM_OPENAPI_SPEC}" > ./internal/clients/iam/api.gen.go
- $(OAPI_CODEGEN) -include-tags=Organization,Workspace,Cluster,Options,Deployment,Role -generate=types,client -package=platform "${CORE_PLATFORM_OPENAPI_SPEC}" > ./internal/clients/platform/api.gen.go
+api_client_gen:
+ @echo "Checking oapi-codegen installation..."
+ @if ! command -v oapi-codegen >/dev/null 2>&1; then \
+ echo "oapi-codegen not found. Installing..."; \
+ go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@$(DESIRED_OAPI_CODEGEN_VERSION); \
+ elif ! oapi-codegen --version | grep -q $(DESIRED_OAPI_CODEGEN_VERSION); then \
+ echo "Updating oapi-codegen to desired version..."; \
+ go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@$(DESIRED_OAPI_CODEGEN_VERSION); \
+ else \
+ echo "Correct version of oapi-codegen is already installed."; \
+ fi
+ @echo "Generating IAM API client..."
+ oapi-codegen -include-tags=User,Invite,Team,ApiToken -generate=types,client -package=iam "$(CORE_IAM_OPENAPI_SPEC)" > ./internal/clients/iam/api.gen.go
+ @echo "Generating Platform API client..."
+ oapi-codegen -include-tags=Organization,Workspace,Cluster,Options,Deployment,Role -generate=types,client -package=platform "$(CORE_PLATFORM_OPENAPI_SPEC)" > ./internal/clients/platform/api.gen.go
\ No newline at end of file
diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md
index 9bcb3e40..8381e519 100644
--- a/docs/data-sources/cluster.md
+++ b/docs/data-sources/cluster.md
@@ -30,6 +30,7 @@ data "astro_cluster" "example" {
- `cloud_provider` (String) Cluster cloud provider
- `created_at` (String) Cluster creation timestamp
- `db_instance_type` (String) Cluster database instance type
+- `health_status` (Attributes) Cluster health status (see [below for nested schema](#nestedatt--health_status))
- `is_limited` (Boolean) Whether the cluster is limited
- `metadata` (Attributes) Cluster metadata (see [below for nested schema](#nestedatt--metadata))
- `name` (String) Cluster name
@@ -47,12 +48,32 @@ data "astro_cluster" "example" {
- `vpc_subnet_range` (String) Cluster VPC subnet range
- `workspace_ids` (Set of String) Cluster workspace IDs
+
+### Nested Schema for `health_status`
+
+Read-Only:
+
+- `details` (Attributes Set) Cluster health status details (see [below for nested schema](#nestedatt--health_status--details))
+- `value` (String) Cluster health status value
+
+
+### Nested Schema for `health_status.details`
+
+Read-Only:
+
+- `code` (String) Cluster health status detail code
+- `description` (String) Cluster health status detail description
+- `severity` (String) Cluster health status detail severity
+
+
+
### Nested Schema for `metadata`
Read-Only:
- `external_ips` (Set of String) Cluster external IPs
+- `kube_dns_ip` (String) Cluster kube DNS IP
- `oidc_issuer_url` (String) Cluster OIDC issuer URL
diff --git a/docs/data-sources/clusters.md b/docs/data-sources/clusters.md
index 1a181c23..654ba22e 100644
--- a/docs/data-sources/clusters.md
+++ b/docs/data-sources/clusters.md
@@ -48,6 +48,7 @@ Read-Only:
- `cloud_provider` (String) Cluster cloud provider
- `created_at` (String) Cluster creation timestamp
- `db_instance_type` (String) Cluster database instance type
+- `health_status` (Attributes) Cluster health status (see [below for nested schema](#nestedatt--clusters--health_status))
- `is_limited` (Boolean) Whether the cluster is limited
- `metadata` (Attributes) Cluster metadata (see [below for nested schema](#nestedatt--clusters--metadata))
- `name` (String) Cluster name
@@ -65,12 +66,32 @@ Read-Only:
- `vpc_subnet_range` (String) Cluster VPC subnet range
- `workspace_ids` (Set of String) Cluster workspace IDs
+
+### Nested Schema for `clusters.health_status`
+
+Read-Only:
+
+- `details` (Attributes Set) Cluster health status details (see [below for nested schema](#nestedatt--clusters--health_status--details))
+- `value` (String) Cluster health status value
+
+
+### Nested Schema for `clusters.health_status.details`
+
+Read-Only:
+
+- `code` (String) Cluster health status detail code
+- `description` (String) Cluster health status detail description
+- `severity` (String) Cluster health status detail severity
+
+
+
### Nested Schema for `clusters.metadata`
Read-Only:
- `external_ips` (Set of String) Cluster external IPs
+- `kube_dns_ip` (String) Cluster kube DNS IP
- `oidc_issuer_url` (String) Cluster OIDC issuer URL
diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md
index 4bae4701..4c286805 100644
--- a/docs/resources/cluster.md
+++ b/docs/resources/cluster.md
@@ -89,6 +89,7 @@ resource "astro_cluster" "imported_cluster" {
- `created_at` (String) Cluster creation timestamp
- `db_instance_type` (String) Cluster database instance type
+- `health_status` (Attributes) Cluster health status (see [below for nested schema](#nestedatt--health_status))
- `id` (String) Cluster identifier
- `is_limited` (Boolean) Whether the cluster is limited
- `metadata` (Attributes) Cluster metadata (see [below for nested schema](#nestedatt--metadata))
@@ -108,12 +109,32 @@ Optional:
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
+
+### Nested Schema for `health_status`
+
+Read-Only:
+
+- `details` (Attributes Set) Cluster health status details (see [below for nested schema](#nestedatt--health_status--details))
+- `value` (String) Cluster health status value
+
+
+### Nested Schema for `health_status.details`
+
+Read-Only:
+
+- `code` (String) Cluster health status detail code
+- `description` (String) Cluster health status detail description
+- `severity` (String) Cluster health status detail severity
+
+
+
### Nested Schema for `metadata`
Read-Only:
- `external_ips` (Set of String) Cluster external IPs
+- `kube_dns_ip` (String) Cluster kube DNS IP
- `oidc_issuer_url` (String) Cluster OIDC issuer URL
diff --git a/internal/clients/platform/api.gen.go b/internal/clients/platform/api.gen.go
index 7e4dc2a2..e909f417 100644
--- a/internal/clients/platform/api.gen.go
+++ b/internal/clients/platform/api.gen.go
@@ -36,11 +36,13 @@ const (
// Defines values for ClusterStatus.
const (
- ClusterStatusCREATED ClusterStatus = "CREATED"
- ClusterStatusCREATEFAILED ClusterStatus = "CREATE_FAILED"
- ClusterStatusCREATING ClusterStatus = "CREATING"
- ClusterStatusUPDATEFAILED ClusterStatus = "UPDATE_FAILED"
- ClusterStatusUPDATING ClusterStatus = "UPDATING"
+ ClusterStatusACCESSDENIED ClusterStatus = "ACCESS_DENIED"
+ ClusterStatusCREATED ClusterStatus = "CREATED"
+ ClusterStatusCREATEFAILED ClusterStatus = "CREATE_FAILED"
+ ClusterStatusCREATING ClusterStatus = "CREATING"
+ ClusterStatusUPDATEFAILED ClusterStatus = "UPDATE_FAILED"
+ ClusterStatusUPDATING ClusterStatus = "UPDATING"
+ ClusterStatusUPGRADEPENDING ClusterStatus = "UPGRADE_PENDING"
)
// Defines values for ClusterType.
@@ -49,6 +51,13 @@ const (
ClusterTypeHYBRID ClusterType = "HYBRID"
)
+// Defines values for ClusterHealthStatusValue.
+const (
+ HEALTHY ClusterHealthStatusValue = "HEALTHY"
+ UNHEALTHY ClusterHealthStatusValue = "UNHEALTHY"
+ UNKNOWN ClusterHealthStatusValue = "UNKNOWN"
+)
+
// Defines values for ClusterOptionsProvider.
const (
ClusterOptionsProviderAWS ClusterOptionsProvider = "AWS"
@@ -90,9 +99,10 @@ const (
// Defines values for CreateDedicatedDeploymentRequestSchedulerSize.
const (
- CreateDedicatedDeploymentRequestSchedulerSizeLARGE CreateDedicatedDeploymentRequestSchedulerSize = "LARGE"
- CreateDedicatedDeploymentRequestSchedulerSizeMEDIUM CreateDedicatedDeploymentRequestSchedulerSize = "MEDIUM"
- CreateDedicatedDeploymentRequestSchedulerSizeSMALL CreateDedicatedDeploymentRequestSchedulerSize = "SMALL"
+ CreateDedicatedDeploymentRequestSchedulerSizeEXTRALARGE CreateDedicatedDeploymentRequestSchedulerSize = "EXTRA_LARGE"
+ CreateDedicatedDeploymentRequestSchedulerSizeLARGE CreateDedicatedDeploymentRequestSchedulerSize = "LARGE"
+ CreateDedicatedDeploymentRequestSchedulerSizeMEDIUM CreateDedicatedDeploymentRequestSchedulerSize = "MEDIUM"
+ CreateDedicatedDeploymentRequestSchedulerSizeSMALL CreateDedicatedDeploymentRequestSchedulerSize = "SMALL"
)
// Defines values for CreateDedicatedDeploymentRequestType.
@@ -143,9 +153,10 @@ const (
// Defines values for CreateStandardDeploymentRequestSchedulerSize.
const (
- CreateStandardDeploymentRequestSchedulerSizeLARGE CreateStandardDeploymentRequestSchedulerSize = "LARGE"
- CreateStandardDeploymentRequestSchedulerSizeMEDIUM CreateStandardDeploymentRequestSchedulerSize = "MEDIUM"
- CreateStandardDeploymentRequestSchedulerSizeSMALL CreateStandardDeploymentRequestSchedulerSize = "SMALL"
+ CreateStandardDeploymentRequestSchedulerSizeEXTRALARGE CreateStandardDeploymentRequestSchedulerSize = "EXTRA_LARGE"
+ CreateStandardDeploymentRequestSchedulerSizeLARGE CreateStandardDeploymentRequestSchedulerSize = "LARGE"
+ CreateStandardDeploymentRequestSchedulerSizeMEDIUM CreateStandardDeploymentRequestSchedulerSize = "MEDIUM"
+ CreateStandardDeploymentRequestSchedulerSizeSMALL CreateStandardDeploymentRequestSchedulerSize = "SMALL"
)
// Defines values for CreateStandardDeploymentRequestType.
@@ -170,9 +181,10 @@ const (
// Defines values for DeploymentSchedulerSize.
const (
- DeploymentSchedulerSizeLARGE DeploymentSchedulerSize = "LARGE"
- DeploymentSchedulerSizeMEDIUM DeploymentSchedulerSize = "MEDIUM"
- DeploymentSchedulerSizeSMALL DeploymentSchedulerSize = "SMALL"
+ DeploymentSchedulerSizeEXTRALARGE DeploymentSchedulerSize = "EXTRA_LARGE"
+ DeploymentSchedulerSizeLARGE DeploymentSchedulerSize = "LARGE"
+ DeploymentSchedulerSizeMEDIUM DeploymentSchedulerSize = "MEDIUM"
+ DeploymentSchedulerSizeSMALL DeploymentSchedulerSize = "SMALL"
)
// Defines values for DeploymentStatus.
@@ -244,9 +256,10 @@ const (
// Defines values for SchedulerMachineName.
const (
- SchedulerMachineNameLARGE SchedulerMachineName = "LARGE"
- SchedulerMachineNameMEDIUM SchedulerMachineName = "MEDIUM"
- SchedulerMachineNameSMALL SchedulerMachineName = "SMALL"
+ SchedulerMachineNameEXTRALARGE SchedulerMachineName = "EXTRA_LARGE"
+ SchedulerMachineNameLARGE SchedulerMachineName = "LARGE"
+ SchedulerMachineNameMEDIUM SchedulerMachineName = "MEDIUM"
+ SchedulerMachineNameSMALL SchedulerMachineName = "SMALL"
)
// Defines values for UpdateDedicatedClusterRequestClusterType.
@@ -262,9 +275,10 @@ const (
// Defines values for UpdateDedicatedDeploymentRequestSchedulerSize.
const (
- UpdateDedicatedDeploymentRequestSchedulerSizeLARGE UpdateDedicatedDeploymentRequestSchedulerSize = "LARGE"
- UpdateDedicatedDeploymentRequestSchedulerSizeMEDIUM UpdateDedicatedDeploymentRequestSchedulerSize = "MEDIUM"
- UpdateDedicatedDeploymentRequestSchedulerSizeSMALL UpdateDedicatedDeploymentRequestSchedulerSize = "SMALL"
+ UpdateDedicatedDeploymentRequestSchedulerSizeEXTRALARGE UpdateDedicatedDeploymentRequestSchedulerSize = "EXTRA_LARGE"
+ UpdateDedicatedDeploymentRequestSchedulerSizeLARGE UpdateDedicatedDeploymentRequestSchedulerSize = "LARGE"
+ UpdateDedicatedDeploymentRequestSchedulerSizeMEDIUM UpdateDedicatedDeploymentRequestSchedulerSize = "MEDIUM"
+ UpdateDedicatedDeploymentRequestSchedulerSizeSMALL UpdateDedicatedDeploymentRequestSchedulerSize = "SMALL"
)
// Defines values for UpdateDedicatedDeploymentRequestType.
@@ -300,9 +314,10 @@ const (
// Defines values for UpdateStandardDeploymentRequestSchedulerSize.
const (
- UpdateStandardDeploymentRequestSchedulerSizeLARGE UpdateStandardDeploymentRequestSchedulerSize = "LARGE"
- UpdateStandardDeploymentRequestSchedulerSizeMEDIUM UpdateStandardDeploymentRequestSchedulerSize = "MEDIUM"
- UpdateStandardDeploymentRequestSchedulerSizeSMALL UpdateStandardDeploymentRequestSchedulerSize = "SMALL"
+ UpdateStandardDeploymentRequestSchedulerSizeEXTRALARGE UpdateStandardDeploymentRequestSchedulerSize = "EXTRA_LARGE"
+ UpdateStandardDeploymentRequestSchedulerSizeLARGE UpdateStandardDeploymentRequestSchedulerSize = "LARGE"
+ UpdateStandardDeploymentRequestSchedulerSizeMEDIUM UpdateStandardDeploymentRequestSchedulerSize = "MEDIUM"
+ UpdateStandardDeploymentRequestSchedulerSizeSMALL UpdateStandardDeploymentRequestSchedulerSize = "SMALL"
)
// Defines values for UpdateStandardDeploymentRequestType.
@@ -462,7 +477,8 @@ type Cluster struct {
CreatedAt time.Time `json:"createdAt"`
// DbInstanceType The type of database instance that is used for the cluster.
- DbInstanceType string `json:"dbInstanceType"`
+ DbInstanceType string `json:"dbInstanceType"`
+ HealthStatus *ClusterHealthStatus `json:"healthStatus,omitempty"`
// Id The cluster's ID.
Id string `json:"id"`
@@ -526,6 +542,30 @@ type ClusterStatus string
// ClusterType The type of the cluster.
type ClusterType string
+// ClusterHealthStatus defines model for ClusterHealthStatus.
+type ClusterHealthStatus struct {
+ // Details List of details supporting health assessment.
+ Details *[]ClusterHealthStatusDetail `json:"details,omitempty"`
+
+ // Value Overall health state (HEALTHY or UNHEALTHY).
+ Value ClusterHealthStatusValue `json:"value"`
+}
+
+// ClusterHealthStatusValue Overall health state (HEALTHY or UNHEALTHY).
+type ClusterHealthStatusValue string
+
+// ClusterHealthStatusDetail defines model for ClusterHealthStatusDetail.
+type ClusterHealthStatusDetail struct {
+ // Code The health status for a specific component.
+ Code string `json:"code"`
+
+ // Description A description of the component that was assessed.
+ Description string `json:"description"`
+
+ // Severity The weight this component is given in overall cluster health assessment.
+ Severity string `json:"severity"`
+}
+
// ClusterK8sTag defines model for ClusterK8sTag.
type ClusterK8sTag struct {
// Key The tag's key.
@@ -540,6 +580,9 @@ type ClusterMetadata struct {
// ExternalIPs External IPs of the cluster.
ExternalIPs *[]string `json:"externalIPs,omitempty"`
+ // KubeDnsIp The IP address of the kube-dns service.
+ KubeDnsIp *string `json:"kubeDnsIp,omitempty"`
+
// OidcIssuerUrl OIDC issuer URL for the cluster
OidcIssuerUrl *string `json:"oidcIssuerUrl,omitempty"`
}
diff --git a/internal/provider/models/cluster.go b/internal/provider/models/cluster.go
index 2f020589..c165eb2a 100644
--- a/internal/provider/models/cluster.go
+++ b/internal/provider/models/cluster.go
@@ -18,6 +18,7 @@ type ClusterResource struct {
Name types.String `tfsdk:"name"`
CloudProvider types.String `tfsdk:"cloud_provider"`
DbInstanceType types.String `tfsdk:"db_instance_type"`
+ HealthStatus types.Object `tfsdk:"health_status"`
Region types.String `tfsdk:"region"`
PodSubnetRange types.String `tfsdk:"pod_subnet_range"`
ServicePeeringRange types.String `tfsdk:"service_peering_range"`
@@ -42,6 +43,7 @@ type ClusterDataSource struct {
Name types.String `tfsdk:"name"`
CloudProvider types.String `tfsdk:"cloud_provider"`
DbInstanceType types.String `tfsdk:"db_instance_type"`
+ HealthStatus types.Object `tfsdk:"health_status"`
Region types.String `tfsdk:"region"`
PodSubnetRange types.String `tfsdk:"pod_subnet_range"`
ServicePeeringRange types.String `tfsdk:"service_peering_range"`
@@ -78,20 +80,41 @@ type NodePool struct {
UpdatedAt types.String `tfsdk:"updated_at"`
}
+type ClusterMetadata struct {
+ OidcIssuerUrl types.String `tfsdk:"oidc_issuer_url"`
+ KubeDnsIp types.String `tfsdk:"kube_dns_ip"`
+ ExternalIps types.Set `tfsdk:"external_ips"`
+}
+
+type ClusterHealthStatus struct {
+ Value types.String `tfsdk:"value"`
+ Details types.Set `tfsdk:"details"`
+}
+
+type ClusterHealthStatusDetail struct {
+ Code types.String `tfsdk:"code"`
+ Description types.String `tfsdk:"description"`
+ Severity types.String `tfsdk:"severity"`
+}
+
func (data *ClusterResource) ReadFromResponse(
ctx context.Context,
cluster *platform.Cluster,
) diag.Diagnostics {
+ var diags diag.Diagnostics
data.Id = types.StringValue(cluster.Id)
data.Name = types.StringValue(cluster.Name)
data.CloudProvider = types.StringValue(string(cluster.CloudProvider))
data.DbInstanceType = types.StringValue(cluster.DbInstanceType)
+ data.HealthStatus, diags = ClusterHealthStatusTypesObject(ctx, cluster.HealthStatus)
+ if diags.HasError() {
+ return diags
+ }
data.Region = types.StringValue(cluster.Region)
data.PodSubnetRange = types.StringPointerValue(cluster.PodSubnetRange)
data.ServicePeeringRange = types.StringPointerValue(cluster.ServicePeeringRange)
data.ServiceSubnetRange = types.StringPointerValue(cluster.ServiceSubnetRange)
data.VpcSubnetRange = types.StringValue(cluster.VpcSubnetRange)
- var diags diag.Diagnostics
data.Metadata, diags = ClusterMetadataTypesObject(ctx, cluster.Metadata)
if diags.HasError() {
return diags
@@ -119,16 +142,20 @@ func (data *ClusterDataSource) ReadFromResponse(
ctx context.Context,
cluster *platform.Cluster,
) diag.Diagnostics {
+ var diags diag.Diagnostics
data.Id = types.StringValue(cluster.Id)
data.Name = types.StringValue(cluster.Name)
data.CloudProvider = types.StringValue(string(cluster.CloudProvider))
data.DbInstanceType = types.StringValue(cluster.DbInstanceType)
+ data.HealthStatus, diags = ClusterHealthStatusTypesObject(ctx, cluster.HealthStatus)
+ if diags.HasError() {
+ return diags
+ }
data.Region = types.StringValue(cluster.Region)
data.PodSubnetRange = types.StringPointerValue(cluster.PodSubnetRange)
data.ServicePeeringRange = types.StringPointerValue(cluster.ServicePeeringRange)
data.ServiceSubnetRange = types.StringPointerValue(cluster.ServiceSubnetRange)
data.VpcSubnetRange = types.StringValue(cluster.VpcSubnetRange)
- var diags diag.Diagnostics
data.Metadata, diags = ClusterMetadataTypesObject(ctx, cluster.Metadata)
if diags.HasError() {
return diags
@@ -192,9 +219,16 @@ func NodePoolTypesObject(
return types.ObjectValueFrom(ctx, schemas.NodePoolAttributeTypes(), obj)
}
-type ClusterMetadata struct {
- OidcIssuerUrl types.String `tfsdk:"oidc_issuer_url"`
- ExternalIps types.Set `tfsdk:"external_ips"`
+func ClusterHealthStatusDetailTypesObject(
+ ctx context.Context,
+ healthStatusDetail platform.ClusterHealthStatusDetail,
+) (types.Object, diag.Diagnostics) {
+ obj := ClusterHealthStatusDetail{
+ Code: types.StringValue(healthStatusDetail.Code),
+ Description: types.StringValue(healthStatusDetail.Description),
+ Severity: types.StringValue(healthStatusDetail.Severity),
+ }
+ return types.ObjectValueFrom(ctx, schemas.ClusterHealthStatusDetailAttributeTypes(), obj)
}
func ClusterMetadataTypesObject(
@@ -208,9 +242,29 @@ func ClusterMetadataTypesObject(
}
obj := ClusterMetadata{
OidcIssuerUrl: types.StringPointerValue(metadata.OidcIssuerUrl),
+ KubeDnsIp: types.StringPointerValue(metadata.KubeDnsIp),
ExternalIps: externalIps,
}
return types.ObjectValueFrom(ctx, schemas.ClusterMetadataAttributeTypes(), obj)
}
return types.ObjectNull(schemas.ClusterMetadataAttributeTypes()), nil
}
+
+func ClusterHealthStatusTypesObject(
+ ctx context.Context,
+ healthStatus *platform.ClusterHealthStatus,
+) (types.Object, diag.Diagnostics) {
+ if healthStatus != nil {
+ details, diags := utils.ObjectSet(ctx, healthStatus.Details, schemas.ClusterHealthStatusDetailAttributeTypes(), ClusterHealthStatusDetailTypesObject)
+ if diags.HasError() {
+ return types.ObjectNull(schemas.ClusterHealthStatusAttributeTypes()), diags
+ }
+ obj := ClusterHealthStatus{
+ Value: types.StringValue(string(healthStatus.Value)),
+ Details: details,
+ }
+
+ return types.ObjectValueFrom(ctx, schemas.ClusterHealthStatusAttributeTypes(), obj)
+ }
+ return types.ObjectNull(schemas.ClusterHealthStatusAttributeTypes()), nil
+}
diff --git a/internal/provider/resources/common_cluster.go b/internal/provider/resources/common_cluster.go
index 9e915f3d..e1192d5a 100644
--- a/internal/provider/resources/common_cluster.go
+++ b/internal/provider/resources/common_cluster.go
@@ -36,8 +36,10 @@ func ClusterResourceRefreshFunc(ctx context.Context, platformClient *platform.Cl
return cluster.JSON200, string(cluster.JSON200.Status), nil
case platform.ClusterStatusUPDATEFAILED, platform.ClusterStatusCREATEFAILED:
return cluster.JSON200, string(cluster.JSON200.Status), fmt.Errorf("cluster mutation failed for cluster '%v'", cluster.JSON200.Id)
- case platform.ClusterStatusCREATING, platform.ClusterStatusUPDATING:
+ case platform.ClusterStatusCREATING, platform.ClusterStatusUPDATING, platform.ClusterStatusUPGRADEPENDING:
return cluster.JSON200, string(cluster.JSON200.Status), nil
+ case platform.ClusterStatusACCESSDENIED:
+ return cluster.JSON200, string(cluster.JSON200.Status), fmt.Errorf("access denied for cluster '%v'", cluster.JSON200.Id)
default:
return cluster.JSON200, string(cluster.JSON200.Status), fmt.Errorf("unexpected cluster status '%v' for cluster '%v'", cluster.JSON200.Status, cluster.JSON200.Id)
}
diff --git a/internal/provider/resources/resource_deployment_test.go b/internal/provider/resources/resource_deployment_test.go
index 87797128..3153ebc8 100644
--- a/internal/provider/resources/resource_deployment_test.go
+++ b/internal/provider/resources/resource_deployment_test.go
@@ -138,7 +138,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
Region: "us-east-1",
CloudProvider: "AWS",
Executor: "KUBERNETES",
- SchedulerSize: "SMALL",
+ SchedulerSize: string(platform.SchedulerMachineNameSMALL),
IncludeEnvironmentVariables: true,
}),
Check: resource.ComposeTestCheckFunc(
@@ -148,7 +148,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
resource.TestCheckResourceAttr(awsResourceVar, "cloud_provider", "AWS"),
resource.TestCheckResourceAttr(awsResourceVar, "executor", "KUBERNETES"),
resource.TestCheckNoResourceAttr(awsResourceVar, "worker_queues"),
- resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", "SMALL"),
+ resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", string(platform.SchedulerMachineNameSMALL)),
resource.TestCheckResourceAttrSet(awsResourceVar, "environment_variables.0.key"),
resource.TestCheckResourceAttrSet(awsResourceVar, "environment_variables.1.key"),
// Check via API that deployment exists
@@ -163,12 +163,12 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
Region: "us-east-1",
CloudProvider: "AWS",
Executor: "CELERY",
- SchedulerSize: "MEDIUM",
+ SchedulerSize: string(platform.SchedulerMachineNameEXTRALARGE),
IncludeEnvironmentVariables: false,
}),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(awsResourceVar, "description", utils.TestResourceDescription),
- resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", "MEDIUM"),
+ resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", string(platform.SchedulerMachineNameEXTRALARGE)),
resource.TestCheckResourceAttr(awsResourceVar, "worker_queues.0.name", "default"),
resource.TestCheckNoResourceAttr(awsResourceVar, "environment_variables.0.key"),
resource.TestCheckResourceAttr(awsResourceVar, "executor", "CELERY"),
@@ -184,7 +184,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
Region: "us-east-1",
CloudProvider: "AWS",
Executor: "KUBERNETES",
- SchedulerSize: "MEDIUM",
+ SchedulerSize: string(platform.SchedulerMachineNameMEDIUM),
IncludeEnvironmentVariables: false,
}),
Check: resource.ComposeTestCheckFunc(
@@ -202,12 +202,12 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
Region: "us-east-1",
CloudProvider: "AWS",
Executor: "KUBERNETES",
- SchedulerSize: "SMALL",
+ SchedulerSize: string(platform.SchedulerMachineNameSMALL),
IncludeEnvironmentVariables: false,
IsDevelopmentMode: true,
}),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", "SMALL"),
+ resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", string(platform.SchedulerMachineNameSMALL)),
resource.TestCheckResourceAttr(awsResourceVar, "is_development_mode", "true"),
// Check via API that deployment exists
testAccCheckDeploymentExistence(t, awsDeploymentName, true, true),
@@ -221,12 +221,12 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
Region: "us-east-1",
CloudProvider: "AWS",
Executor: "KUBERNETES",
- SchedulerSize: "SMALL",
+ SchedulerSize: string(platform.SchedulerMachineNameSMALL),
IncludeEnvironmentVariables: true,
IsDevelopmentMode: false,
}),
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", "SMALL"),
+ resource.TestCheckResourceAttr(awsResourceVar, "scheduler_size", string(platform.SchedulerMachineNameSMALL)),
resource.TestCheckResourceAttr(awsResourceVar, "is_development_mode", "false"),
resource.TestCheckResourceAttrSet(awsResourceVar, "environment_variables.0.key"),
resource.TestCheckResourceAttrSet(awsResourceVar, "environment_variables.1.key"),
@@ -260,7 +260,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
Region: "westus2",
CloudProvider: "AZURE",
Executor: "CELERY",
- SchedulerSize: "SMALL",
+ SchedulerSize: string(platform.SchedulerMachineNameSMALL),
IncludeEnvironmentVariables: true,
}),
Check: resource.ComposeTestCheckFunc(
@@ -270,7 +270,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
resource.TestCheckResourceAttr(azureCeleryResourceVar, "cloud_provider", "AZURE"),
resource.TestCheckResourceAttr(azureCeleryResourceVar, "executor", "CELERY"),
resource.TestCheckResourceAttr(azureCeleryResourceVar, "worker_queues.0.name", "default"),
- resource.TestCheckResourceAttr(azureCeleryResourceVar, "scheduler_size", "SMALL"),
+ resource.TestCheckResourceAttr(azureCeleryResourceVar, "scheduler_size", string(platform.SchedulerMachineNameSMALL)),
resource.TestCheckResourceAttrSet(azureCeleryResourceVar, "environment_variables.0.key"),
// Check via API that deployment exists
testAccCheckDeploymentExistence(t, azureCeleryDeploymentName, true, true),
@@ -302,7 +302,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
Region: "us-east4",
CloudProvider: "GCP",
Executor: "KUBERNETES",
- SchedulerSize: "SMALL",
+ SchedulerSize: string(platform.SchedulerMachineNameSMALL),
IncludeEnvironmentVariables: true,
}),
Check: resource.ComposeTestCheckFunc(
@@ -312,7 +312,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) {
resource.TestCheckResourceAttr(gcpKubernetesResourceVar, "cloud_provider", "GCP"),
resource.TestCheckResourceAttr(gcpKubernetesResourceVar, "executor", "KUBERNETES"),
resource.TestCheckResourceAttr(gcpKubernetesResourceVar, "worker_queues.#", "0"),
- resource.TestCheckResourceAttr(gcpKubernetesResourceVar, "scheduler_size", "SMALL"),
+ resource.TestCheckResourceAttr(gcpKubernetesResourceVar, "scheduler_size", string(platform.SchedulerMachineNameSMALL)),
resource.TestCheckResourceAttrSet(gcpKubernetesResourceVar, "environment_variables.0.key"),
// Check via API that deployment exists
testAccCheckDeploymentExistence(t, gcpKubernetesDeploymentName, true, true),
@@ -489,7 +489,7 @@ func TestAcc_ResourceDeploymentStandardRemovedOutsideOfTerraform(t *testing.T) {
CloudProvider: "AWS",
Executor: "KUBERNETES",
IncludeEnvironmentVariables: true,
- SchedulerSize: "SMALL",
+ SchedulerSize: string(platform.SchedulerMachineNameSMALL),
}
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: astronomerprovider.TestAccProtoV6ProviderFactories,
@@ -618,7 +618,7 @@ func developmentDeployment(scalingSpecDeploymentName, scalingSpec string) string
Region: "us-east4",
CloudProvider: "GCP",
Executor: "CELERY",
- SchedulerSize: "SMALL",
+ SchedulerSize: string(platform.SchedulerMachineNameSMALL),
IsDevelopmentMode: true,
ScalingSpec: scalingSpec,
})
diff --git a/internal/provider/schemas/cluster.go b/internal/provider/schemas/cluster.go
index 02bb5409..4e543ab3 100644
--- a/internal/provider/schemas/cluster.go
+++ b/internal/provider/schemas/cluster.go
@@ -50,6 +50,11 @@ func ClusterResourceSchemaAttributes(ctx context.Context) map[string]resourceSch
MarkdownDescription: "Cluster database instance type",
Computed: true,
},
+ "health_status": resourceSchema.SingleNestedAttribute{
+ Attributes: ClusterHealthStatusResourceAttributes(),
+ MarkdownDescription: "Cluster health status",
+ Computed: true,
+ },
"region": resourceSchema.StringAttribute{
MarkdownDescription: "Cluster region - if changed, the cluster will be recreated.",
Required: true,
@@ -183,6 +188,11 @@ func ClusterDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute {
MarkdownDescription: "Cluster database instance type",
Computed: true,
},
+ "health_status": datasourceSchema.SingleNestedAttribute{
+ Attributes: ClusterHealthStatusDataSourceAttributes(),
+ MarkdownDescription: "Cluster health status",
+ Computed: true,
+ },
"region": datasourceSchema.StringAttribute{
MarkdownDescription: "Cluster region",
Computed: true,
@@ -262,6 +272,7 @@ func ClusterDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute {
func ClusterMetadataAttributeTypes() map[string]attr.Type {
return map[string]attr.Type{
"external_ips": types.SetType{ElemType: types.StringType},
+ "kube_dns_ip": types.StringType,
"oidc_issuer_url": types.StringType,
}
}
@@ -273,6 +284,10 @@ func ClusterMetadataDataSourceAttributes() map[string]datasourceSchema.Attribute
MarkdownDescription: "Cluster external IPs",
Computed: true,
},
+ "kube_dns_ip": datasourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster kube DNS IP",
+ Computed: true,
+ },
"oidc_issuer_url": datasourceSchema.StringAttribute{
MarkdownDescription: "Cluster OIDC issuer URL",
Computed: true,
@@ -287,6 +302,10 @@ func ClusterMetadataResourceAttributes() map[string]resourceSchema.Attribute {
MarkdownDescription: "Cluster external IPs",
Computed: true,
},
+ "kube_dns_ip": resourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster kube DNS IP",
+ Computed: true,
+ },
"oidc_issuer_url": resourceSchema.StringAttribute{
MarkdownDescription: "Cluster OIDC issuer URL",
Computed: true,
@@ -422,3 +441,88 @@ func NodePoolDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute
},
}
}
+
+func ClusterHealthStatusAttributeTypes() map[string]attr.Type {
+ return map[string]attr.Type{
+ "value": types.StringType,
+ "details": types.SetType{
+ ElemType: types.ObjectType{
+ AttrTypes: ClusterHealthStatusDetailAttributeTypes(),
+ },
+ },
+ }
+}
+
+func ClusterHealthStatusResourceAttributes() map[string]resourceSchema.Attribute {
+ return map[string]resourceSchema.Attribute{
+ "value": resourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status value",
+ Computed: true,
+ },
+ "details": resourceSchema.SetNestedAttribute{
+ NestedObject: resourceSchema.NestedAttributeObject{
+ Attributes: ClusterHealthStatusDetailResourceAttributes(),
+ },
+ MarkdownDescription: "Cluster health status details",
+ Computed: true,
+ },
+ }
+}
+
+func ClusterHealthStatusDataSourceAttributes() map[string]datasourceSchema.Attribute {
+ return map[string]datasourceSchema.Attribute{
+ "value": datasourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status value",
+ Computed: true,
+ },
+ "details": datasourceSchema.SetNestedAttribute{
+ NestedObject: datasourceSchema.NestedAttributeObject{
+ Attributes: ClusterHealthStatusDetailDataSourceAttributes(),
+ },
+ MarkdownDescription: "Cluster health status details",
+ Computed: true,
+ },
+ }
+}
+
+func ClusterHealthStatusDetailAttributeTypes() map[string]attr.Type {
+ return map[string]attr.Type{
+ "code": types.StringType,
+ "description": types.StringType,
+ "severity": types.StringType,
+ }
+}
+
+func ClusterHealthStatusDetailResourceAttributes() map[string]resourceSchema.Attribute {
+ return map[string]resourceSchema.Attribute{
+ "code": resourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status detail code",
+ Computed: true,
+ },
+ "description": resourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status detail description",
+ Computed: true,
+ },
+ "severity": resourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status detail severity",
+ Computed: true,
+ },
+ }
+}
+
+func ClusterHealthStatusDetailDataSourceAttributes() map[string]datasourceSchema.Attribute {
+ return map[string]datasourceSchema.Attribute{
+ "code": datasourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status detail code",
+ Computed: true,
+ },
+ "description": datasourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status detail description",
+ Computed: true,
+ },
+ "severity": datasourceSchema.StringAttribute{
+ MarkdownDescription: "Cluster health status detail severity",
+ Computed: true,
+ },
+ }
+}
diff --git a/internal/provider/schemas/clusters.go b/internal/provider/schemas/clusters.go
index 95b090f2..eab8f468 100644
--- a/internal/provider/schemas/clusters.go
+++ b/internal/provider/schemas/clusters.go
@@ -12,10 +12,13 @@ import (
func ClustersElementAttributeTypes() map[string]attr.Type {
return map[string]attr.Type{
- "id": types.StringType,
- "name": types.StringType,
- "cloud_provider": types.StringType,
- "db_instance_type": types.StringType,
+ "id": types.StringType,
+ "name": types.StringType,
+ "cloud_provider": types.StringType,
+ "db_instance_type": types.StringType,
+ "health_status": types.ObjectType{
+ AttrTypes: ClusterHealthStatusAttributeTypes(),
+ },
"region": types.StringType,
"pod_subnet_range": types.StringType,
"service_peering_range": types.StringType,
diff --git a/internal/provider/schemas/deployment.go b/internal/provider/schemas/deployment.go
index 8910e586..6315a4a8 100644
--- a/internal/provider/schemas/deployment.go
+++ b/internal/provider/schemas/deployment.go
@@ -247,6 +247,7 @@ func DeploymentResourceSchemaAttributes() map[string]resourceSchema.Attribute {
string(platform.SchedulerMachineNameSMALL),
string(platform.SchedulerMachineNameMEDIUM),
string(platform.SchedulerMachineNameLARGE),
+ string(platform.SchedulerMachineNameEXTRALARGE),
),
},
},