-
Notifications
You must be signed in to change notification settings - Fork 15
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
janus_cli
: automatically discover datastore keys
#448
janus_cli
: automatically discover datastore keys
#448
Conversation
janus_server/src/bin/janus_cli.rs
Outdated
long, | ||
env = "SECRETS_K8S_NAMESPACE", | ||
takes_value = true, | ||
long_help = "Kubernetes namespace where datastore keyis stored. Required if \ |
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.
nit: typo
long_help = "Kubernetes namespace where datastore keyis stored. Required if \ | |
long_help = "Kubernetes namespace where the datastore key is stored. Required if \ |
51c3485
to
18433ef
Compare
janus_server/src/bin/janus_cli.rs
Outdated
let k8s_client = kube::Client::try_default() | ||
.await | ||
.context("couldn't connect to Kubernetes environment")?; |
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.
With janus_cli decode-dap-message
on the way, we should avoid constructing this client unless it is required by the subcommand, so that write-schema
and decode-dap-message
can be used on systems without kubeconfig files. once_cell::unsync::Lazy
would be a convenient way to do so without duplication.
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.
+1, we should maintain that we don't access/connect to dependencies that are not used for the particular subcommand.
janus_server/src/bin/janus_cli.rs
Outdated
let k8s_client = kube::Client::try_default() | ||
.await | ||
.context("couldn't connect to Kubernetes environment")?; |
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.
+1, we should maintain that we don't access/connect to dependencies that are not used for the particular subcommand.
Downgrading to draft while I re-work the argument handling here and in #450 |
2ca4a34
to
411c870
Compare
|
janus_server/src/bin/janus_cli.rs
Outdated
let kube_client = kube::Client::try_default() | ||
.await | ||
.context("couldn't connect to Kubernetes environment")?; | ||
|
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 need to defer this, and only run it inside the commands that require it. Otherwise, we may get the following error when it's not necessary.
Error: couldn't connect to Kubernetes environment
Caused by:
0: Failed to infer configuration: failed to infer config: in-cluster: (failed to read the default namespace: No such file or directory (os error 2)), kubeconfig: (failed to read kubeconfig from '"/root/.kube/config"': No such file or directory (os error 2))
1: failed to infer config: in-cluster: (failed to read the default namespace: No such file or directory (os error 2)), kubeconfig: (failed to read kubeconfig from '"/root/.kube/config"': No such file or directory (os error 2))
2: failed to read kubeconfig from '"/root/.kube/config"': No such file or directory (os error 2)
3: No such file or directory (os error 2)
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.
Whoops, I was sure I had caught this, but I think I got mixed up while rebasing.
In order to provision tasks, `janus_cli` needs the datastore key, used encrypt some database rows. This key can be provided with `--datastore-keys`, but since `janus_cli` has to talk to a Kubernetes cluster anyway, it can also fetch the secret value from Kubernetes secrets, which is fewer steps for an operator (no need to fetch the secret before running `janus_cli`) and less risk of exposing the datastore key to an operator workstation (or worse, an operator's clipboard). Resolves #409
Add a doctest for `janus_server::config::CommonConfig` with a minimal example. This is principally useful so I can copy-paste this into a config file for `janus_cli`.
When `janus_cli` provisions a task, it first deletes any task with the provided `TaskId`, and ignores the error if it is "Not Found". But if the `delete_task` method is annotated with `#[tracing::instrument(err)]`, then you get a big, scary level=ERROR line printed in RED to the console when `janus_cli` is run, even though the error is benign. Remove the annotation to avoid operators incorrectly thinking something has gone wrong.
14d1f6a
to
e1348ed
Compare
Another day, another PR merged to the wrong target. |
In order to provision tasks,
janus_cli
needs the datastore key, usedencrypt some database rows. This key can be provided with
--datastore-keys
, but sincejanus_cli
has to talk to a Kubernetescluster anyway, it can also fetch the secret value from Kubernetes
secrets, which is fewer steps for an operator (no need to fetch the
secret before running
janus_cli
) and less risk of exposing thedatastore key to an operator workstation (or worse, an operator's
clipboard).