-
Notifications
You must be signed in to change notification settings - Fork 46
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
Updated metal-go client for sub-command devices #282
Conversation
3d237d1
to
6ad1f80
Compare
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.
It's going to take some time to test these changes, but in the meantime I had a couple minor comments
05c6baf
to
dad5716
Compare
7681a36
to
23f26f8
Compare
internal/devices/update.go
Outdated
} | ||
|
||
if alwaysPXE { | ||
req.AlwaysPXE = &alwaysPXE | ||
deviceUpdate.AlwaysPxe = &alwaysPXE |
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.
Let's address #257 while we are here.
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.
@Vasubabu attempted to address this, but it's not as simple as removing the if alwaysPXE
check, because sending a value for alwaysPxe
causes a 422 error for some OSes. I think we would have to change how the command-line parameter is defined so that we have 3 states:
- unset
- false
- true
I see that cobra has a Changed
method on flags, but I'm not sure if we can get to it in the current implementation of this command. Assuming all of the above is accurate, I think we should address #257 in a separate PR.
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.
plan to address in a seperate PR. closing the thread.
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.
It's addressed in latest commit
} | ||
device, _, Err := c.Service.FindDeviceById(context.Background(), id).Execute() | ||
if Err != nil { | ||
fmt.Printf("Error when calling `DevicesApiService.FindDeviceByID``: %v\n", Err) |
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.
We shouldn't need to load the device here; the API will default to the existing operating system if one is not specified in the action.
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.
^^ just boosting this comment from earlier in case it was missed.
t.Error(err) | ||
} | ||
} else { | ||
t.Error(err) |
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.
Latest test run failed here with:
device_get_test.go:77: <nil>
It looks like we need a couple things:
CreateTestDevice
should return a non-nil error if the device is still not active after the retry loop is done- We probably need a longer wait time for the device to become active.
// Sleep for the specified interval | ||
time.Sleep(retryInterval) | ||
} | ||
return false, err |
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.
This is returning a nil error. It should return something that indicates that the time ran out.
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.
There are a few unaddressed comments but nothing that impacts functionality, and I think it'll be easier to address those in smaller PRs as needed. Confirmed locally that the reinstall test passes with the longer timeout; we won't be able to confirm in CI until after the workflow file change is merged.
The end-to-end tests for #282 are failing because the tests were moved to nested directories. This updates the e2e test workflow to not care about how the tests are laid out within the test/e2e directory so that we can move things around freely.
Breakout from #270 What this PR does / why we need it: This PR replaces packngo with metal-go for all interactions with the Equinix Metal API specifically for Device sub commands Test Results: ================ # Retrieve ## Cmd: metal devices get * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` * Metal-Go ``` vasu@vasu-cloud:~/Equinix$ metal devices get +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` ## Cmd: metal devices get -p <Project_ID> * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get -p 65dcd8f4-abd4-4e7a-8b29-da4b030edd96 +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01T08:42:42Z | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25T12:33:17Z | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01T08:43:12Z | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03T09:42:52Z | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:01Z | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:05Z | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03T09:47:59Z | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03T09:48:00Z | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03T09:54:11Z | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24T18:24:15Z | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24T18:24:12Z | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24T18:22:35Z | +--------------------------------------+-------------------------------------+------------------+--------+----------------------+ ``` * Metal-Go ``` vasu@vasu-cloud:~/Equinix/metal-cli/bin$ ./metal devices get -p 65dcd8f4-abd4-4e7a-8b29-da4b030edd96 +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ | d231a5d0-3da9-4e4b-bbd6-a367c4c2d34b | test-staging-2 | Ubuntu 20.04 LTS | active | 2023-06-01 08:42:42 +0000 UTC | | bcab4df0-945e-4cb5-a8c7-f9dfbaabb3d7 | eksa-node-003 | Custom iPXE | active | 2023-04-25 12:33:17 +0000 UTC | | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26 13:09:24 +0000 UTC | | b396c4fd-c412-4a25-b6b4-df6f2f548629 | test-staging-12 | Ubuntu 22.04 LTS | active | 2023-06-01 08:43:12 +0000 UTC | | bad6f156-4777-49a5-87e7-d038e7365c9e | capi-quickstart-control-plane-mkz7l | Ubuntu 22.04 LTS | active | 2023-05-03 09:42:52 +0000 UTC | | d7126b67-a96f-48b7-9cf1-e1914d84235b | capi-quickstart-worker-a-spr64 | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:01 +0000 UTC | | 4c397b2d-eccf-4948-9fcf-2b325303048c | capi-quickstart-control-plane-98xjq | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:05 +0000 UTC | | bdbe09fa-d140-4cc9-b988-f51610e8c2f3 | capi-quickstart-worker-a-q89f8 | Ubuntu 22.04 LTS | active | 2023-05-03 09:47:59 +0000 UTC | | 67992861-066b-4d76-a6a4-a21b3e855722 | capi-quickstart-worker-a-qqnhb | Ubuntu 22.04 LTS | active | 2023-05-03 09:48:00 +0000 UTC | | b15870cd-a83d-48bd-9552-5281162ae563 | capi-quickstart-control-plane-lxnsr | Ubuntu 22.04 LTS | active | 2023-05-03 09:54:11 +0000 UTC | | 2f6d7ff2-6aa5-49bc-838a-97a3473ea16a | eksa-node-002 | Custom iPXE | active | 2023-04-24 18:24:15 +0000 UTC | | 46005014-5256-41b3-938a-1b295f931aa2 | eksa-node-001 | Custom iPXE | active | 2023-04-24 18:24:12 +0000 UTC | | c3b1006c-0422-4f01-9c96-24dbcd72f7f1 | eksa-admin | Ubuntu 20.04 LTS | active | 2023-04-24 18:22:35 +0000 UTC | +--------------------------------------+-------------------------------------+------------------+--------+-------------------------------+ ``` ## Cmd: metal devices get -i <Device ID> * Packngo: ``` vasu@vasu-cloud:~/Equinix$ metal devices get -i 09be98b7-0db6-4fdb-90be-901ab847158d +--------------------------------------+--------------+------------------+--------+----------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+--------------+------------------+--------+----------------------+ | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26T13:09:24Z | +--------------------------------------+--------------+------------------+--------+----------------------+ ``` *Metal-go: ``` vasu@vasu-cloud:~/Equinix/metal-cli/bin$ ./metal devices get -i 09be98b7-0db6-4fdb-90be-901ab847158d +--------------------------------------+--------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+--------------+------------------+--------+-------------------------------+ | 09be98b7-0db6-4fdb-90be-901ab847158d | test-packngo | Ubuntu 20.04 LTS | active | 2023-06-26 13:09:24 +0000 UTC | +--------------------------------------+--------------+------------------+--------+-------------------------------+ ``` # Create ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d -P m3.small.x86 -m da -O ubuntu_20_04 -H create-device-dev-cdata --customdata '{"testDate":"fromCli"}' +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ | 8dc6920e-cf5a-4852-994d-a53094fe9673 | create-device-dev-cdata | Ubuntu 20.04 LTS | queued | 2023-08-24 10:28:29 +0000 UTC | +--------------------------------------+-------------------------+------------------+--------+-------------------------------+ Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d -P m3.small.x86 -m da -O ubuntu_20_04 -H create-dev-cdata --customdata '{"testDate":""}' +--------------------------------------+------------------+------------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+------------------+------------------+--------+-------------------------------+ | a45f8746-f3b5-4fc5-8fe6-b4fa6493d365 | create-dev-cdata | Ubuntu 20.04 LTS | queued | 2023-08-24 10:40:50 +0000 UTC | +--------------------------------------+------------------+------------------+--------+-------------------------------+ ``` ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d --hostname netboot-custom-ipxe-1 --plan c3.small.x86 --metro sv --operating-system custom_ipxe --userdata='#!ipxe chain -ar https://boot.netboot.xyz' --always-pxe=true +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ | b149fc32-bcfd-44c8-9c0e-9e5d49d382e0 | netboot-custom-ipxe-1 | Custom iPXE | queued | 2023-08-24 10:48:33 +0000 UTC | +--------------------------------------+-----------------------+-------------+--------+-------------------------------+ <img width="1430" alt="image" src="https://github.com/equinix/metal-cli/assets/3358152/ea4d5a5a-b495-40e7-a7ec-e3a6905ac5c7"> ``` ``` Vasubabus-MacBook-Pro:bin vasubabu$ ./metal device create -p c309ce2c-160d-47e2-bb26-9debeb0be87d --hostname netboot-custom-ipxe --plan c3.small.x86 --metro sv --operating-system custom_ipxe --userdata='#!ipxe > chain -ar https://boot.netboot.xyz' +--------------------------------------+---------------------+-------------+--------+-------------------------------+ | ID | HOSTNAME | OS | STATE | CREATED | +--------------------------------------+---------------------+-------------+--------+-------------------------------+ | 4aa8977b-259b-4684-a3b4-9ff49e96db47 | netboot-custom-ipxe | Custom iPXE | queued | 2023-08-24 10:44:02 +0000 UTC | +--------------------------------------+---------------------+-------------+--------+-------------------------------+ <img width="1416" alt="image" src="https://github.com/equinix/metal-cli/assets/3358152/a9ff3f36-4716-4cbd-a9be-cc2dc8e672b7"> ```
Breakout from #270
What this PR does / why we need it:
This PR replaces packngo with metal-go for all interactions with the Equinix Metal API specifically for Device sub commands
Test Results:
Retrieve
Cmd: metal devices get
Cmd: metal devices get -p <Project_ID>
Cmd: metal devices get -i
*Metal-go:
Create