remove Config CRD's BackupStorageProvider & other obsolete code
Signed-off-by: Steve Kriss <steve@heptio.com>pull/799/head
parent
bd4d97b9e4
commit
6f7bfe545d
|
@ -40,11 +40,6 @@ type Config struct {
|
|||
// PersistentVolumeProvider is the configuration information for the cloud where
|
||||
// the cluster is running and has PersistentVolumes to snapshot or restore. Optional.
|
||||
PersistentVolumeProvider *CloudProviderConfig `json:"persistentVolumeProvider"`
|
||||
|
||||
// BackupStorageProvider is the configuration information for the cloud where
|
||||
// Ark backups are stored in object storage. This may be a different cloud than
|
||||
// where the cluster is running.
|
||||
BackupStorageProvider ObjectStorageProviderConfig `json:"backupStorageProvider"`
|
||||
}
|
||||
|
||||
// CloudProviderConfig is configuration information about how to connect
|
||||
|
@ -54,21 +49,3 @@ type CloudProviderConfig struct {
|
|||
|
||||
Config map[string]string `json:"config"`
|
||||
}
|
||||
|
||||
// ObjectStorageProviderConfig is configuration information for connecting to
|
||||
// a particular bucket in object storage to access Ark backups.
|
||||
type ObjectStorageProviderConfig struct {
|
||||
// CloudProviderConfig is the configuration information for the cloud where
|
||||
// Ark backups are stored in object storage.
|
||||
CloudProviderConfig `json:",inline"`
|
||||
|
||||
// Bucket is the name of the bucket in object storage where Ark backups
|
||||
// are stored.
|
||||
Bucket string `json:"bucket"`
|
||||
|
||||
// ResticLocation is the bucket and optional prefix in object storage where
|
||||
// Ark stores restic backups of pod volumes, specified either as "bucket" or
|
||||
// "bucket/prefix". This bucket must be different than the `Bucket` field.
|
||||
// Optional.
|
||||
ResticLocation string `json:"resticLocation"`
|
||||
}
|
||||
|
|
|
@ -439,7 +439,6 @@ func (in *Config) DeepCopyInto(out *Config) {
|
|||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
in.BackupStorageProvider.DeepCopyInto(&out.BackupStorageProvider)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -741,23 +740,6 @@ func (in *ObjectStorageLocation) DeepCopy() *ObjectStorageLocation {
|
|||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ObjectStorageProviderConfig) DeepCopyInto(out *ObjectStorageProviderConfig) {
|
||||
*out = *in
|
||||
in.CloudProviderConfig.DeepCopyInto(&out.CloudProviderConfig)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectStorageProviderConfig.
|
||||
func (in *ObjectStorageProviderConfig) DeepCopy() *ObjectStorageProviderConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ObjectStorageProviderConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PodVolumeBackup) DeepCopyInto(out *PodVolumeBackup) {
|
||||
*out = *in
|
||||
|
|
|
@ -166,7 +166,6 @@ type server struct {
|
|||
kubeClientConfig *rest.Config
|
||||
kubeClient kubernetes.Interface
|
||||
arkClient clientset.Interface
|
||||
objectStore cloudprovider.ObjectStore
|
||||
blockStore cloudprovider.BlockStore
|
||||
discoveryClient discovery.DiscoveryInterface
|
||||
discoveryHelper arkdiscovery.Helper
|
||||
|
@ -274,12 +273,6 @@ func (s *server) run() error {
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
objectStore, err := getObjectStore(config.BackupStorageProvider.CloudProviderConfig, s.pluginManager)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.objectStore = objectStore
|
||||
|
||||
if config.PersistentVolumeProvider == nil {
|
||||
s.logger.Info("PersistentVolumeProvider config not provided, volume snapshots and restores are disabled")
|
||||
} else {
|
||||
|
@ -319,15 +312,6 @@ func (s *server) applyConfigDefaults(c *api.Config) {
|
|||
} else {
|
||||
s.logger.WithField("priorities", s.config.restoreResourcePriorities).Info("Using given resource priorities")
|
||||
}
|
||||
|
||||
if c.BackupStorageProvider.Config == nil {
|
||||
c.BackupStorageProvider.Config = make(map[string]string)
|
||||
}
|
||||
|
||||
// add the bucket name to the config map so that object stores can use
|
||||
// it when initializing. The AWS object store uses this to determine the
|
||||
// bucket's region when setting up its client.
|
||||
c.BackupStorageProvider.Config["bucket"] = c.BackupStorageProvider.Bucket
|
||||
}
|
||||
|
||||
// namespaceExists returns nil if namespace can be successfully
|
||||
|
@ -487,23 +471,6 @@ func (s *server) watchConfig(config *api.Config) {
|
|||
})
|
||||
}
|
||||
|
||||
func getObjectStore(cloudConfig api.CloudProviderConfig, manager plugin.Manager) (cloudprovider.ObjectStore, error) {
|
||||
if cloudConfig.Name == "" {
|
||||
return nil, errors.New("object storage provider name must not be empty")
|
||||
}
|
||||
|
||||
objectStore, err := manager.GetObjectStore(cloudConfig.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := objectStore.Init(cloudConfig.Config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return objectStore, nil
|
||||
}
|
||||
|
||||
func getBlockStore(cloudConfig api.CloudProviderConfig, manager plugin.Manager) (cloudprovider.BlockStore, error) {
|
||||
if cloudConfig.Name == "" {
|
||||
return nil, errors.New("block storage provider name must not be empty")
|
||||
|
|
|
@ -460,24 +460,6 @@ func (controller *backupController) runBackup(backup *api.Backup, backupLocation
|
|||
}
|
||||
|
||||
// TODO(ncdc): move this to a better location that isn't backup specific
|
||||
func getObjectStore(cloudConfig api.CloudProviderConfig, manager plugin.Manager) (cloudprovider.ObjectStore, error) {
|
||||
if cloudConfig.Name == "" {
|
||||
return nil, errors.New("object storage provider name must not be empty")
|
||||
}
|
||||
|
||||
objectStore, err := manager.GetObjectStore(cloudConfig.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := objectStore.Init(cloudConfig.Config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return objectStore, nil
|
||||
}
|
||||
|
||||
// TODO(nrb): Consolidate with other implementations
|
||||
func getObjectStoreForLocation(location *api.BackupStorageLocation, manager plugin.Manager) (cloudprovider.ObjectStore, error) {
|
||||
if location.Spec.Provider == "" {
|
||||
return nil, errors.New("backup storage location provider name must not be empty")
|
||||
|
@ -488,6 +470,16 @@ func getObjectStoreForLocation(location *api.BackupStorageLocation, manager plug
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// add the bucket name to the config map so that object stores can use
|
||||
// it when initializing. The AWS object store uses this to determine the
|
||||
// bucket's region when setting up its client.
|
||||
if location.Spec.ObjectStorage != nil {
|
||||
if location.Spec.Config == nil {
|
||||
location.Spec.Config = make(map[string]string)
|
||||
}
|
||||
location.Spec.Config["bucket"] = location.Spec.ObjectStorage.Bucket
|
||||
}
|
||||
|
||||
if err := objectStore.Init(location.Spec.Config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -17,83 +17,19 @@ limitations under the License.
|
|||
package install
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
arkv1 "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
)
|
||||
|
||||
type arkConfigOption func(*arkConfig)
|
||||
|
||||
type arkConfig struct {
|
||||
backupSyncPeriod time.Duration
|
||||
gcSyncPeriod time.Duration
|
||||
podVolumeOperationTimeout time.Duration
|
||||
restoreOnly bool
|
||||
resticLocation string
|
||||
}
|
||||
|
||||
func WithBackupSyncPeriod(t time.Duration) arkConfigOption {
|
||||
return func(c *arkConfig) {
|
||||
c.backupSyncPeriod = t
|
||||
}
|
||||
}
|
||||
|
||||
func WithGCSyncPeriod(t time.Duration) arkConfigOption {
|
||||
return func(c *arkConfig) {
|
||||
c.gcSyncPeriod = t
|
||||
}
|
||||
}
|
||||
|
||||
func WithPodVolumeOperationTimeout(t time.Duration) arkConfigOption {
|
||||
return func(c *arkConfig) {
|
||||
c.podVolumeOperationTimeout = t
|
||||
}
|
||||
}
|
||||
|
||||
func WithRestoreOnly() arkConfigOption {
|
||||
return func(c *arkConfig) {
|
||||
c.restoreOnly = true
|
||||
}
|
||||
}
|
||||
|
||||
func WithResticLocation(location string) arkConfigOption {
|
||||
return func(c *arkConfig) {
|
||||
c.resticLocation = location
|
||||
}
|
||||
}
|
||||
|
||||
func Config(
|
||||
namespace string,
|
||||
pvCloudProviderName string,
|
||||
pvCloudProviderConfig map[string]string,
|
||||
backupCloudProviderName string,
|
||||
backupCloudProviderConfig map[string]string,
|
||||
bucket string,
|
||||
opts ...arkConfigOption,
|
||||
) *arkv1.Config {
|
||||
c := &arkConfig{
|
||||
backupSyncPeriod: 30 * time.Minute,
|
||||
gcSyncPeriod: 30 * time.Minute,
|
||||
podVolumeOperationTimeout: 60 * time.Minute,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
|
||||
return &arkv1.Config{
|
||||
ObjectMeta: objectMeta(namespace, "default"),
|
||||
PersistentVolumeProvider: &arkv1.CloudProviderConfig{
|
||||
Name: pvCloudProviderName,
|
||||
Config: pvCloudProviderConfig,
|
||||
},
|
||||
BackupStorageProvider: arkv1.ObjectStorageProviderConfig{
|
||||
CloudProviderConfig: arkv1.CloudProviderConfig{
|
||||
Name: backupCloudProviderName,
|
||||
Config: backupCloudProviderConfig,
|
||||
},
|
||||
Bucket: bucket,
|
||||
ResticLocation: c.resticLocation,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue