Skip to content

Commit

Permalink
Switch to managing ETCDSnapshotFile resources
Browse files Browse the repository at this point in the history
Reconcile snapshot CRs instead of ConfigMap; manage ConfigMap downstream from CR list

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
  • Loading branch information
brandond committed Oct 12, 2023
1 parent 5cd4f69 commit 550ab36
Show file tree
Hide file tree
Showing 4 changed files with 681 additions and 211 deletions.
1 change: 1 addition & 0 deletions pkg/etcd/etcd.go
Expand Up @@ -576,6 +576,7 @@ func (e *ETCD) Register(handler http.Handler) (http.Handler, error) {
e.config.Runtime.LeaderElectedClusterControllerStarts[version.Program+"-etcd"] = func(ctx context.Context) {
registerEndpointsHandlers(ctx, e)
registerMemberHandlers(ctx, e)
registerSnapshotHandlers(ctx, e)
}
}

Expand Down
7 changes: 5 additions & 2 deletions pkg/etcd/s3.go
Expand Up @@ -144,6 +144,7 @@ func (s *S3) upload(ctx context.Context, snapshot string, extraMetadata *v1.Conf
},
Compressed: strings.HasSuffix(snapshot, compressedExtension),
metadataSource: extraMetadata,
nodeSource: s.nodeName,
}

uploadInfo, err := s.uploadSnapshot(ctx, snapshotKey, snapshot)
Expand Down Expand Up @@ -338,8 +339,9 @@ func (s *S3) listSnapshots(ctx context.Context) (map[string]snapshotFile, error)
defer cancel()

opts := minio.ListObjectsOptions{
Prefix: s.config.EtcdS3Folder,
Recursive: true,
Prefix: s.config.EtcdS3Folder,
Recursive: true,
WithMetadata: true,
}

objects := s.client.ListObjects(ctx, s.config.EtcdS3BucketName, opts)
Expand Down Expand Up @@ -389,6 +391,7 @@ func (s *S3) listSnapshots(ctx context.Context) (map[string]snapshotFile, error)
},
Status: successfulSnapshotStatus,
Compressed: compressed,
nodeSource: obj.UserMetadata[nodeNameKey],
}
sfKey := generateSnapshotConfigMapKey(sf)
snapshots[sfKey] = sf
Expand Down

0 comments on commit 550ab36

Please sign in to comment.