Skip to content

PRICE-553: add terraform support for pod mutations#662

Open
pawelpeksa wants to merge 8 commits intomasterfrom
PRICE-553-poc-pod-mutations-terraform-support
Open

PRICE-553: add terraform support for pod mutations#662
pawelpeksa wants to merge 8 commits intomasterfrom
PRICE-553-poc-pod-mutations-terraform-support

Conversation

@pawelpeksa
Copy link

PRICE-553: add terraform support for pod mutations

@pawelpeksa pawelpeksa self-assigned this Mar 12, 2026
@pawelpeksa pawelpeksa requested a review from a team as a code owner March 12, 2026 15:48
d.SetId("")
return nil
}
if checkErr := sdk.CheckOKResponse(resp, err); checkErr != nil {
Copy link
Contributor

@michal-kopczynski michal-kopczynski Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err is always nil at this point -> so maybe (resp, nil)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Type: schema.TypeInt,
Computed: true,
Description: "Number of pods mutated by this pod mutation.",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this field be in state at all? it's changing dynamically in the API

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

if v, ok := d.GetOk(FieldPodMutationSpotDistributionPct); ok {
pct := int32(v.(int))
mutation.SpotDistributionPercentage = &pct
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will GetOk handle correctly zero value? I mean won't it be ignored by TF?

Copy link
Author

@pawelpeksa pawelpeksa Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be ignored, changed

}

func podMutationStateImporter(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
organizationID, id := parseImportID(d)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseImportID is defined in resource_hibernation_schedule.go. Maybe it should be moved to some shared file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used anymore after other changes

}
}

func podMutationStateImporter(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should podMutationStateImporter handle also cluster ID or there is no need? 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it definitely should, fixing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, cluster ID is required to fetch pod mutation anyway

}

// Restart matching workloads
if v, ok := d.GetOk(FieldPodMutationRestartWorkloads); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - does it handle false value properly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

patchJSON, err := json.Marshal(*g.Config.Patch)
if err == nil {
configMap[FieldPodMutationPatch] = string(patchJSON)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Marshal error handling

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

}
em := e.(map[string]interface{})
key := em[FieldPodMutationTolerationKey].(string)
operator := em[FieldPodMutationTolerationOperator].(string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should NodeSelectorRequirement have it own specific key and operator constants, and not re use the one from toleration?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
FieldPodMutationTolerationKey: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should Affinity/MatchExpressions have it own specific key and operator constants, and not re use the one from toleration?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants