Skip to content

Commit 9a495f1

Browse files
authored
Add missing fields to workload policies (#16)
1 parent a60116c commit 9a495f1

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

internal/provider/workload_policy.go

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type WorkloadPolicyResourceModel struct {
4949
CronSchedule types.String `tfsdk:"cron_schedule"`
5050
DetectionTriggers types.List `tfsdk:"detection_triggers"`
5151
LoopbackPeriodSeconds types.Int32 `tfsdk:"loopback_period_seconds"`
52-
StartupPeriodSeconds types.Int32 `tfsdk:"startup_period_seconds"`
52+
StartupPeriodSeconds types.Int64 `tfsdk:"startup_period_seconds"`
5353
CPUVerticalScaling *VerticalScalingOptions `tfsdk:"cpu_vertical_scaling"`
5454
MemoryVerticalScaling *VerticalScalingOptions `tfsdk:"memory_vertical_scaling"`
5555
GPUVerticalScaling *VerticalScalingOptions `tfsdk:"gpu_vertical_scaling"`
@@ -240,12 +240,10 @@ func (r *WorkloadPolicyResource) Schema(ctx context.Context, req resource.Schema
240240
Computed: true,
241241
Default: int32default.StaticInt32(86400),
242242
},
243-
"startup_period_seconds": schema.Int32Attribute{
243+
"startup_period_seconds": schema.Int64Attribute{
244244
Description: "Ignore early-life metrics for this duration",
245245
MarkdownDescription: "Startup period seconds of the workload policy. The startup period is the period of time to ignore resource usage data after the workload is started.",
246246
Optional: true,
247-
Computed: true,
248-
Default: int32default.StaticInt32(0),
249247
},
250248
"cpu_vertical_scaling": schema.SingleNestedAttribute{
251249
Description: "CPU vertical scaling options",
@@ -578,6 +576,8 @@ func (m *WorkloadPolicyResourceModel) toProto(ctx context.Context, diags *diag.D
578576
ActionTriggers: actionTriggers,
579577
CronSchedule: m.CronSchedule.ValueStringPointer(),
580578
DetectionTriggers: detectionTriggers,
579+
LoopbackPeriodSeconds: m.LoopbackPeriodSeconds.ValueInt32Pointer(),
580+
StartupPeriodSeconds: m.StartupPeriodSeconds.ValueInt64Pointer(),
581581
CpuVerticalScaling: m.CPUVerticalScaling.toProto(),
582582
MemoryVerticalScaling: m.MemoryVerticalScaling.toProto(),
583583
GpuVerticalScaling: m.GPUVerticalScaling.toProto(),
@@ -586,6 +586,13 @@ func (m *WorkloadPolicyResourceModel) toProto(ctx context.Context, diags *diag.D
586586
LiveMigrationEnabled: m.LiveMigrationEnabled.ValueBool(),
587587
SchedulerPlugins: schedulerPlugins,
588588
DefragmentationSchedule: m.DefragmentationSchedule.ValueStringPointer(),
589+
MinChangePercent: m.MinChangePercent.ValueFloat32Pointer(),
590+
MinDataPoints: m.MinDataPoints.ValueInt32Pointer(),
591+
StabilityCvMax: m.StabilityCvMax.ValueFloat32Pointer(),
592+
HysteresisVsTarget: m.HysteresisVsTarget.ValueFloat32Pointer(),
593+
DriftDeltaPercent: m.DriftDeltaPercent.ValueFloat32Pointer(),
594+
MinVpaWindowDataPoints: m.MinVpaWindowDataPoints.ValueInt32Pointer(),
595+
CooldownMinutes: m.CooldownMinutes.ValueInt32Pointer(),
589596
}
590597
}
591598

@@ -624,6 +631,13 @@ func (m *WorkloadPolicyResourceModel) fromProto(policy *apiv1.WorkloadRecommenda
624631
}
625632
m.DetectionTriggers = types.ListValueMust(types.StringType, detectionTriggers)
626633

634+
if policy.LoopbackPeriodSeconds != nil {
635+
m.LoopbackPeriodSeconds = types.Int32Value(*policy.LoopbackPeriodSeconds)
636+
}
637+
if policy.StartupPeriodSeconds != nil {
638+
m.StartupPeriodSeconds = types.Int64Value(*policy.StartupPeriodSeconds)
639+
}
640+
627641
m.CPUVerticalScaling.fromProto(policy.CpuVerticalScaling)
628642
m.MemoryVerticalScaling.fromProto(policy.MemoryVerticalScaling)
629643
m.GPUVerticalScaling.fromProto(policy.GpuVerticalScaling)
@@ -640,6 +654,28 @@ func (m *WorkloadPolicyResourceModel) fromProto(policy *apiv1.WorkloadRecommenda
640654
if policy.DefragmentationSchedule != nil {
641655
m.DefragmentationSchedule = types.StringValue(*policy.DefragmentationSchedule)
642656
}
657+
658+
if policy.MinChangePercent != nil {
659+
m.MinChangePercent = types.Float32Value(*policy.MinChangePercent)
660+
}
661+
if policy.MinDataPoints != nil {
662+
m.MinDataPoints = types.Int32Value(*policy.MinDataPoints)
663+
}
664+
if policy.StabilityCvMax != nil {
665+
m.StabilityCvMax = types.Float32Value(*policy.StabilityCvMax)
666+
}
667+
if policy.HysteresisVsTarget != nil {
668+
m.HysteresisVsTarget = types.Float32Value(*policy.HysteresisVsTarget)
669+
}
670+
if policy.DriftDeltaPercent != nil {
671+
m.DriftDeltaPercent = types.Float32Value(*policy.DriftDeltaPercent)
672+
}
673+
if policy.MinVpaWindowDataPoints != nil {
674+
m.MinVpaWindowDataPoints = types.Int32Value(*policy.MinVpaWindowDataPoints)
675+
}
676+
if policy.CooldownMinutes != nil {
677+
m.CooldownMinutes = types.Int32Value(*policy.CooldownMinutes)
678+
}
643679
}
644680

645681
func (o *VerticalScalingOptions) toProto() *apiv1.VerticalScalingOptimizationTarget {

0 commit comments

Comments
 (0)