Skip to content

Commit

Permalink
Remote restore support for Medusa (#454)
Browse files Browse the repository at this point in the history
* Add MedusaTask API with support for purge, sync and restore prep, and implement remote restore.

The PrepareRestore grpc call will have Medusa compute the mapping between the backup and restore clusters, and store it in the local storage.
This will allow the restore init container to know which mapping should be performed, without having Cassandra up.

* Upgrade to Medusa 0.13.1
  • Loading branch information
adejanovski authored May 13, 2022
1 parent 75308d2 commit 2e6ed83
Show file tree
Hide file tree
Showing 79 changed files with 5,013 additions and 454 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/kind_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ jobs:
- CreateStargateAndDatacenter
- CreateSingleReaper
- CreateReaperAndDatacenter
- CreateSingleMedusa
- CreateSingleMedusaOld
- CreateSingleMedusaJob
- ConfigControllerRestarts
- SingleDcEncryptionWithStargate
- SingleDcEncryptionWithReaper
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/kind_multicluster_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ jobs:
- CreateMultiStargateAndDatacenter
- CreateMultiReaper
- ClusterScoped/MultiDcMultiCluster
- CreateMultiMedusa
- CreateMultiMedusaOld
- CreateMultiMedusaJob
- MultiDcAuthOnOff
- MultiDcEncryptionWithStargate
- MultiDcEncryptionWithReaper
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG/CHANGELOG-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ When cutting a new release, update the `unreleased` heading to the tag being gen

* [CHANGE] []() Update to cass-operator v1.11.0
* [CHANGE] [#310](https://github.com/k8ssandra/k8ssandra-operator/issues/310) Update to Go 1.17 and Kubernetes dependencies (incl. controller-runtime)
* [FEATURE] [#454](https://github.com/k8ssandra/k8ssandra-operator/pull/454) Remote restore support for Medusa
* [ENHANCEMENT] [#465](https://github.com/k8ssandra/k8ssandra-operator/issues/465) ⁃ Refactor config-builder JSON marshaling
* [ENHANCEMENT] [#507](https://github.com/k8ssandra/k8ssandra-operator/issues/507) Shared Cassandra cluster and datacenter fields are defined in a single struct
* [BUGFIX] [#447](https://github.com/k8ssandra/k8ssandra-operator/issues/447) Reconciliation doesn't finish when adding DC with more than 1 node
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,8 @@ gke-e2e-test:
-hostNetwork=false \
-imageName=$(GKE_IMAGE_TAG_BASE) \
-imageTag=latest"

# The protobuf compiler is required to run this target: https://grpc.io/docs/protoc-installation/
PHONY: protobuf-code-gen
protobuf-code-gen:
@protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/medusa/medusa.proto
36 changes: 36 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,40 @@ resources:
kind: CassandraRestore
path: github.com/k8ssandra/k8ssandra-operator/apis/medusa/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: k8ssandra.io
group: medusa
kind: MedusaTask
path: github.com/k8ssandra/k8ssandra-operator/apis/medusa/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: k8ssandra.io
group: medusa
kind: MedusaBackup
path: github.com/k8ssandra/k8ssandra-operator/apis/medusa/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: k8ssandra.io
group: medusa
kind: MedusaBackupJob
path: github.com/k8ssandra/k8ssandra-operator/apis/medusa/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: k8ssandra.io
group: medusa
kind: MedusaRestoreJob
path: github.com/k8ssandra/k8ssandra-operator/apis/medusa/v1alpha1
version: v1alpha1
version: "3"
12 changes: 3 additions & 9 deletions apis/medusa/v1alpha1/cassandrabackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,13 @@ package v1alpha1

import (
cassdcapi "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1"
"github.com/k8ssandra/k8ssandra-operator/pkg/shared"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// An enum of the possible modes for medusa backups
type BackupType string

const (
FullBackup BackupType = "full"
DifferentialBackup BackupType = "differential"
)

// CassandraBackupSpec defines the desired state of CassandraBackup
type CassandraBackupSpec struct {
// The name of the backup.
Expand All @@ -44,7 +37,7 @@ type CassandraBackupSpec struct {
// The type of the backup: "full" or "differential"
// +kubebuilder:validation:Enum=differential;full;
// +kubebuilder:default:=differential
Type BackupType `json:"backupType,omitempty"`
Type shared.BackupType `json:"backupType,omitempty"`
}

type CassandraDatacenterTemplateSpec struct {
Expand Down Expand Up @@ -72,6 +65,7 @@ type CassandraBackupStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:deprecatedversion:warning="medusa.k8ssandra.com/v1alpha1 CassandraBackup/CassandraRestore are deprecated, use medusa.k8ssandra.com/v1alpha1 MedusaBackupJob/MedusaRestoreJob instead."

// CassandraBackup is the Schema for the cassandrabackups API
type CassandraBackup struct {
Expand Down
1 change: 1 addition & 0 deletions apis/medusa/v1alpha1/cassandrarestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type CassandraRestoreStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:deprecatedversion:warning="medusa.k8ssandra.com/v1alpha1 CassandraBackup/CassandraRestore are deprecated, use medusa.k8ssandra.com/v1alpha1 MedusaBackupJob/MedusaRestoreJob instead."

// CassandraRestore is the Schema for the cassandrarestores API
type CassandraRestore struct {
Expand Down
67 changes: 67 additions & 0 deletions apis/medusa/v1alpha1/medusabackup_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"github.com/k8ssandra/k8ssandra-operator/pkg/shared"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// MedusaBackupSpec defines the desired state of MedusaBackup
type MedusaBackupSpec struct {
// The name of the CassandraDatacenter to back up
CassandraDatacenter string `json:"cassandraDatacenter"`

// The type of the backup: "full" or "differential"
// +kubebuilder:validation:Enum=differential;full;
// +kubebuilder:default:=differential
Type shared.BackupType `json:"backupType,omitempty"`
}

// MedusaBackupStatus defines the observed state of MedusaBackup
type MedusaBackupStatus struct {
StartTime metav1.Time `json:"startTime,omitempty"`
FinishTime metav1.Time `json:"finishTime,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// MedusaBackup is the Schema for the medusabackups API
type MedusaBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MedusaBackupSpec `json:"spec,omitempty"`
Status MedusaBackupStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// MedusaBackupList contains a list of MedusaBackup
type MedusaBackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MedusaBackup `json:"items"`
}

func init() {
SchemeBuilder.Register(&MedusaBackup{}, &MedusaBackupList{})
}
74 changes: 74 additions & 0 deletions apis/medusa/v1alpha1/medusabackupjob_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"github.com/k8ssandra/k8ssandra-operator/pkg/shared"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// MedusaBackupJobSpec defines the desired state of MedusaBackupJob
type MedusaBackupJobSpec struct {
// The name of the CassandraDatacenter to back up
CassandraDatacenter string `json:"cassandraDatacenter"`

// The type of the backup: "full" or "differential"
// +kubebuilder:validation:Enum=differential;full;
// +kubebuilder:default:=differential
Type shared.BackupType `json:"backupType,omitempty"`
}

// MedusaBackupJobStatus defines the observed state of MedusaBackupJob
type MedusaBackupJobStatus struct {
StartTime metav1.Time `json:"startTime,omitempty"`

FinishTime metav1.Time `json:"finishTime,omitempty"`

InProgress []string `json:"inProgress,omitempty"`

Finished []string `json:"finished,omitempty"`

Failed []string `json:"failed,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// MedusaBackupJob is the Schema for the medusabackupjobs API
type MedusaBackupJob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MedusaBackupJobSpec `json:"spec,omitempty"`
Status MedusaBackupJobStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// MedusaBackupJobList contains a list of MedusaBackupJob
type MedusaBackupJobList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MedusaBackupJob `json:"items"`
}

func init() {
SchemeBuilder.Register(&MedusaBackupJob{}, &MedusaBackupJobList{})
}
78 changes: 78 additions & 0 deletions apis/medusa/v1alpha1/medusarestorejob_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// MedusaRestoreJobSpec defines the desired state of MedusaRestoreJob
type MedusaRestoreJobSpec struct {
// The name of the CassandraBackup to restore.
Backup string `json:"backup"`

// Name of the Cassandra datacenter to perform the restore on.
CassandraDatacenter string `json:"cassandraDatacenter"`
}

// MedusaRestoreJobStatus defines the observed state of MedusaRestoreJob
type MedusaRestoreJobStatus struct {
// A unique key that identifies the restore operation.
RestoreKey string `json:"restoreKey"`

RestorePrepared bool `json:"restorePrepared,omitempty"`

StartTime metav1.Time `json:"startTime,omitempty"`

FinishTime metav1.Time `json:"finishTime,omitempty"`

DatacenterStopped metav1.Time `json:"datacenterStopped,omitempty"`

InProgress []string `json:"inProgress,omitempty"`

Finished []string `json:"finished,omitempty"`

Failed []string `json:"failed,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// MedusaRestoreJob is the Schema for the medusarestorejobs API
type MedusaRestoreJob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MedusaRestoreJobSpec `json:"spec,omitempty"`
Status MedusaRestoreJobStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// MedusaRestoreJobList contains a list of MedusaRestoreJob
type MedusaRestoreJobList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MedusaRestoreJob `json:"items"`
}

func init() {
SchemeBuilder.Register(&MedusaRestoreJob{}, &MedusaRestoreJobList{})
}
Loading

0 comments on commit 2e6ed83

Please sign in to comment.