Skip to content

Commit

Permalink
remove Config CRD's BackupStorageProvider & other obsolete code
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kriss <[email protected]>
  • Loading branch information
skriss committed Aug 28, 2018
1 parent bd4d97b commit 6f7bfe5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 156 deletions.
23 changes: 0 additions & 23 deletions pkg/apis/ark/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"`
}
18 changes: 0 additions & 18 deletions pkg/apis/ark/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
28 changes: 10 additions & 18 deletions pkg/controller/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
}
Expand Down
64 changes: 0 additions & 64 deletions pkg/install/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}

0 comments on commit 6f7bfe5

Please sign in to comment.