Closed mnr closed 1 year ago
Originally posted to @meztez in plumberDeploy repo. @ghstreamline suggests posting here.
Hi @mnr ! Thanks for reporting. Are you trying to add a key to a droplet?
I don't believe I've created a droplet just yet. I'm just trying to set up to deploy a plumber instance. I'm following the procedure outlined at https://github.com/meztez/plumberDeploy. Step three is to configure an ssh key for the Digital Ocean account using analogsea::key_create.
Step 4 is to use analogsea::droplets()
- but I haven't gotten there yet.
hi @mnr just to be triple sure, did you add your public ssh key to the project you are working with on digitalocean? can you please send me a minimal example of what you did?
I have not set up an SSH key with digital ocean. let me try that first, then see if things change.
In the meantime, here is the code I am running. It's in R...
install.packages("plumberDeploy")
remotes::install_github("rstudio/plumber")
library(plumberDeploy)
analogsea::account()
plumbSSHKey <- analogsea::key_create("plumberSSH", readLines("~/.ssh/id_rsa.pub"))
I've set up an SSH key as detailed at https://cloud.digitalocean.com/ssh_keys. Subsequently running the above code still results in "Error: Key can't be blank"
I'm not sure if this is helpful, but analogsea::account()
produces the (redacted) result...
email: (my correct email)
E-mail verified: TRUE
UUID: (a long number/string)
Droplet limit: 10
Floating IP limit: 3
Status: active
Status message: (blank)
I've set up an SSH key as detailed at https://cloud.digitalocean.com/ssh_keys. Subsequently running the above code still results in "Error: Key can't be blank"
sorry the slow reply you can @ me (i.e. @mnr)
after inspecting this, it's something about API changes on DigitalOcean side I'll write to the people I know there to ask for more details
in the meanwhile, you can add keys here https://cloud.digitalocean.com/account/security
I too am experiencing a similar issue. I observe using the dev version of plumberDeploy from github:
k <- analogsea::key_create("PACER", readLines('C:\plumber\digitalOcean.pub'))
Error: Key can't be blank
mydrop <- plumberDeploy::do_provision()
THIS ACTION COSTS YOU MONEY!
Provisioning a new server for which you will get a bill from DigitalOcean.
Using default ssh keys: PACER
NB: This costs $0.00893 / hour until you droplet_delete() it
Waiting for create ....................................
New server key: [[deleted for purposes of this post]]
Error: Authentication with ssh server failed
lapply(analogsea::keys(), '[[', "public_key")
$PACER
[1] "ssh-rsa [[[key deleted]]Extreme\n"
I have not yet been successful and am also looking for a solution.
@mnr
sorry the long delay, you can install the development version with devtools::install_github("pachadotdev/analogsea")
I updated as suggested by @pachadotdev and now I see:
k <- analogsea::key_create("PACER", readLines('C:\\plumber\\digitalOcean.pub'))
Error: SSH Key is already in use on your account
But still observe:
> mydrop <- plumberDeploy::do_provision()
THIS ACTION COSTS YOU MONEY!
Provisioning a new server for which you will get a bill from DigitalOcean.
Using default ssh keys: PACER
NB: This costs $0.00893 / hour until you droplet_delete() it
Waiting for create ...............................
New server key: [[deleted]]
Error: Authentication with ssh server failed
I do see that when I run and squint at the pubkey printed using ssh::ssh_key_info() it does NOT match the one in the .pub file on my DO settings. Perhaps that's the culprit? If so, I'm not sure how to make sure the local key matches the one on the DO settings?
Just a quick real time update. I found the two files R was reading when it looked at ssh::ssh_key_info(). I manually went into those files and did a copy paste of the contents from the two files created by DO when I generated the SSH key. Now, this process is running and appears to be moving in a good direction so far. I'll share updates in case this is useful to others.
@hdoran hi! that is different, one thing is to add the ssh to a droplet and another is to use that ssh key for API purposes please keep us posted!
This may not be a plumberDeploy issue, but I'll ask it on this thread anyhow to see if appropriate. I have now successfully deployed on DO. Locally, I can run my API because the functions I use are in the R workspace. However, when deployed at DO I need to figure out how to also push my code to the server and this code is NOT in a package and would prefer it not be.
Here is a toy example that does not work because the function myadd() is outside the endpoint. Is there a way to push just the R code that is used in the endpoints to the DO server so the code could run?
#* Return the sum of two numbers
#* @param a The first number to add
#* @param b The second number to add
#* @get /sum
function(a, b) {
myAdd(a,b)
}
myAdd <- function(x,y){
x + y
}
sorry, my experience led me to create an internal R package just to export those functions :(
OK, I decided to build the R package and deploy. I moved the contents of the package to a public github, but it's not obvious to me how to install from that repo.
If I were just doing a regular install in R, I would use:
devtools::install_github("myname/Blog", subdir='mypackage')
I tried
analogsea::install_github_r_package(mydrop, "PACERStuff", repo = "myname/Blog/mypackage")
analogsea::install_github_r_package(mydrop, "PACERStuff", repo = "https://github.com/myname/Blog/tree/master/mypackage")
Neither of which ends up installing the package at DO. Any obvious errors in what I'm doing or suggestions to use fix this?
@hdoran you need something like
x <- droplet_create(n, region = r, size = s, image = img, wait = T)
x <- droplet(x$id)
install_github_r_package(x, "pachamaltese/eflm")
I would look at the tests for more examples https://github.com/pachadotdev/analogsea/blob/main/tests/testthat/test-droplet_actions_1.R
This was successful to resolve installing from github. API is now live and hosted. I also found it helpful that via digital ocean you can log into an R session on your droplet via its terminal to see if packages load there as expected for some debugging.
System details
Output of
sessioninfo::session_info()()
:Example application or steps to reproduce the problem
install plumber deploy
install.packages("plumberDeploy")
I also tried...remotes::install_github("rstudio/plumber")
then...library(plumberDeploy)
analogsea::account() # validate
plumbSSHKey <- analogsea::key_create("plumberSSH", readLines("~/.ssh/id_rsa.pub"))
which results in .... Error: Key can't be blank
I've confirmed
readLines("~/.ssh/id_rsa.pub")
returns a valid SSH keyDescribe the problem in detail
Trying to create an SSH key results in error: key can't be blank