Skip to content

Commit 0a25482

Browse files
authored
Merge branch 'master' into redis/allow_2_nodes_in_cluster_size
2 parents 3939ee8 + 36a1f88 commit 0a25482

File tree

9 files changed

+1249
-2155
lines changed

9 files changed

+1249
-2155
lines changed

docs/resources/cockpit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ page_title: "Scaleway: scaleway_cockpit"
99
As of September 2024, Cockpit has introduced [regionalization](https://www.scaleway.com/en/docs/observability/cockpit/concepts/#region) to offer more flexibility and resilience.
1010
If you have created customized dashboards with data for your Scaleway resources before April 2024, you will need to update your queries in Grafana, with the new regionalized [data sources](../resources/cockpit_source.md).
1111

12+
-> **Note:**
13+
Cockpit plans scheduled for deprecation on January 1st 2025.
14+
The retention period previously set for your logs and metrics will remain the same after that date.
15+
You will be able to edit the retention period for your metrics, logs, and traces for free during Beta.
16+
1217
Please note that even if you provide the grafana_url, it will only be active if a [Grafana user](../resources/cockpit_grafana_user.md) is created first. Make sure to create a Grafana user in your Cockpit instance to enable full access to Grafana.
1318

1419
The `scaleway_cockpit` resource allows you to create and manage Scaleway Cockpit instances.

docs/resources/instance_server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ To retrieve more information by label please use: ```scw marketplace image get l
213213
- `size_in_gb` - (Required) Size of the root volume in gigabytes.
214214
To find the right size use [this endpoint](https://www.scaleway.com/en/developers/api/instance/#path-instances-list-all-instances) and
215215
check the `volumes_constraint.{min|max}_size` (in bytes) for your `commercial_type`.
216-
Updates to this field will recreate a new resource.
216+
Depending on `volume_type`, updates to this field may recreate a new resource.
217217
- `volume_type` - (Optional) Volume type of root volume, can be `b_ssd`, `l_ssd` or `sbs_volume`, default value depends on server type
218218
- `delete_on_termination` - (Defaults to `true`) Forces deletion of the root volume on instance termination.
219219
- `sbs_iops` - (Optional) Choose IOPS of your sbs volume, has to be used with `sbs_volume` for root volume type.

internal/services/cockpit/cockpit.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func ResourceCockpitCreate(ctx context.Context, d *schema.ResourceData, m interf
103103
if targetPlanI, ok := d.GetOk("plan"); ok {
104104
targetPlan := targetPlanI.(string)
105105

106-
plans, err := api.ListPlans(&cockpit.GlobalAPIListPlansRequest{}, scw.WithContext(ctx), scw.WithAllPages())
106+
plans, err := api.ListPlans(&cockpit.GlobalAPIListPlansRequest{}, scw.WithContext(ctx), scw.WithAllPages()) //nolint:staticcheck
107107
if err != nil {
108108
return diag.FromErr(err)
109109
}
@@ -120,7 +120,7 @@ func ResourceCockpitCreate(ctx context.Context, d *schema.ResourceData, m interf
120120
return diag.Errorf("plan %s not found", targetPlan)
121121
}
122122

123-
_, err = api.SelectPlan(&cockpit.GlobalAPISelectPlanRequest{
123+
_, err = api.SelectPlan(&cockpit.GlobalAPISelectPlanRequest{ //nolint:staticcheck
124124
ProjectID: projectID,
125125
PlanName: cockpit.PlanName(planName),
126126
}, scw.WithContext(ctx))
@@ -150,8 +150,7 @@ func ResourceCockpitRead(ctx context.Context, d *schema.ResourceData, m interfac
150150
return diag.FromErr(err)
151151
}
152152
}
153-
154-
res, err := api.GetCurrentPlan(&cockpit.GlobalAPIGetCurrentPlanRequest{
153+
res, err := api.GetCurrentPlan(&cockpit.GlobalAPIGetCurrentPlanRequest{ //nolint:staticcheck
155154
ProjectID: projectID,
156155
}, scw.WithContext(ctx))
157156
if err != nil {
@@ -214,7 +213,7 @@ func ResourceCockpitUpdate(ctx context.Context, d *schema.ResourceData, m interf
214213
targetPlan = targetPlanI.(string)
215214
}
216215

217-
plans, err := api.ListPlans(&cockpit.GlobalAPIListPlansRequest{}, scw.WithContext(ctx), scw.WithAllPages())
216+
plans, err := api.ListPlans(&cockpit.GlobalAPIListPlansRequest{}, scw.WithContext(ctx), scw.WithAllPages()) //nolint:staticcheck
218217
if err != nil {
219218
return diag.FromErr(err)
220219
}
@@ -231,7 +230,7 @@ func ResourceCockpitUpdate(ctx context.Context, d *schema.ResourceData, m interf
231230
return diag.Errorf("plan %s not found", targetPlan)
232231
}
233232

234-
_, err = api.SelectPlan(&cockpit.GlobalAPISelectPlanRequest{
233+
_, err = api.SelectPlan(&cockpit.GlobalAPISelectPlanRequest{ //nolint:staticcheck
235234
ProjectID: projectID,
236235
PlanName: cockpit.PlanName(planName),
237236
}, scw.WithContext(ctx))

internal/services/cockpit/cockpit_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func dataSourceCockpitRead(ctx context.Context, d *schema.ResourceData, m interf
5353
}
5454
}
5555

56-
res, err := api.GetCurrentPlan(&cockpit.GlobalAPIGetCurrentPlanRequest{
56+
res, err := api.GetCurrentPlan(&cockpit.GlobalAPIGetCurrentPlanRequest{ //nolint:staticcheck
5757
ProjectID: projectID,
5858
}, scw.WithContext(ctx))
5959
if err != nil {

internal/services/cockpit/plan_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func DataSourceCockpitPlanRead(ctx context.Context, d *schema.ResourceData, m in
3131

3232
name := d.Get("name").(string)
3333

34-
res, err := api.ListPlans(&cockpit.GlobalAPIListPlansRequest{}, scw.WithContext(ctx), scw.WithAllPages())
34+
res, err := api.ListPlans(&cockpit.GlobalAPIListPlansRequest{}, scw.WithContext(ctx), scw.WithAllPages()) //nolint:staticcheck
3535
if err != nil {
3636
return diag.FromErr(err)
3737
}

internal/services/instance/server.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ func ResourceServer() *schema.Resource {
121121
Type: schema.TypeInt,
122122
Optional: true,
123123
Computed: true,
124-
ForceNew: true,
125124
Description: "Size of the root volume in gigabytes",
126125
},
127126
"volume_type": {
@@ -374,6 +373,7 @@ func ResourceServer() *schema.Resource {
374373
),
375374
customDiffInstanceServerType,
376375
customDiffInstanceServerImage,
376+
customDiffInstanceRootVolumeSize,
377377
),
378378
}
379379
}
@@ -1169,6 +1169,33 @@ func instanceServerCanMigrate(api *instanceSDK.API, server *instanceSDK.Server,
11691169
return nil
11701170
}
11711171

1172+
func customDiffInstanceRootVolumeSize(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error {
1173+
if !diff.HasChange("root_volume.0.size_in_gb") || diff.Id() == "" {
1174+
return nil
1175+
}
1176+
1177+
instanceAPI, zone, id, err := NewAPIWithZoneAndID(meta, diff.Id())
1178+
if err != nil {
1179+
return err
1180+
}
1181+
1182+
resp, err := instanceAPI.GetServer(&instanceSDK.GetServerRequest{
1183+
Zone: zone,
1184+
ServerID: id,
1185+
})
1186+
if err != nil {
1187+
return fmt.Errorf("failed to check server root volume type: %w", err)
1188+
}
1189+
1190+
if rootVolume, hasRootVolume := resp.Server.Volumes["0"]; hasRootVolume {
1191+
if rootVolume.VolumeType == instanceSDK.VolumeServerVolumeTypeLSSD {
1192+
return diff.ForceNew("root_volume.0.size_in_gb")
1193+
}
1194+
}
1195+
1196+
return nil
1197+
}
1198+
11721199
func customDiffInstanceServerType(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error {
11731200
if !diff.HasChange("type") || diff.Id() == "" {
11741201
return nil

internal/services/instance/server_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ func TestAccServer_Minimal2(t *testing.T) {
146146
func TestAccServer_RootVolume1(t *testing.T) {
147147
tt := acctest.NewTestTools(t)
148148
defer tt.Cleanup()
149+
150+
serverID := ""
151+
149152
resource.ParallelTest(t, resource.TestCase{
150153
PreCheck: func() { acctest.PreCheck(t) },
151154
ProviderFactories: tt.ProviderFactories,
@@ -166,6 +169,7 @@ func TestAccServer_RootVolume1(t *testing.T) {
166169
isServerPresent(tt, "scaleway_instance_server.base"),
167170
serverHasNewVolume(tt, "scaleway_instance_server.base"),
168171
resource.TestCheckResourceAttr("scaleway_instance_server.base", "root_volume.0.size_in_gb", "10"),
172+
acctest.CheckResourceIDPersisted("scaleway_instance_server.base", &serverID),
169173
),
170174
},
171175
{
@@ -183,6 +187,7 @@ func TestAccServer_RootVolume1(t *testing.T) {
183187
isServerPresent(tt, "scaleway_instance_server.base"),
184188
serverHasNewVolume(tt, "scaleway_instance_server.base"),
185189
resource.TestCheckResourceAttr("scaleway_instance_server.base", "root_volume.0.size_in_gb", "20"),
190+
acctest.CheckResourceIDChanged("scaleway_instance_server.base", &serverID), // Server should have been re-created as l_ssd cannot be resized.
186191
),
187192
},
188193
},
@@ -1702,6 +1707,9 @@ func TestAccServer_BlockExternal(t *testing.T) {
17021707
func TestAccServer_BlockExternalRootVolume(t *testing.T) {
17031708
tt := acctest.NewTestTools(t)
17041709
defer tt.Cleanup()
1710+
1711+
serverID := ""
1712+
17051713
resource.ParallelTest(t, resource.TestCase{
17061714
PreCheck: func() { acctest.PreCheck(t) },
17071715
ProviderFactories: tt.ProviderFactories,
@@ -1725,6 +1733,7 @@ func TestAccServer_BlockExternalRootVolume(t *testing.T) {
17251733
resource.TestCheckResourceAttr("scaleway_instance_server.main", "root_volume.0.volume_type", string(instanceSDK.VolumeVolumeTypeSbsVolume)),
17261734
resource.TestCheckResourceAttr("scaleway_instance_server.main", "root_volume.0.sbs_iops", "15000"),
17271735
resource.TestCheckResourceAttr("scaleway_instance_server.main", "root_volume.0.size_in_gb", "50"),
1736+
acctest.CheckResourceIDPersisted("scaleway_instance_server.main", &serverID),
17281737
),
17291738
},
17301739
{
@@ -1745,6 +1754,7 @@ func TestAccServer_BlockExternalRootVolume(t *testing.T) {
17451754
resource.TestCheckResourceAttr("scaleway_instance_server.main", "root_volume.0.volume_type", string(instanceSDK.VolumeVolumeTypeSbsVolume)),
17461755
resource.TestCheckResourceAttr("scaleway_instance_server.main", "root_volume.0.sbs_iops", "15000"),
17471756
resource.TestCheckResourceAttr("scaleway_instance_server.main", "root_volume.0.size_in_gb", "60"),
1757+
acctest.CheckResourceIDPersisted("scaleway_instance_server.main", &serverID),
17481758
),
17491759
},
17501760
},

0 commit comments

Comments
 (0)