Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1c0d3aaf
Commit
1c0d3aaf
authored
Nov 13, 2024
by
manuelbuil
Committed by
Brad Davidson
Jan 09, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If no etcd was deployed, fail etcd-snapshot with a useful error
Signed-off-by:
manuelbuil
<
mbuil@suse.com
>
parent
ab3818c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
managed.go
pkg/cluster/managed.go
+20
-1
snapshotrestore_test.go
tests/e2e/snapshotrestore/snapshotrestore_test.go
+0
-11
No files found.
pkg/cluster/managed.go
View file @
1c0d3aaf
...
...
@@ -11,9 +11,13 @@ import (
"os"
"time"
"github.com/pkg/errors"
"github.com/gorilla/mux"
"github.com/k3s-io/k3s/pkg/cluster/managed"
"github.com/k3s-io/k3s/pkg/etcd"
"github.com/k3s-io/k3s/pkg/nodepassword"
"github.com/k3s-io/k3s/pkg/util"
"github.com/k3s-io/k3s/pkg/version"
"github.com/sirupsen/logrus"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
...
...
@@ -96,7 +100,7 @@ func (c *Cluster) start(ctx context.Context) error {
// management of etcd cluster membership without being disrupted when a member is removed from the cluster.
func
(
c
*
Cluster
)
registerDBHandlers
(
handler
http
.
Handler
)
(
http
.
Handler
,
error
)
{
if
c
.
managedDB
==
nil
{
return
handler
,
nil
return
handler
NoEtcd
(
handler
)
,
nil
}
return
c
.
managedDB
.
Register
(
handler
)
...
...
@@ -168,3 +172,18 @@ func (c *Cluster) deleteNodePasswdSecret(ctx context.Context) {
logrus
.
Warnf
(
"failed to delete old node password secret: %v"
,
err
)
}
}
// handlerNoEtcd wraps a handler with an error message indicating that etcd is not deployed.
func
handlerNoEtcd
(
handler
http
.
Handler
)
http
.
Handler
{
r
:=
mux
.
NewRouter
()
.
SkipClean
(
true
)
// Wildcard route for anything after /db/
r
.
HandleFunc
(
"/db/{_:.*}"
,
func
(
resp
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
util
.
SendError
(
errors
.
New
(
"etcd datastore disabled"
),
resp
,
r
,
http
.
StatusBadRequest
)
})
// Needs to come at the end, otherwise wildcard routes won't work
r
.
NotFoundHandler
=
handler
return
r
}
tests/e2e/snapshotrestore/snapshotrestore_test.go
View file @
1c0d3aaf
...
...
@@ -145,17 +145,6 @@ var _ = Describe("Verify snapshots and cluster restores work", Ordered, func() {
Expect
(
e2e
.
RunCmdOnNode
(
cmd
,
serverNodeNames
[
0
]))
.
Error
()
.
NotTo
(
HaveOccurred
())
})
It
(
"Resets non bootstrap nodes"
,
func
()
{
for
_
,
nodeName
:=
range
serverNodeNames
{
if
nodeName
!=
serverNodeNames
[
0
]
{
cmd
:=
"k3s server --cluster-reset"
response
,
err
:=
e2e
.
RunCmdOnNode
(
cmd
,
nodeName
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
response
)
.
Should
(
ContainSubstring
(
"Managed etcd cluster membership has been reset, restart without --cluster-reset flag now"
))
}
}
})
It
(
"Checks that other servers are not ready"
,
func
()
{
fmt
.
Printf
(
"
\n
Fetching node status
\n
"
)
Eventually
(
func
(
g
Gomega
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment