-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Move etcd snapshot management CLI to request/response #9816
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9816 +/- ##
==========================================
- Coverage 52.67% 42.94% -9.73%
==========================================
Files 157 158 +1
Lines 13822 13991 +169
==========================================
- Hits 7281 6009 -1272
- Misses 5155 6842 +1687
+ Partials 1386 1140 -246
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
8b9ad2b
to
763b691
Compare
763b691
to
745b1d0
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.
Generally LGTM, some random questions on my end.
} | ||
} | ||
|
||
func sendSnapshotResponse(rw http.ResponseWriter, req *http.Request, sr *managed.SnapshotResult) { |
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.
I assume we are sending the full error back to the client on failure, we don't try and hide it like secrets-encryption?
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.
Many errors are probably just returned as-is at the moment. Let me take a look at whether or not that exposes anything.
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 should be fine, but if you want to obfuscate you may find https://github.com/k3s-io/k3s/blob/master/pkg/server/secrets-encrypt.go#L471 helpful as it makes grepping logs alot easier for the user.
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.
I refactored this a bit. Most that indicate problems with the input from the user are still passed through with minimal information, while others just send a more generic message with error ID. For example:
root@k3s-server-1:~# k3s etcd-snapshot save
INFO[0000] Snapshot on-demand-k3s-server-1-1712288593 saved.
root@k3s-server-1:~# k3s etcd-snapshot save --etcd-s3
FATA[0000] see server log for details: s3 bucket name was not set
root@k3s-server-1:~# k3s etcd-snapshot save --etcd-s3 --etcd-s3-bucket foo
FATA[0001] see server log for details: failed to test for existence of bucket foo: 401 Unauthorized
root@k3s-server-1:~# k3s etcd-snapshot save --etcd-snapshot-dir /foo
FATA[0000] see server log for details: Internal error occurred: etcd-snapshot error ID 18952
ERRO[0193] etcd-snapshot error ID 18952: failed to get etcd-snapshot-dir: stat /foo: no such file or directory
ERRO[0193] Sending HTTP 500 response to 127.0.0.1:36124: etcd-snapshot error ID 18952
fde406e
to
e731900
Compare
Signed-off-by: Brad Davidson <[email protected]>
e731900
to
3056aa2
Compare
Confirmation that this works on an ipv6-only node: root@systemd-node-1:/# ip addr show eth0
1880: eth0@if1881: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:08 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fd7c:53a5:aef5::242:ac11:8/64 scope global nodad
valid_lft forever preferred_lft forever
inet6 fe80::42:acff:fe11:8/64 scope link
valid_lft forever preferred_lft forever
root@systemd-node-1:/# kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
systemd-node-1 Ready control-plane,etcd,master 109m v1.29.3+k3s-1a9615a7 fd7c:53a5:aef5::242:ac11:8 <none> openSUSE Leap 15.4 6.6.0-1001-aws containerd://1.7.11-k3s2
root@systemd-node-1:/# k3s etcd-snapshot save
WARN[0000] Unknown flag --node-ip found in config.yaml, skipping
WARN[0000] Unknown flag --cluster-cidr found in config.yaml, skipping
WARN[0000] Unknown flag --service-cidr found in config.yaml, skipping
WARN[0000] Unknown flag --system-default-registry found in config.yaml, skipping
WARN[0000] Unknown flag --disable found in config.yaml, skipping
WARN[0000] Unknown flag --cluster-init found in config.yaml, skipping
INFO[0000] Snapshot on-demand-systemd-node-1-1712700964 saved. |
The output of `k3s etcd-snapshot ls` has been changed with k3s-io/k3s#9816. Signed-off-by: Volker Theile <[email protected]>
The output of `k3s etcd-snapshot ls` has been changed with k3s-io/k3s#9816. To avoid incompatibilities with older installations, these will be upgraded to K3S v1.29.4+k3s1. New installations will use this version as default. This version is now kept as the default as long as no upgrade to an existing version is necessary. Users can adjust this as required and under their own responsibility via the environment variable `OMV_K8S_K3S_VERSION`. Signed-off-by: Volker Theile <[email protected]>
The output of `k3s etcd-snapshot ls` has been changed with k3s-io/k3s#9816. To avoid incompatibilities with older installations, these will be upgraded to K3S v1.29.4+k3s1. New installations will use this version as default. This version is now kept as the default as long as no upgrade to an existing version is necessary. Users can adjust this as required and under their own responsibility via the environment variable `OMV_K8S_K3S_VERSION`. Signed-off-by: Volker Theile <[email protected]>
The output of `k3s etcd-snapshot ls` has been changed with k3s-io/k3s#9816. To avoid incompatibilities with older installations, these will be upgraded to K3S v1.29.4+k3s1. New installations will use this version as default. This version is now kept as the default as long as no upgrade to an existing version is necessary. Users can adjust this as required and under their own responsibility via the environment variable `OMV_K8S_K3S_VERSION`. Signed-off-by: Volker Theile <[email protected]>
Proposed Changes
Moves
etcd-snapshot
commands over to a request/response process, similar to howsecrets-encrypt
andcertificate rotate-ca
work. Benefits of this include:We were having issues with config passed as server args not being visible to the etcd-snapshot cli, for example cluster/service cidr, node name, and so on.
It does slightly reduce the feedback available via the CLI when taking a snapshot, as the actual operation is now completed server-side, the client is just sent back a list of snapshots or an error.
etcd-snapshot save/prune/delete
now only output either a short error message, or the name of the created/deleted snapshotsetcd-snapshot list
has changedetcd-snapshot list
is identicalRancher CAPR only uses the text format output of
etcd-snapshot save
so this should be fine:Example CLI output:
Example server logs when a generic error with ID is sent:
Types of Changes
bugfix/enhancement
Verification
See linked issue
Testing
Linked Issues
User-Facing Change
Further Comments