cloudyr / googleComputeEngineR

An R interface to the Google Cloud Compute API, for launching virtual machines
https://cloudyr.github.io/googleComputeEngineR/
Other
152 stars 41 forks source link

Bad Zone can mess up getting GCE instance #180

Open muschellij2 opened 3 years ago

muschellij2 commented 3 years ago

Describe the bug I accidentally sent a bad zone and gce_get_instance didn't fail. This affects gce_vm in the error catching. It didn't cause an error. It errors only when you go to show the object:

token = gargle::credentials_gce()
googleAuthR::gar_auth(token = token, cache = FALSE)
#> ℹ 2021-09-01 23:08:03 > Setting client.id from options(googleAuthR.client_id)
x = googleComputeEngineR::gce_get_instance("blah", 
                                           project = "MYPROJECT",
                                           "us-east4-c#/bin/bash")
x
#> ==Google Compute Engine Instance==
#> 
#> Name:                us-east4-c
#> Created:             1969-12-31 16:00:00
#> Error in basename(x$machineType): a character vector argument expected

Created on 2021-09-01 by the reprex package (v2.0.0)

MarkEdmondson1234 commented 3 years ago

The print out error is a cosmetic bug via print S3 method here:

https://github.com/cloudyr/googleComputeEngineR/blob/77367894333373932b3dcb54568b4bd2fbee9592/R/print-methods.R#L41-L53

The instance object itself will still be valid if you view it via str() - but it should also make sure the zone is valid - I guess if the API didn't error it ignroed it?

muschellij2 commented 3 years ago

Yeah the error is spurious, it’s the underlying call that is problematic and surprising it doesn’t return an error message. I added some validation in my Frankenstein PR.

On Thu, Sep 2, 2021 at 4:36 AM Mark @.***> wrote:

The print out error is only the print S3 method here:

https://github.com/cloudyr/googleComputeEngineR/blob/77367894333373932b3dcb54568b4bd2fbee9592/R/print-methods.R#L41-L53

The instance object itself will still be valid if you view it via str() - but it should also make sure the zone is valid - I guess if the API didn't error it ignroed it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cloudyr/googleComputeEngineR/issues/180#issuecomment-911390312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIGPLSXWB6OZXPO2XWUIMDT74ZRJANCNFSM5DHTFXMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Best, John