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

feat: change log format for runner and operator #179

Open
wants to merge 3 commits into
base: feat/configurable-disk
Choose a base branch
from

Conversation

dav1do
Copy link
Contributor

@dav1do dav1do commented May 21, 2024

You can now change the operator and runner log format. Currently you can run the binary with keramik-operator --log-format json daemon to change it. The developing_operator page includes an example.

I took the value from the operator cli and then set it globally in the process to be used by anyone. Alternatively, it could be piped through in config/specs (e.g. BootstrapSpec/BootstrapConfig) but it didn't seem like you'd want to set them differently, and having to set multiple places is a bit annoying. As we start operator logs before we start the daemon and get access to the network context, I used the command line option and a global variable. I don't love it and am open to better options, but using the network spec isn't an option as this has to happen before we start reconciling.

I thought I could get the tracing to work with just tracing_subscriber::fmt()::json() and tracing_subscriber::fmt().pretty() but I didn't get the generics right and took the example from rust-ceramic to implement format for fields/events.

It originally had multiple CLI args, but switched to using the one from telemetry every where else. I had to add clap a dependency to common, but it's not optional in the workspace currently so it didn't change anything. I did this in its own commit if we prefer the multiple args option, or if there's a better solution I'm missing.

❯ k logs keramik-operator-5cb74877b6-s55hw -n keramik
{"timestamp":"2024-05-21T02:09:03.050162Z","level":"INFO","fields":{"message":"starting operator"},"target":"keramik_operator"}
{"timestamp":"2024-05-21T02:09:26.627798Z","level":"ERROR","fields":{"message":"reconcile error","err":"ReconcilerFailed(Kube { source: Api(ErrorResponse { status: \"Failure\", message: \"pods \\\"ceramic-0-0\\\" not found\", reason: \"NotFound\", code: 404 }) }, ObjectRef { dyntype: ApiResource { group: \"keramik.3box.io\", version: \"v1alpha1\", api_version: \"keramik.3box.io/v1alpha1\", kind: \"Network\", plural: \"networks\" }, name: \"small\", namespace: None, extra: Extra { resource_version: Some(\"3787284\"), uid: Some(\"8c9199fa-b16b-4474-a6a8-c1ef88ac238f\") } })"},"target":"keramik_operator::network::controller"}
{"timestamp":"2024-05-21T02:09:26.712457Z","level":"ERROR","fields":{"message":"reconcile error","err":"ReconcilerFailed(Kube { source: Api(ErrorResponse { status: \"Failure\", message: \"pods \\\"ceramic-0-0\\\" not found\", reason: \"NotFound\", code: 404 }) }, ObjectRef { dyntype: ApiResource { group: \"keramik.3box.io\", version: \"v1alpha1\", api_version: \"keramik.3box.io/v1alpha1\", kind: \"Network\", plural: \"networks\" }, name: \"small\", namespace: None, extra: Extra { resource_version: None, uid: Some(\"8c9199fa-b16b-4474-a6a8-c1ef88ac238f\") } })"},"target":"keramik_operator::network::controller"}
{"timestamp":"2024-05-21T02:09:31.814035Z","level":"WARN","fields":{"message":"failed to get peer info for cas-ipfs","err":"error sending request for url (http://cas-ipfs-0.cas-ipfs.keramik-small.svc.cluster.local:5001/api/v0/id): error trying to connect: dns error: failed to lookup address information: Name or service not known"},"target":"keramik_operator::network::controller","span":{"object.reason":"error policy requested retry","object.ref":"Network.v1alpha1.keramik.3box.io/small","name":"reconciling object"},"spans":[{"object.reason":"error policy requested retry","object.ref":"Network.v1alpha1.keramik.3box.io/small","name":"reconciling object"}]}

@dav1do dav1do requested review from 3benbox and smrz2001 May 21, 2024 02:22
@dav1do dav1do force-pushed the feat/log-format branch from 7bca77d to 7e351dd Compare May 21, 2024 20:59
@dav1do dav1do force-pushed the feat/configurable-disk branch from 5fe0754 to 590ab39 Compare May 21, 2024 21:02
@dav1do dav1do force-pushed the feat/log-format branch 2 times, most recently from 7ce357f to 27cbef1 Compare May 21, 2024 21:06
@dav1do dav1do force-pushed the feat/configurable-disk branch from 590ab39 to b6da2b6 Compare May 21, 2024 21:08
@dav1do dav1do force-pushed the feat/log-format branch from 27cbef1 to 5fad7d8 Compare May 22, 2024 19:47
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.

1 participant