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

instancepool: add min available support and Migrate to egoscale v3 #629

Merged

Conversation

elkezza
Copy link
Contributor

@elkezza elkezza commented Aug 20, 2024

Description

Added min available to both instance_pool_create.go and instance_pool_update.go and Migrate to egoscale v3k, however, there are some parts need to be reviewed like InstanceType in instance_pool_update.go which I was not sure how to be correctly implemented in egoscale v3.

Checklist

(For exoscale contributors)

  • Changelog updated (under Unreleased block)
  • Testing

Testing

I test to create new instance pool with min available 3 then I updated see the bellow output of the tests:

 go run . compute instance-pool create my-pool --size 4 --min-available 3
 ✔ Creating Instance Pool "my-pool"... 24s
┼──────────────────────┼──────────────────────────────────────┼
│    INSTANCE POOL     │                                      │
┼──────────────────────┼──────────────────────────────────────┼
│ ID                   │ 9c52ad25-9898-48c1-be9a-f90ce13575c2 │
│ Name                 │ my-pool                              │
│ Description          │                                      │
│ Instance Type        │ standard.medium                      │
│ Template             │ Linux Ubuntu 22.04 LTS 64-bit        │
│ Zone                 │ at-vie-1                             │
│ Anti-Affinity Groups │ n/a                                  │
│ Security Groups      │ n/a                                  │
│ Private Networks     │ n/a                                  │
│ Elastic IPs          │ n/a                                  │
│ IPv6                 │ false                                │
│ SSH Key              │ -                                    │
│ Size                 │ 4                                    │
│ Disk Size            │ 50 GiB                               │
│ Instance Prefix      │ pool                                 │
│ State                │ scaling-up                           │
│ Labels               │ n/a                                  │
│ Instances            │ pool-9c52a-dqhmy                     │
│                      │ pool-9c52a-pkwqs                     │
│                      │ pool-9c52a-iepbx                     │
│                      │ pool-9c52a-staqe                     │
┼──────────────────────┼──────────────────────────────────────┼


 go run . compute instance-pool update my-pool --min-available 4
 ✔ Updating Instance Pool "my-pool"... 0s
┼──────────────────────┼──────────────────────────────────────┼
│    INSTANCE POOL     │                                      │
┼──────────────────────┼──────────────────────────────────────┼
│ ID                   │ 9c52ad25-9898-48c1-be9a-f90ce13575c2 │
│ Name                 │ my-pool                              │
│ Description          │                                      │
│ Instance Type        │ standard.medium                      │
│ Template             │ Linux Ubuntu 22.04 LTS 64-bit        │
│ Zone                 │ at-vie-1                             │
│ Anti-Affinity Groups │ n/a                                  │
│ Security Groups      │ n/a                                  │
│ Private Networks     │ n/a                                  │
│ Elastic IPs          │ n/a                                  │
│ IPv6                 │ false                                │
│ SSH Key              │ -                                    │
│ Size                 │ 4                                    │
│ Disk Size            │ 50 GiB                               │
│ Instance Prefix      │ pool                                 │
│ State                │ updating                             │
│ Labels               │ n/a                                  │
│ Instances            │ pool-9c52a-dqhmy                     │
│                      │ pool-9c52a-pkwqs                     │
│                      │ pool-9c52a-iepbx                     │
│                      │ pool-9c52a-staqe                     │
┼──────────────────────┼──────────────────────────────────────┼

@elkezza elkezza force-pushed the salehelkaza/sc-46617/cli-tf-instancepool-min-available-support branch from 1b025df to 1a06458 Compare August 20, 2024 14:07
Name string `cli-short:"n" cli-usage:"Instance Pool name"`
PrivateNetworks []string `cli-flag:"private-network" cli-usage:"managed Compute instances Private Network NAME|ID (can be specified multiple times)"`
SSHKey string `cli-flag:"ssh-key" cli-usage:"SSH key to deploy on managed Compute instances"`
SSHKey string `cli-flag:"ssh-key" cli-usage:"SSH key to deploy on managed Compute instances (can be specified multiple times)"`
Copy link
Member

Choose a reason for hiding this comment

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

missing an s after SSHKey

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one I kept, becuase, I was not sure if to make it more than ssh key or only one, usually user update more than ssk keys?

Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to how it was done in #620, it should be SSHKeys and type is []string]. Then instead of setting updateReq.SSHKey (which accepts one SSH key), you set updateReq.SSHKeys.

Copy link
Contributor

@kobajagi kobajagi Aug 20, 2024

Choose a reason for hiding this comment

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

Actually ignore my previous comment. This kind of change is out of scope of this PR, let's keep it focused instead. So just remove (can be specified multiple times) suffix in the flag usage as it is incorrect (you can only specify a single SSH key with this implementation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack!

