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
83ae76fe
Commit
83ae76fe
authored
Apr 29, 2021
by
Brian Downs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update data structure and account for possible race in start
Signed-off-by:
Brian Downs
<
brian.downs@gmail.com
>
parent
4c57fad5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
+29
-5
etcd.go
pkg/etcd/etcd.go
+29
-5
No files found.
pkg/etcd/etcd.go
View file @
83ae76fe
...
...
@@ -11,6 +11,7 @@ import (
"net/url"
"os"
"path/filepath"
"runtime"
"sort"
"strconv"
"strings"
...
...
@@ -869,6 +870,15 @@ func (e *ETCD) Snapshot(ctx context.Context, config *config.Control) error {
return
e
.
storeSnapshotData
(
ctx
,
snapshots
)
}
type
s3Config
struct
{
Endpoint
string
`json:"endpoint,omitempty"`
EndpointCA
string
`json:"endpointCA,omitempty"`
SkipSSLVerify
bool
`json:"skipSSLVerify,omitempty"`
Bucket
string
`json:"bucket,omitempty"`
Region
string
`json:"region,omitempty"`
Folder
string
`json:"folder,omitempty"`
}
// snapshotFile represents a single snapshot and it's
// metadata.
type
snapshotFile
struct
{
...
...
@@ -876,10 +886,11 @@ type snapshotFile struct {
// Location contains the full path of the snapshot. For
// local paths, the location will be prefixed with "file://"
// and for S3 will be "s3://".
Location
string
`json:"location"`
NodeName
string
`json:"nodeName"`
CreatedAt
*
metav1
.
Time
`json:"createdAt"`
Size
int64
`json:"size"`
Location
string
`json:"location,omitempty"`
NodeName
string
`json:"nodeName,omitempty"`
CreatedAt
*
metav1
.
Time
`json:"createdAt,omitempty"`
Size
int64
`json:"size,omitempty"`
S3
*
s3Config
`json:"s3Config,omitempty"`
}
// listSnapshots provides a list of the currently stored
...
...
@@ -908,12 +919,19 @@ func (e *ETCD) listSnapshots(ctx context.Context, snapshotDir string) ([]snapsho
}
snapshots
=
append
(
snapshots
,
snapshotFile
{
Name
:
obj
.
Key
,
Location
:
"s3://"
+
filepath
.
Join
(
e
.
config
.
EtcdS3BucketName
,
obj
.
Key
),
NodeName
:
nodeName
,
CreatedAt
:
&
metav1
.
Time
{
Time
:
ca
,
},
Size
:
obj
.
Size
,
S3
:
&
s3Config
{
Endpoint
:
e
.
config
.
EtcdS3Endpoint
,
EndpointCA
:
e
.
config
.
EtcdS3EndpointCA
,
SkipSSLVerify
:
e
.
config
.
EtcdS3SkipSSLVerify
,
Bucket
:
e
.
config
.
EtcdS3BucketName
,
Region
:
e
.
config
.
EtcdS3Region
,
Folder
:
e
.
config
.
EtcdS3Folder
,
},
})
}
...
...
@@ -963,6 +981,12 @@ func (e *ETCD) storeSnapshotData(ctx context.Context, snapshotFiles []snapshotFi
return
err
}
// make sure the core.Factory is initialize. There can
// be a race between this core code startup.
for
e
.
config
.
Runtime
.
Core
==
nil
{
runtime
.
Gosched
()
}
snapshotConfigMap
,
err
:=
e
.
config
.
Runtime
.
Core
.
Core
()
.
V1
()
.
ConfigMap
()
.
Get
(
metav1
.
NamespaceSystem
,
snapshotConfigMapName
,
metav1
.
GetOptions
{})
if
apierrors
.
IsNotFound
(
err
)
{
cm
:=
v1
.
ConfigMap
{
...
...
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