-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support filesystem backup as well as blob store backup #1
base: 1.52.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,6 +21,7 @@ | |||||
package v1beta1 | ||||||
|
||||||
import ( | ||||||
"fmt" | ||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
) | ||||||
|
||||||
|
@@ -63,6 +64,8 @@ type FoundationDBRestoreSpec struct { | |||||
|
||||||
// This is the configuration of the target blobstore for this backup. | ||||||
BlobStoreConfiguration *BlobStoreConfiguration `json:"blobStoreConfiguration,omitempty"` | ||||||
// This is the configuration of the target filesystem for this backup. | ||||||
FSConfiguration *FSConfiguration `json:"fsConfiguration,omitempty"` | ||||||
|
||||||
// CustomParameters defines additional parameters to pass to the backup | ||||||
// agents. | ||||||
|
@@ -93,18 +96,26 @@ type FoundationDBKeyRange struct { | |||||
// BackupName gets the name of the backup for the source backup. | ||||||
// This will fill in a default value if the backup name in the spec is empty. | ||||||
func (restore *FoundationDBRestore) BackupName() string { | ||||||
if restore.Spec.BlobStoreConfiguration == nil || restore.Spec.BlobStoreConfiguration.BackupName == "" { | ||||||
return restore.ObjectMeta.Name | ||||||
|
||||||
if restore.Spec.BlobStoreConfiguration != nil && restore.Spec.BlobStoreConfiguration.BackupName != "" { | ||||||
return restore.Spec.BlobStoreConfiguration.BackupName | ||||||
} | ||||||
|
||||||
if restore.Spec.FSConfiguration != nil && restore.Spec.FSConfiguration.BackupName != "" { | ||||||
return restore.Spec.FSConfiguration.BackupName | ||||||
} | ||||||
|
||||||
return restore.Spec.BlobStoreConfiguration.BackupName | ||||||
return restore.ObjectMeta.Name | ||||||
} | ||||||
|
||||||
// BackupURL gets the destination url of the backup. | ||||||
func (restore *FoundationDBRestore) BackupURL() string { | ||||||
if restore.Spec.BlobStoreConfiguration != nil { | ||||||
return restore.Spec.BlobStoreConfiguration.getURL(restore.BackupName(), restore.Spec.BlobStoreConfiguration.BucketName()) | ||||||
} | ||||||
if restore.Spec.FSConfiguration != nil { | ||||||
return fmt.Sprintf("%s/%s", restore.Spec.FSConfiguration.URL, restore.BackupName()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is a filesystem path, you should use
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above ? |
||||||
} | ||||||
|
||||||
return restore.Spec.BackupURL | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -95,6 +95,8 @@ type FoundationDBBackupSpec struct { | |||||
|
||||||
// This is the configuration of the target blobstore for this backup. | ||||||
BlobStoreConfiguration *BlobStoreConfiguration `json:"blobStoreConfiguration,omitempty"` | ||||||
// This is the configuration of the target filesystem for this backup. | ||||||
FSConfiguration *FSConfiguration `json:"fsConfiguration,omitempty"` | ||||||
|
||||||
// MainContainer defines customization for the foundationdb container. | ||||||
MainContainer ContainerOverrides `json:"mainContainer,omitempty"` | ||||||
|
@@ -211,6 +213,19 @@ type BlobStoreConfiguration struct { | |||||
URLParameters []URLParameter `json:"urlParameters,omitempty"` | ||||||
} | ||||||
|
||||||
// FSConfiguration describes the blob store configuration. | ||||||
type FSConfiguration struct { | ||||||
// The name for the backup. | ||||||
// If empty defaults to .metadata.name. | ||||||
// +kubebuilder:validation:MaxLength=1024 | ||||||
BackupName string `json:"backupName,omitempty"` | ||||||
|
||||||
// The url to use with the backup destination. | ||||||
// +kubebuilder:validation:MaxLength=255 | ||||||
// +kubebuilder:validation:Required | ||||||
URL string `json:"url"` | ||||||
} | ||||||
|
||||||
// ShouldRun determines whether a backup should be running. | ||||||
func (backup *FoundationDBBackup) ShouldRun() bool { | ||||||
return backup.Spec.BackupState == "" || backup.Spec.BackupState == BackupStateRunning || backup.Spec.BackupState == BackupStatePaused | ||||||
|
@@ -224,7 +239,7 @@ func (backup *FoundationDBBackup) ShouldBePaused() bool { | |||||
// Bucket gets the bucket this backup will use. | ||||||
// This will fill in a default value if the bucket in the spec is empty. | ||||||
func (backup *FoundationDBBackup) Bucket() string { | ||||||
if backup.Spec.BlobStoreConfiguration.Bucket == "" { | ||||||
if backup.Spec.BlobStoreConfiguration == nil || backup.Spec.BlobStoreConfiguration.Bucket == "" { | ||||||
return "fdb-backups" | ||||||
} | ||||||
|
||||||
|
@@ -234,16 +249,27 @@ func (backup *FoundationDBBackup) Bucket() string { | |||||
// BackupName gets the name of the backup in the destination. | ||||||
// This will fill in a default value if the backup name in the spec is empty. | ||||||
func (backup *FoundationDBBackup) BackupName() string { | ||||||
if backup.Spec.BlobStoreConfiguration.BackupName == "" { | ||||||
return backup.ObjectMeta.Name | ||||||
if backup.Spec.BlobStoreConfiguration != nil && backup.Spec.BlobStoreConfiguration.BackupName != "" { | ||||||
return backup.Spec.BlobStoreConfiguration.BackupName | ||||||
} | ||||||
|
||||||
if backup.Spec.FSConfiguration != nil && backup.Spec.FSConfiguration.BackupName != "" { | ||||||
return backup.Spec.FSConfiguration.BackupName | ||||||
} | ||||||
|
||||||
return backup.Spec.BlobStoreConfiguration.BackupName | ||||||
return backup.ObjectMeta.Name | ||||||
} | ||||||
|
||||||
// BackupURL gets the destination url of the backup. | ||||||
func (backup *FoundationDBBackup) BackupURL() string { | ||||||
return backup.Spec.BlobStoreConfiguration.getURL(backup.BackupName(), backup.Bucket()) | ||||||
if backup.Spec.BlobStoreConfiguration != nil { | ||||||
return backup.Spec.BlobStoreConfiguration.getURL(backup.BackupName(), backup.Bucket()) | ||||||
} | ||||||
// mpatou: should we use file:// ? | ||||||
if backup.Spec.FSConfiguration != nil { | ||||||
return fmt.Sprintf("%s/%s", backup.Spec.FSConfiguration.URL, backup.BackupName()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is a filesystem path, you should use
Suggested change
|
||||||
} | ||||||
return "" | ||||||
} | ||||||
|
||||||
// SnapshotPeriodSeconds gets the period between snapshots for a backup. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ limitations under the License. | |
package v1beta2 | ||
|
||
import ( | ||
"fmt" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
|
@@ -55,6 +56,8 @@ type FoundationDBRestoreSpec struct { | |
|
||
// This is the configuration of the target blobstore for this backup. | ||
BlobStoreConfiguration *BlobStoreConfiguration `json:"blobStoreConfiguration,omitempty"` | ||
// This is the configuration of the target filesystem for this backup. | ||
FSConfiguration *FSConfiguration `json:"fsConfiguration,omitempty"` | ||
|
||
// CustomParameters defines additional parameters to pass to the backup | ||
// agents. | ||
|
@@ -85,16 +88,32 @@ type FoundationDBKeyRange struct { | |
// BackupName gets the name of the backup for the source backup. | ||
// This will fill in a default value if the backup name in the spec is empty. | ||
func (restore *FoundationDBRestore) BackupName() string { | ||
if restore.Spec.BlobStoreConfiguration == nil || restore.Spec.BlobStoreConfiguration.BackupName == "" { | ||
if (restore.Spec.BlobStoreConfiguration == nil || restore.Spec.BlobStoreConfiguration.BackupName == "") && (restore.Spec.FSConfiguration == nil || restore.Spec.FSConfiguration.BackupName == "") { | ||
return restore.ObjectMeta.Name | ||
} | ||
|
||
return restore.Spec.BlobStoreConfiguration.BackupName | ||
if restore.Spec.BlobStoreConfiguration != nil && restore.Spec.BlobStoreConfiguration.BackupName != "" { | ||
return restore.Spec.BlobStoreConfiguration.BackupName | ||
} | ||
|
||
if restore.Spec.FSConfiguration != nil && restore.Spec.FSConfiguration.BackupName != "" { | ||
return restore.Spec.FSConfiguration.BackupName | ||
} | ||
|
||
return "" | ||
} | ||
|
||
// BackupURL gets the destination url of the backup. | ||
func (restore *FoundationDBRestore) BackupURL() string { | ||
return restore.Spec.BlobStoreConfiguration.getURL(restore.BackupName(), restore.Spec.BlobStoreConfiguration.BucketName()) | ||
if restore.Spec.BlobStoreConfiguration != nil { | ||
return restore.Spec.BlobStoreConfiguration.getURL(restore.BackupName(), restore.Spec.BlobStoreConfiguration.BucketName()) | ||
} | ||
|
||
if restore.Spec.FSConfiguration != nil { | ||
return fmt.Sprintf("%s/%s", restore.Spec.FSConfiguration.URL, restore.BackupName()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as previous |
||
} | ||
|
||
return "" | ||
} | ||
|
||
func init() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is a filesystem path, you should use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation of
fdb
indicates that you can usefile://
I don't think it would work ?