/
etcdrestore.go
50 lines (43 loc) · 1.56 KB
/
etcdrestore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cluster
import (
"context"
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/openshift/openshift-azure/pkg/api"
"github.com/openshift/openshift-azure/pkg/cluster/names"
"github.com/openshift/openshift-azure/pkg/cluster/updateblob"
)
func (u *Upgrade) EtcdListBackups(ctx context.Context) ([]storage.Blob, error) {
bsc := u.StorageClient.GetBlobService()
etcdContainer := bsc.GetContainerReference(EtcdBackupContainerName)
resp, err := etcdContainer.ListBlobs(storage.ListBlobsParameters{})
if err != nil {
return nil, err
}
blobs := make([]storage.Blob, 0, len(resp.Blobs))
for _, blob := range resp.Blobs {
blobs = append(blobs, blob)
}
return blobs, nil
}
func (u *Upgrade) EtcdRestoreDeleteMasterScaleSet(ctx context.Context) *api.PluginError {
// We may need/want to delete all the scalesets in the future
err := u.Ssc.Delete(ctx, u.Cs.Properties.AzProfile.ResourceGroup, names.MasterScalesetName)
if err != nil {
return &api.PluginError{Err: err, Step: api.PluginStepScaleSetDelete}
}
return nil
}
func (u *Upgrade) EtcdRestoreDeleteMasterScaleSetHashes(ctx context.Context) *api.PluginError {
uBlob, err := u.UpdateBlobService.Read()
if err != nil {
return &api.PluginError{Err: err, Step: api.PluginStepInitializeUpdateBlob}
}
// delete only the master entries from the blob in order to
// avoid unnecessary infra and compute rotations.
uBlob.HostnameHashes = updateblob.HostnameHashes{}
err = u.UpdateBlobService.Write(uBlob)
if err != nil {
return &api.PluginError{Err: err, Step: api.PluginStepInitializeUpdateBlob}
}
return nil
}