-
Notifications
You must be signed in to change notification settings - Fork 48
STACKITRCO-187 - Add option iaas API param agent #1113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
STACKITRCO-187 - Add option iaas API param agent #1113
Conversation
3a093e8 to
44c1522
Compare
Adds a terraform `stackit_server` option for the iaas ( _create server_ ) API param:
`"agent": {"provisioned": true}`
ref STACKITRCO-187
ref: stackitcloud/stackit-cli#1213
---
Tests:
* ran `make fmt`, `make generate-docs`
* ran unit tests
```
[~/terraform-provider-stackit] go test stackit/internal/services/iaas/server/*
ok command-line-arguments 15.005s
[~/terraform-provider-stackit] make test
...
ok github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/server 15.006s coverage: 33.0% of statements
...
[~/terraform-provider-stackit]
```
* Tested: with a locally-configured terraform - tested by adding, changing, deleting `agent`-related parts of the below main.tf
** Tested without providing agent inside main.tf (the result had `"agent" = null /* object */`)
** Tested with setting `agent = { provisioning = true }` (and then ran the `stackit-cli` command for checking if the agent was created successfully and able to run commands, `stackit -y server command create --server-id=3fdac6ea-3885-441c-b473-bc94ca570ca8 --project-id=c904f41c-2f8c-4edb-b966-e87d65f10b64 --template-name=RunShellScript --params script='echo hello'`).
** Tested when setting `agent = { provisioning = true }` and then set it to false - verified the server was deleted and recreated again with the new value.
```
[~] cat main.tf
provider "stackit" {
# Configuration options
service_account_key_path = "/home/debian/terraform_dev/.terraform_key.json"
default_region = "eu01"
}
resource "stackit_network_interface" "server_nic" {
project_id = "c904f41c-2f8c-4edb-b966-e87d65f10b64"
network_id = "97c5dde4-cb9d-49b8-be55-9cdf0c3795e1"
}
resource "stackit_server" "myserver1" {
project_id = "c904f41c-2f8c-4edb-b966-e87d65f10b64"
name = "terraformtestserver1"
boot_volume = {
size = 64
source_type = "image"
source_id = "21466190-b904-4267-8bf3-1be4323f4ffb"
delete_on_termination = true
}
availability_zone = "eu01-1"
agent = {
provisioned = true
}
machine_type = "t1.1"
network_interfaces = [ stackit_network_interface.server_nic.network_interface_id ]
}
data "stackit_server" "myserver1_data" {
project_id = "c904f41c-2f8c-4edb-b966-e87d65f10b64"
server_id = stackit_server.myserver1.server_id
}
output "server_info_from_data" {
value = data.stackit_server.myserver1_data
}
```
```
[~] terraform apply -auto-approve ## this is without `agent` set in the config
...
server_info_from_data = {
"affinity_group" = tostring(null)
"agent" = null /* object */
"availability_zone" = "eu01-1"
...
}
...
```
```
[~] terraform apply -auto-approve ## this is with `agent = { provisioned = true }` set in the config
...
server_info_from_data = {
"affinity_group" = tostring(null)
"agent" = {
"provisioned" = true
}
"availability_zone" = "eu01-1"
"boot_volume" = {
"delete_on_termination" = true
"id" = "673021e5-2a90-4482-8ffa-e0485c7588bd"
}
...
}
```
Signed-off-by: Adrian Nackov <[email protected]>
44c1522 to
699af50
Compare
|
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. |
cgoetz-inovex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm besides the docs
| resource "stackit_key_pair" "keypair" { | ||
| ```terraform | ||
| resource "stackitkeypair" "keypair" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these changes look odd, sure these belong into this PR? Probably also explain the check-docs-failure on CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from that the docs are auto-generated and this looks like manual edits to these documents.
See the result of make generate-docs 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update my tfplugindocs from v0.16.0 to the newest version 0.21.0, per scripts/project.sh, and update the PR's docs.
The docs were not edited manually. My dev branch was cut after 74ed4bd. I just trusted the auto-doc-generator of make generate-docs - without seeing I have an old version of tfplugindocs installed locally some years ago for contributing to this project. I did skim over the generated docs, but (wrongly) thought anything not mine were leftover docs from previous commits in this repo that people had forgotten to commit.
[~/terraform-provider-stackit] go version -m $(which tfplugindocs)
/home/debian/go/bin/tfplugindocs: go1.22.1
path github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
mod github.com/hashicorp/terraform-plugin-docs v0.16.0 h1:UmxFr3AScl6Wged84jndJIfFccGyBZn52KtMNsS12dI=
| MarkdownDescription: "Name of the type of the machine for the server. Possible values are documented in [Virtual machine flavors](https://docs.stackit.cloud/products/compute-engine/server/basics/machine-types/)", | ||
| Computed: true, | ||
| }, | ||
| "agent": schema.SingleNestedAttribute{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The acceptance tests don't include your new field yet:
Could you also adjust them please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot run the acceptance tests (if I do, it probably costs money). I did not want to add code to files I cannot test.
If this is a strong requirement for this PR, how can I do this?
| Attributes: map[string]schema.Attribute{ | ||
| "provisioned": schema.BoolAttribute{ | ||
| Description: "Whether a STACKIT Server Agent is provisioned at the server", | ||
| Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what the API docs say about the "provisioned" server agent field: https://docs.api.stackit.cloud/documentation/iaas/version/v2#tag/Servers/operation/v2CreateServer
When false the agent IS NOT installed. When true the agent IS installed. When its not set the result depend on the used image and its default provisioning setting.
Since this is not trivial to solve, we as the STACKIT Developer Tools team decided that the default value for the "provisioned" field should be false. Could you please adjust your implementation to respect that decision? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be sure I understand it right:
- By the previous code, so far, the param always has defaulted to null. (I think) I keep it as it has always been. Like - don't send any agent-related param to the API.
- Currently (by my code) the param has 3 states:
null,false,true. Default remains null.
It seems like you want to be even more explicit - and to always default the param to false, without a null state (thus - to not use any image default agent provisioning) .
OK. I'll update the code (cannot do it today, I also need to re-test it all).
Adds a terraform
stackit_serveroption for the iaas ( create server ) API param:"agent": {"provisioned": true}ref STACKITRCO-187
ref: stackitcloud/stackit-cli#1213
Tests:
ran
make fmt,make generate-docsran unit tests
agent-related parts of the below main.tf ** Tested without providing agent inside main.tf (the result had"agent" = null /* object */)** Tested with setting
agent = { provisioning = true }(and then ran thestackit-clicommand for checking if the agent was created successfully and able to run commands,stackit -y server command create --server-id=3fdac6ea-3885-441c-b473-bc94ca570ca8 --project-id=c904f41c-2f8c-4edb-b966-e87d65f10b64 --template-name=RunShellScript --params script='echo hello').** Tested when setting
agent = { provisioning = true }and then set it to false - verified the server was deleted and recreated again with the new value.Description
relates to STACKITRCO-187
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)