Skip to content

Add model serving#697

Merged
bahkauv70 merged 38 commits intostackitcloud:mainfrom
PatrickKoss:main
Mar 28, 2025
Merged

Add model serving#697
bahkauv70 merged 38 commits intostackitcloud:mainfrom
PatrickKoss:main

Conversation

@PatrickKoss
Copy link
Copy Markdown
Contributor

Add model serving to stackit terraform provider

Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
Comment thread stackit/internal/core/core.go
@rubenhoenle
Copy link
Copy Markdown
Member

Could you add some examples for your new resource and datasource please?

see https://github.com/stackitcloud/terraform-provider-stackit/tree/main/examples

Comment thread stackit/internal/services/modelserving/model_serving_acc_test.go Outdated
@PatrickKoss
Copy link
Copy Markdown
Contributor Author

Could you add some examples for your new resource and datasource please?

see https://github.com/stackitcloud/terraform-provider-stackit/tree/main/examples

Added the examples

Comment thread examples/resources/stackit_modelserving_token/resource.tf Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go
@h3adex
Copy link
Copy Markdown
Contributor

h3adex commented Mar 12, 2025

Please also runmake generate-docsand push the model_serving docs to this PR :-)

@PatrickKoss
Copy link
Copy Markdown
Contributor Author

will come back to this pr once the stackit-go-sdk is released because I need the wait handler

@h3adex
Copy link
Copy Markdown
Contributor

h3adex commented Mar 14, 2025

will come back to this pr once the stackit-go-sdk is released because I need the wait handler

Release (2025-03-14)

@PatrickKoss
Copy link
Copy Markdown
Contributor Author

@h3adex @rubenhoenle can you check again? Is this the right way to implement the default region if not in the provider specified?

Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go
Comment thread stackit/internal/services/modelserving/token/resource.go
Comment thread stackit/internal/services/modelserving/token/resource.go
Comment thread stackit/internal/services/modelserving/token/resource.go
Comment thread stackit/internal/services/modelserving/token/datasource.go Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
Comment thread stackit/internal/services/modelserving/token/datasource.go Outdated
Comment thread stackit/internal/services/modelserving/token/resource.go Outdated
@h3adex
Copy link
Copy Markdown
Contributor

h3adex commented Mar 25, 2025

provider "stackit" {
  default_region           = var.stackit_region
  service_account_key_path = var.stackit_service_account_key_path
  enable_beta_resources    = true
}

resource "time_rotating" "rotate" {
  rotation_minutes = 1
}

resource "stackit_modelserving_token" "example" {
  project_id = var.stackit_project_id
  region     = "eu01"
  name       = "Example token"

  rotate_when_changed = {
    rotation = time_rotating.rotate.id
  }
}

@bahkauv70
Copy link
Copy Markdown
Contributor

Creating the datasource still has some issues:
when using the following terraform file:

resource "time_rotating" "rotate" {
  rotation_minutes = 60
}

resource "stackit_modelserving_token" "example" {
  project_id = var.project_id
  region     = "eu01"
  name       = "Example token"

  rotate_when_changed = {
    rotation = time_rotating.rotate.id
  }
}

data "stackit_modelserving_token" "exampleds" {
  project_id = var.project_id
  token_id   = stackit_modelserving_token.example.token_id
}

output "testoutput" {
  value = [
    "token id: ${data.stackit_modelserving_token.exampleds.token_id}",
  ]
}

the following error occurs

│ Error: Value Conversion Error
│ 
│   with data.stackit_modelserving_token.exampleds,
│ An unexpected error was encountered trying to convert tftypes.Value into token.Model. This
│ is always an error in the provider. Please report the following to the provider developer:
│ 
│ mismatch between struct and object: Struct defines fields not found in object: ttl_duration
│ and rotate_when_changed.
╵

The datasource has a different structure as the resource, so we probably need a dedicated model for the datasource

@h3adex
Copy link
Copy Markdown
Contributor

h3adex commented Mar 25, 2025

I also got a region error on the data-source.

Screenshot 2025-03-25 at 16 32 54

@PatrickKoss
Copy link
Copy Markdown
Contributor Author

Creating the datasource still has some issues: when using the following terraform file:

resource "time_rotating" "rotate" {
  rotation_minutes = 60
}

resource "stackit_modelserving_token" "example" {
  project_id = var.project_id
  region     = "eu01"
  name       = "Example token"

  rotate_when_changed = {
    rotation = time_rotating.rotate.id
  }
}

data "stackit_modelserving_token" "exampleds" {
  project_id = var.project_id
  token_id   = stackit_modelserving_token.example.token_id
}

output "testoutput" {
  value = [
    "token id: ${data.stackit_modelserving_token.exampleds.token_id}",
  ]
}

the following error occurs

│ Error: Value Conversion Error
│ 
│   with data.stackit_modelserving_token.exampleds,
│ An unexpected error was encountered trying to convert tftypes.Value into token.Model. This
│ is always an error in the provider. Please report the following to the provider developer:
│ 
│ mismatch between struct and object: Struct defines fields not found in object: ttl_duration
│ and rotate_when_changed.
╵

The datasource has a different structure as the resource, so we probably need a dedicated model for the datasource

fixed it

@PatrickKoss
Copy link
Copy Markdown
Contributor Author

I also got a region error on the data-source.

Screenshot 2025-03-25 at 16 32 54

should be fixed

@PatrickKoss
Copy link
Copy Markdown
Contributor Author

Ok, looks good now. Could you please provide a sample terraform file and some testing instructions, so we can do some acceptance testsing for this change. If it works, we can merge it asap. For future PR please try to avoid reformatting of existing code when not necessary to keep the diffs as small as possible

where do I need to add these instructions? I see there is some kind of acceptance test in each service.

@bahkauv70
Copy link
Copy Markdown
Contributor

The testing instructions are commonly added to the JIRA issues (for this one it would be STACKITTPR-147. Note that due to permission issues the TPR project is most suitable. In this case however the terraform config is sufficient.

bahkauv70
bahkauv70 previously approved these changes Mar 27, 2025
Copy link
Copy Markdown
Contributor

@bahkauv70 bahkauv70 left a comment

Choose a reason for hiding this comment

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

Looks good now, all tests from my side worked

Comment thread stackit/internal/services/modelserving/token/const.go Outdated
bahkauv70
bahkauv70 previously approved these changes Mar 28, 2025
@bahkauv70 bahkauv70 enabled auto-merge (squash) March 28, 2025 09:27
@bahkauv70 bahkauv70 merged commit 435de4c into stackitcloud:main Mar 28, 2025
3 checks passed
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.

5 participants