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
4a3f0e49
Commit
4a3f0e49
authored
Sep 28, 2020
by
Brad Davidson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert removal of EndpointName hooks (#2319)
* Revert "Remove dead EndpointName code" This reverts commit
8025da5a
. * Fix docstrings based on proper understanding of use
parent
22f57cd8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
managed.go
pkg/cluster/managed.go
+24
-2
No files found.
pkg/cluster/managed.go
View file @
4a3f0e49
...
@@ -6,9 +6,11 @@ package cluster
...
@@ -6,9 +6,11 @@ package cluster
import
(
import
(
"context"
"context"
"net/http"
"net/http"
"strings"
"time"
"time"
"github.com/rancher/k3s/pkg/cluster/managed"
"github.com/rancher/k3s/pkg/cluster/managed"
"github.com/rancher/kine/pkg/endpoint"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)
)
...
@@ -62,11 +64,21 @@ func (c *Cluster) initClusterDB(ctx context.Context, handler http.Handler) (http
...
@@ -62,11 +64,21 @@ func (c *Cluster) initClusterDB(ctx context.Context, handler http.Handler) (http
return
handler
,
nil
return
handler
,
nil
}
}
if
!
strings
.
HasPrefix
(
c
.
config
.
Datastore
.
Endpoint
,
c
.
managedDB
.
EndpointName
()
+
"://"
)
{
c
.
config
.
Datastore
=
endpoint
.
Config
{
Endpoint
:
c
.
managedDB
.
EndpointName
(),
}
}
return
c
.
managedDB
.
Register
(
ctx
,
c
.
config
,
handler
)
return
c
.
managedDB
.
Register
(
ctx
,
c
.
config
,
handler
)
}
}
// assignManagedDriver checks to see if any managed databases are already configured or should be created/joined.
// assignManagedDriver assigns a driver based on a number of different configuration variables.
// If a driver has been initialized it is used, otherwise we create or join a cluster using the default driver.
// If a driver has been initialized it is used.
// If the configured endpoint matches the name of a driver, that driver is used.
// If no specific endpoint has been requested and creating or joining has been requested,
// we use the default driver.
// If none of the above are true, no managed driver is assigned.
func
(
c
*
Cluster
)
assignManagedDriver
(
ctx
context
.
Context
)
error
{
func
(
c
*
Cluster
)
assignManagedDriver
(
ctx
context
.
Context
)
error
{
// Check all managed drivers for an initialized database on disk; use one if found
// Check all managed drivers for an initialized database on disk; use one if found
for
_
,
driver
:=
range
managed
.
Registered
()
{
for
_
,
driver
:=
range
managed
.
Registered
()
{
...
@@ -78,6 +90,16 @@ func (c *Cluster) assignManagedDriver(ctx context.Context) error {
...
@@ -78,6 +90,16 @@ func (c *Cluster) assignManagedDriver(ctx context.Context) error {
}
}
}
}
// This is needed to allow downstreams to override driver selection logic by
// setting ServerConfig.Datastore.Endpoint such that it will match a driver's EndpointName
endpointType
:=
strings
.
SplitN
(
c
.
config
.
Datastore
.
Endpoint
,
":"
,
2
)[
0
]
for
_
,
driver
:=
range
managed
.
Registered
()
{
if
endpointType
==
driver
.
EndpointName
()
{
c
.
managedDB
=
driver
return
nil
}
}
// If we have been asked to initialize or join a cluster, do so using the default managed database.
// If we have been asked to initialize or join a cluster, do so using the default managed database.
if
c
.
config
.
Datastore
.
Endpoint
==
""
&&
(
c
.
config
.
ClusterInit
||
(
c
.
config
.
Token
!=
""
&&
c
.
config
.
JoinURL
!=
""
))
{
if
c
.
config
.
Datastore
.
Endpoint
==
""
&&
(
c
.
config
.
ClusterInit
||
(
c
.
config
.
Token
!=
""
&&
c
.
config
.
JoinURL
!=
""
))
{
for
_
,
driver
:=
range
managed
.
Registered
()
{
for
_
,
driver
:=
range
managed
.
Registered
()
{
...
...
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