PrivateNetworks []string `cli-flag:"private-network" cli-usage:"managed Compute instances Private Network NAME|ID (can be specified multiple times)"`
SSHKey string `cli-flag:"ssh-key" cli-usage:"SSH key to deploy on managed Compute instances"`
SSHKeys []string `cli-flag:"ssh-key" cli-usage:"SSH key to deploy on managed Compute instances (can be specified multiple times)"`
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain how this change is relevant to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@pierre-emmanuelJ pierre-emmanuelJ force-pushed the salehelkaza/sc-46617/cli-tf-instancepool-min-available-support branch from 12c8dc2 to 20be0f7 Compare September 11, 2024 14:23
@pierre-emmanuelJ
Copy link
Member

pierre-emmanuelJ commented Sep 11, 2024

Thanks, @elkezza, for your effort on this change. I fixed Elastic IP and Instance Type.
You can re-run your test series on the command, to be able to tick again the PR testing checkbox.

return fmt.Errorf("error listing instance type: %w", err)
}

// c.InstanceType is never empty
Copy link
Member

Choose a reason for hiding this comment

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

To be checked if It's the case like Instance

@elkezza
Copy link
Contributor Author

elkezza commented Sep 11, 2024

@pierre-emmanuelJ big thanks for the new improvement in the code, below are the test regarding these changes : )

❯ go run . compute instance-pool update my-pool --elastic-ip 85.217.175.225  --elastic-ip 85.217.174.116
 ✔ Updating Instance Pool "my-pool"... 0s
┼──────────────────────┼──────────────────────────────────────┼
│    INSTANCE POOL     │                                      │
┼──────────────────────┼──────────────────────────────────────┼
│ ID                   │ 8fa38a23-4891-4868-b39b-f55a7fe567fb │
│ Name                 │ my-pool                              │
│ Description          │                                      │
│ Instance Type        │ standard.medium                      │
│ Template             │ Linux Ubuntu 22.04 LTS 64-bit        │
│ Zone                 │ at-vie-1                             │
│ Anti-Affinity Groups │ n/a                                  │
│ Security Groups      │ n/a                                  │
│ Private Networks     │ n/a                                  │
│ Elastic IPs          │ 85.217.175.225                       │
│                      │ 85.217.174.116                       │
│ IPv6                 │ false                                │
│ SSH Key              │ -                                    │
│ Size                 │ 4                                    │
│ Disk Size            │ 50 GiB                               │
│ Instance Prefix      │ pool                                 │
│ State                │ updating                             │
│ Labels               │ n/a                                  │
│ Instances            │ pool-8fa38-geuxj                     │
│                      │ pool-8fa38-czrfn                     │
│                      │ pool-8fa38-iglia                     │
│                      │ pool-8fa38-hjapn                     │
┼──────────────────────┼──────────────────────────────────────┼
❯ go run . compute instance-pool update my-pool --elastic-ip 85.217.175.225  --elastic-ip 85.217.232.33
warning: Elastic IP 85.217.232.33 not found.
 ✔ Updating Instance Pool "my-pool"... 0s
┼──────────────────────┼──────────────────────────────────────┼
│    INSTANCE POOL     │                                      │
┼──────────────────────┼──────────────────────────────────────┼
│ ID                   │ 8fa38a23-4891-4868-b39b-f55a7fe567fb │
│ Name                 │ my-pool                              │
│ Description          │                                      │
│ Instance Type        │ standard.medium                      │
│ Template             │ Linux Ubuntu 22.04 LTS 64-bit        │
│ Zone                 │ at-vie-1                             │
│ Anti-Affinity Groups │ n/a                                  │
│ Security Groups      │ n/a                                  │
│ Private Networks     │ n/a                                  │
│ Elastic IPs          │ 85.217.175.225                       │
│ IPv6                 │ false                                │
│ SSH Key              │ -                                    │
│ Size                 │ 4                                    │
│ Disk Size            │ 50 GiB                               │
│ Instance Prefix      │ pool                                 │
│ State                │ updating                             │
│ Labels               │ n/a                                  │
│ Instances            │ pool-8fa38-geuxj                     │
│                      │ pool-8fa38-czrfn                     │
│                      │ pool-8fa38-iglia                     │
│                      │ pool-8fa38-hjapn                     │
┼──────────────────────┼──────────────────────────────────────┼



❯ go run . compute instance-pool update my-pool --instance-type standard.micro
 ✔ Updating Instance Pool "my-pool"... 0s
┼──────────────────────┼──────────────────────────────────────┼
│    INSTANCE POOL     │                                      │
┼──────────────────────┼──────────────────────────────────────┼
│ ID                   │ 8fa38a23-4891-4868-b39b-f55a7fe567fb │
│ Name                 │ my-pool                              │
│ Description          │                                      │
│ Instance Type        │ standard.micro                       │
│ Template             │ Linux Ubuntu 22.04 LTS 64-bit        │
│ Zone                 │ at-vie-1                             │
│ Anti-Affinity Groups │ n/a                                  │
│ Security Groups      │ n/a                                  │
│ Private Networks     │ n/a                                  │
│ Elastic IPs          │ n/a                                  │
│ IPv6                 │ false                                │
│ SSH Key              │ -                                    │
│ Size                 │ 4                                    │
│ Disk Size            │ 50 GiB                               │
│ Instance Prefix      │ pool                                 │
│ State                │ updating                             │
│ Labels               │ n/a                                  │
│ Instances            │ pool-8fa38-geuxj                     │
│                      │ pool-8fa38-czrfn                     │
│                      │ pool-8fa38-iglia                     │
│                      │ pool-8fa38-hjapn                     │
┼──────────────────────┼──────────────────────────────────────┼

@elkezza elkezza force-pushed the salehelkaza/sc-46617/cli-tf-instancepool-min-available-support branch from a08634c to e37b482 Compare September 15, 2024 22:10
@elkezza elkezza merged commit 3868b32 into master Sep 15, 2024
2 checks passed
@elkezza elkezza deleted the salehelkaza/sc-46617/cli-tf-instancepool-min-available-support branch September 15, 2024 22:19
simisoft-exo pushed a commit that referenced this pull request Sep 19, 2024
)

# Description
Added min available to both instance_pool_create.go and
instance_pool_update.go and Migrate to egoscale v3k, however, there are
some parts need to be reviewed like InstanceType in
instance_pool_update.go which I was not sure how to be correctly
implemented in egoscale v3.
## Checklist
(For exoscale contributors)

* [ ] Changelog updated (under *Unreleased* block)
* [ ] Testing

## Testing
I test to create new instance pool with min available 3 then I updated
see the bellow output of the tests:

```bash
 go run . compute instance-pool create my-pool --size 4 --min-available 3
 ✔ Creating Instance Pool "my-pool"... 24s
┼──────────────────────┼──────────────────────────────────────┼
│    INSTANCE POOL     │                                      │
┼──────────────────────┼──────────────────────────────────────┼
│ ID                   │ 9c52ad25-9898-48c1-be9a-f90ce13575c2 │
│ Name                 │ my-pool                              │
│ Description          │                                      │
│ Instance Type        │ standard.medium                      │
│ Template             │ Linux Ubuntu 22.04 LTS 64-bit        │
│ Zone                 │ at-vie-1                             │
│ Anti-Affinity Groups │ n/a                                  │
│ Security Groups      │ n/a                                  │
│ Private Networks     │ n/a                                  │
│ Elastic IPs          │ n/a                                  │
│ IPv6                 │ false                                │
│ SSH Key              │ -                                    │
│ Size                 │ 4                                    │
│ Disk Size            │ 50 GiB                               │
│ Instance Prefix      │ pool                                 │
│ State                │ scaling-up                           │
│ Labels               │ n/a                                  │
│ Instances            │ pool-9c52a-dqhmy                     │
│                      │ pool-9c52a-pkwqs                     │
│                      │ pool-9c52a-iepbx                     │
│                      │ pool-9c52a-staqe                     │
┼──────────────────────┼──────────────────────────────────────┼


 go run . compute instance-pool update my-pool --min-available 4
 ✔ Updating Instance Pool "my-pool"... 0s
┼──────────────────────┼──────────────────────────────────────┼
│    INSTANCE POOL     │                                      │
┼──────────────────────┼──────────────────────────────────────┼
│ ID                   │ 9c52ad25-9898-48c1-be9a-f90ce13575c2 │
│ Name                 │ my-pool                              │
│ Description          │                                      │
│ Instance Type        │ standard.medium                      │
│ Template             │ Linux Ubuntu 22.04 LTS 64-bit        │
│ Zone                 │ at-vie-1                             │
│ Anti-Affinity Groups │ n/a                                  │
│ Security Groups      │ n/a                                  │
│ Private Networks     │ n/a                                  │
│ Elastic IPs          │ n/a                                  │
│ IPv6                 │ false                                │
│ SSH Key              │ -                                    │
│ Size                 │ 4                                    │
│ Disk Size            │ 50 GiB                               │
│ Instance Prefix      │ pool                                 │
│ State                │ updating                             │
│ Labels               │ n/a                                  │
│ Instances            │ pool-9c52a-dqhmy                     │
│                      │ pool-9c52a-pkwqs                     │
│                      │ pool-9c52a-iepbx                     │
│                      │ pool-9c52a-staqe                     │
┼──────────────────────┼──────────────────────────────────────┼

```

---------

Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]>
Co-authored-by: Pierre-Emmanuel Jacquier <[email protected]>
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.

4 participants