Skip to content
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

Feat/implement volume boot order #486

Closed
wants to merge 6 commits into from

Conversation

cbeti-ionos
Copy link
Member

What does this fix or implement?

Ability to select the primary boot volume for ionoscloud_server

Checklist

  • PR name added as appropriate (e.g. feat:/fix:/doc:/test:/refactor:)
  • Tests added or updated
  • Documentation updated
  • Changelog updated and version incremented (label: upcoming release)
  • Github Issue linked if any
  • Jira task updated

inlineVolumeIds := d.Get("inline_volume_ids")

if inlineVolumeIds != nil {
inlineVolumeIds := inlineVolumeIds.([]interface{})
Copy link
Collaborator

Choose a reason for hiding this comment

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

very minor, but you can use any instead of interface{}

Copy link
Member Author

Choose a reason for hiding this comment

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

currently there is mixed usage of interface{} and any, should we allow this or enforce one over the other?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can allow for now. any was added in go 1.18. maybe we do a search and replace at some point.

volumes = append(volumes, entry)
if err := d.Set("volume", volumes); err != nil {
return fmt.Errorf("error setting volume %w", err)
bootOrder := ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't you just set it to AUTO here and not have the if if bootOrder == "" below?

Copy link
Member Author

Choose a reason for hiding this comment

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

has been reworked, we will now use a boolean instead of predefined strings like 'AUTO', 'NONE', 'PRIMARY'

@@ -352,6 +360,15 @@ func resourceCubeServer() *schema.Resource {
},
},
},
//Keep track of the inline volume of the Cube server in case the boot volume is changed.
"inline_volume_ids": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you test an upgrade pre to after inline_volume_ids? I think we need to add something similar to resoruce_server
// takes care of an upgrade from a version that does not have inline_volume_ids(pre 6.4.0)
// to one that has it(>6.4.0)
if _, ok := d.GetOk("inline_volume_ids"); !ok {
if bootVolumeItf, ok := d.GetOk("boot_volume"); ok {
bootVolume := bootVolumeItf.(string)
var inlineVolumeIds []string
inlineVolumeIds = append(inlineVolumeIds, bootVolume)
if err := d.Set("inline_volume_ids", inlineVolumeIds); err != nil {
return utils.GenerateSetError("server", "inline_volume_ids", err)
}
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

tested upgrade from 6.3.8 to current, seems to be working fine

@@ -310,6 +310,13 @@ func resourceServer() *schema.Resource {
Description: "The UUID of the attached server.",
Computed: true,
},
"boot_order": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add this to some server tests also?

Copy link
Member Author

Choose a reason for hiding this comment

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

added tests for server resource

adeatcu-ionos
adeatcu-ionos previously approved these changes Nov 20, 2023
docs/resources/volume.md Outdated Show resolved Hide resolved
ionoscloud/resource_server.go Outdated Show resolved Hide resolved
ionoscloud/resource_server.go Outdated Show resolved Hide resolved
ionoscloud/resource_server.go Outdated Show resolved Hide resolved
ionoscloud/resource_server.go Outdated Show resolved Hide resolved
ionoscloud/resource_server.go Show resolved Hide resolved
ionoscloud/resource_server.go Outdated Show resolved Hide resolved
ionoscloud/resource_server.go Show resolved Hide resolved
ionoscloud/resource_server_cube.go Show resolved Hide resolved
ionoscloud/resource_server_cube_test.go Show resolved Hide resolved
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
14.1% 14.1% Duplication

@cbeti-ionos cbeti-ionos linked an issue Dec 12, 2023 that may be closed by this pull request
@cbeti-ionos
Copy link
Member Author

Closing this as the feature has been implemented by
#507

@cbeti-ionos cbeti-ionos deleted the feat/implement_volume_boot_order branch December 20, 2023 09:10
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