diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 6306c133..eff7bfeb 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -148,15 +148,10 @@ jobs: aws_role_arn: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - name: Mark error id: status - if: always() + if: failure() run: | - if [ "${{ steps.e2e.outcome }}" == "success" ] - then - echo "status=success" >> $GITHUB_OUTPUT - else - echo "status=failure" >> $GITHUB_OUTPUT - exit 1 - fi + echo "status=failure" >> $GITHUB_OUTPUT + exit 1 report: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9d0d7a50..11a221ed 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -167,15 +167,10 @@ jobs: - name: Mark error id: status - if: always() + if: failure() run: | - if [ "${{ steps.e2e.outcome }}" == "success" ] - then - echo "status=success" >> $GITHUB_OUTPUT - else - echo "status=failure" >> $GITHUB_OUTPUT - exit 1 - fi + echo "status=failure" >> $GITHUB_OUTPUT + exit 1 report: runs-on: ubuntu-latest diff --git a/pkg/resource/service.go b/pkg/resource/service.go index 6e2ea6b4..cf54502f 100644 --- a/pkg/resource/service.go +++ b/pkg/resource/service.go @@ -183,8 +183,9 @@ func (r *ServiceResource) Schema(_ context.Context, _ resource.SchemaRequest, re Optional: true, }, "num_replicas": schema.Int64Attribute{ - Description: "Number of replicas for the service. Available only for 'production' services. Must be between 3 and 20. Contact support to enable this feature.", Optional: true, + Computed: true, + Description: "Number of replicas for the service. Available only for 'production' services. Must be between 3 and 20. Contact support to enable this feature.", }, "idle_timeout_minutes": schema.Int64Attribute{ Description: "Set minimum idling timeout (in minutes). Must be greater than or equal to 5 minutes. Must be set if idle_scaling is enabled", @@ -344,10 +345,24 @@ func (r *ServiceResource) ModifyPlan(ctx context.Context, req resource.ModifyPla } if plan.Tier.ValueString() == api.TierDevelopment { - if !plan.MinTotalMemoryGb.IsNull() || !plan.MaxTotalMemoryGb.IsNull() || !plan.NumReplicas.IsNull() { + if !plan.MinTotalMemoryGb.IsNull() { + resp.Diagnostics.AddError( + "Invalid Configuration", + "min_total_memory_gb cannot be defined if the service tier is development", + ) + } + + if !plan.MaxTotalMemoryGb.IsNull() { resp.Diagnostics.AddError( "Invalid Configuration", - "min_total_memory_gb, max_total_memory_gb and num_replicas cannot be defined if the service tier is development", + "max_total_memory_gb cannot be defined if the service tier is development", + ) + } + + if !plan.NumReplicas.IsNull() && !plan.NumReplicas.IsUnknown() { + resp.Diagnostics.AddError( + "Invalid Configuration", + "num_replicas cannot be defined if the service tier is development", ) } @@ -506,6 +521,12 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest // behaviour as before. maxReplicaMemoryGb = int(plan.MaxTotalMemoryGb.ValueInt64() / 3) } + if !plan.NumReplicas.IsNull() { + numReplicas := int(plan.NumReplicas.ValueInt64()) + if numReplicas > 0 { + service.NumReplicas = &numReplicas + } + } service.MinReplicaMemoryGb = &minReplicaMemoryGb service.MaxReplicaMemoryGb = &maxReplicaMemoryGb @@ -956,6 +977,8 @@ func (r *ServiceResource) syncServiceState(ctx context.Context, state *models.Se if service.NumReplicas != nil { state.NumReplicas = types.Int64Value(int64(*service.NumReplicas)) } + } else { + state.NumReplicas = types.Int64Null() } {