Skip to content

feat(mexp): Onboarding Modelexperiments - #1547

Open
paul-sffrth wants to merge 42 commits into
stackitcloud:mainfrom
paul-sffrth:feat/mlflow
Open

feat(mexp): Onboarding Modelexperiments#1547
paul-sffrth wants to merge 42 commits into
stackitcloud:mainfrom
paul-sffrth:feat/mlflow

Conversation

@paul-sffrth

Copy link
Copy Markdown
Member

Description

This is the onboarding PR for integration STACKIT Modelexperiments into the STACKIT Terraform Provider.

It adds for customer the ability to:

  • Create, Read, Update and Delete Modelexperiments Instances
  • Create, Read, Update and Delete Mdelexperiments Instance Tokens

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@paul-sffrth
paul-sffrth requested a review from a team as a code owner June 29, 2026 09:24
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it.

@github-actions github-actions Bot added the Stale PR is marked as stale due to inactivity. label Jul 8, 2026
@Fyusel Fyusel removed the Stale PR is marked as stale due to inactivity. label Jul 8, 2026
Comment thread examples/resources/stackit_modelexperiments_token/resource.tf
Comment thread stackit/internal/services/modelexperiments/instance/description.md Outdated
Comment thread stackit/internal/services/modelexperiments/instance/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/instance/resource.go
Comment thread stackit/internal/services/modelexperiments/token/description.md Outdated
Comment thread stackit/internal/services/modelexperiments/utils/util.go Outdated
Comment thread stackit/internal/services/modelexperiments/token/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/instance/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/token/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/token/resource.go
Comment thread stackit/internal/services/modelexperiments/token/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/token/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/token/resource.go
Comment thread stackit/internal/services/modelexperiments/instance/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/instance/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/token/resource.go Outdated
Comment thread stackit/internal/services/modelexperiments/modelexperiments_acc_test.go Outdated
@Fyusel

Fyusel commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

After those comments are resolved I will start to run the acceptance tests and manual testing

Comment thread stackit/internal/services/modelexperiments/instance/datasource.go
Comment thread stackit/internal/services/modelexperiments/token/datasource.go
Comment thread examples/resources/stackit_modelexperiments_instance/resource.tf
Comment thread examples/resources/stackit_modelexperiments_token/resource.tf Outdated
Comment thread examples/resources/stackit_modelexperiments_token/resource.tf Outdated
Comment on lines +12 to +22
resource "time_rotating" "rotate" {
rotation_days = 80
}

resource "stackit_modelexperiments_token" "token" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "Example token nane"
region = "eu01"
instance_id = stackit_modelexperiments_instance.example.instance_id
description = "Example token description"
ttl_duration = "1h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I got it correctly, the ttl_duration value defines when the token expires. In this case it would be after one hour, but the time_rotating resource would trigger a recreate after 80 days. I think it would be nice, if this examples contains values which fit better together

Comment on lines +405 to +410
updateInstanceResp, err := i.client.PartialUpdateInstance(ctx, projectId, region, instanceId).PartialUpdateInstancePayload(*payload).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating AI Model Experiments instance", fmt.Sprintf("Calling API: %v", err))
return
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is the update synchronous? Because based on the API spec, it returns a 202 which means the update is accepted but not done. There is also an updating state. But I couldn't find a waiter for the update

Comment on lines +498 to +500
if instance.Id == "" {
return fmt.Errorf("instance id not present")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

check if instance == nil is missing. Potential nil pointer exception

Comment on lines +23 to +25
type InstanceDataSourceModel struct {
Model
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason why there is a separate datasource model, which just has the resource model embedded? If not, then the Model can be just directly used.


getInstanceTokenResp, err := i.client.GetInstanceToken(ctx, projectId, region, tokenId, instanceId).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading AI Model Experiments instance token", fmt.Sprintf("Calling API: %v", err))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have a utils.LogError() function, which should be used in datasources for error handling and providing a more descriptive error message.

See example usage:

utils.LogError(
ctx,
&resp.Diagnostics,
err,
"Reading server update enable",
fmt.Sprintf("Server update enable does not exist for this server %q.", serverId),
map[int]string{
http.StatusForbidden: fmt.Sprintf("Project with ID %q or server with ID %q not found or forbidden access", projectId, serverId),
},
)

return fmt.Errorf("model input is nil")
}

if token.Id == "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nil check for token is missing

return fmt.Errorf("model input is nil")
}

if token.Id == "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

potential nil pointer on token

return fmt.Errorf("model input is nil")
}

if token.Id == "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

potential nil pointer on token

Comment on lines +195 to +196
ConfigVariables: testModelexperimentsInstanceConfigVarsMinUpdated(),
Check: resource.ComposeAggregateTestCheckFunc(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add here some config plan checks, to ensure that only a update and not a replace will be triggered. Similar like here:

ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("stackit_postgresflex_instance.instance", plancheck.ResourceActionUpdate),
},
},

Comment on lines +344 to +345
ConfigVariables: testModelexperimentsInstanceConfigVarsMaxUpdated(),
Check: resource.ComposeAggregateTestCheckFunc(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("stackit_postgresflex_instance.instance", plancheck.ResourceActionUpdate),
},
},

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.

3 participants