Skip to content
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

OADP-1224: restic node-agent refactor label #879

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 12 additions & 14 deletions controllers/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
)

const (
Restic = "restic"
ResticRestoreHelperCM = "restic-restore-action-config"
HostPods = "host-pods"
)
Expand All @@ -37,11 +36,12 @@ var (
// we need to declare mountPropagationToHostContainer so that we have an address to point to
// for ds.Spec.Template.Spec.Volumes[].Containers[].VolumeMounts[].MountPropagation
mountPropagationToHostContainer = corev1.MountPropagationHostToContainer
resticLabelSelector = &metav1.LabelSelector{
MatchLabels: map[string]string{
"component": common.Velero,
"name": common.NodeAgent,
},
nodeAgentMatchLabels = map[string]string{
"component": common.Velero,
"name": common.NodeAgent,
}
nodeAgentLabelSelector = &metav1.LabelSelector{
MatchLabels: nodeAgentMatchLabels,
}
)

Expand All @@ -53,13 +53,11 @@ func getResticPvHostPath() string {
return env
}

func getResticObjectMeta(r *DPAReconciler) metav1.ObjectMeta {
func getNodeAgentObjectMeta(r *DPAReconciler) metav1.ObjectMeta {
return metav1.ObjectMeta{
Name: Restic,
Name: common.NodeAgent,
Namespace: r.NamespacedName.Namespace,
Labels: map[string]string{
"component": "velero",
},
Labels: nodeAgentMatchLabels,
}
}

Expand All @@ -71,7 +69,7 @@ func (r *DPAReconciler) ReconcileResticDaemonset(log logr.Logger) (bool, error)

// Define "static" portion of daemonset
ds := &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
}
if dpa.Spec.Configuration.Restic == nil || dpa.Spec.Configuration.Restic != nil && (dpa.Spec.Configuration.Restic.Enable == nil || !*dpa.Spec.Configuration.Restic.Enable) {
deleteContext := context.Background()
Expand Down Expand Up @@ -114,7 +112,7 @@ func (r *DPAReconciler) ReconcileResticDaemonset(log logr.Logger) (bool, error)
if ds.Spec.Selector.MatchLabels == nil {
ds.Spec.Selector.MatchLabels = make(map[string]string)
}
ds.Spec.Selector.MatchLabels, err = common.AppendUniqueLabels(ds.Spec.Selector.MatchLabels, resticLabelSelector.MatchLabels)
ds.Spec.Selector.MatchLabels, err = common.AppendUniqueLabels(ds.Spec.Selector.MatchLabels, nodeAgentLabelSelector.MatchLabels)
if err != nil {
return fmt.Errorf("failed to append labels to selector: %s", err)
}
Expand Down Expand Up @@ -206,7 +204,7 @@ func (r *DPAReconciler) customizeResticDaemonset(dpa *oadpv1alpha1.DataProtectio
}
}
// customize specs
ds.Spec.Selector = resticLabelSelector
ds.Spec.Selector = nodeAgentLabelSelector
ds.Spec.UpdateStrategy = appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
}
Expand Down
74 changes: 37 additions & 37 deletions controllers/restic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -144,7 +144,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -271,12 +271,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -285,7 +285,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -413,7 +413,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: true,
Expand Down Expand Up @@ -441,12 +441,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -455,7 +455,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -609,12 +609,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -623,7 +623,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -776,12 +776,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -790,7 +790,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -942,12 +942,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -956,7 +956,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -1105,12 +1105,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -1119,7 +1119,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -1271,12 +1271,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -1285,7 +1285,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -1434,12 +1434,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -1448,7 +1448,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -1592,12 +1592,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -1606,7 +1606,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -1766,12 +1766,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -1780,7 +1780,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down Expand Up @@ -1938,12 +1938,12 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
},
},
}, &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
},
},
wantErr: false,
want: &appsv1.DaemonSet{
ObjectMeta: getResticObjectMeta(r),
ObjectMeta: getNodeAgentObjectMeta(r),
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
Expand All @@ -1952,7 +1952,7 @@ func TestDPAReconciler_buildResticDaemonset(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
},
Selector: resticLabelSelector,
Selector: nodeAgentLabelSelector,
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion controllers/velero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ func TestDPAReconciler_buildVeleroDeployment(t *testing.T) {
Velero: &oadpv1alpha1.VeleroConfig{
PodConfig: &oadpv1alpha1.PodConfig{
Labels: map[string]string{
"component": "restic",
"component": common.NodeAgent,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ var _ = Describe("AWS backup restore tests", func() {

if brCase.BackupRestoreType == RESTIC {
log.Printf("Waiting for restic pods to be running")
Eventually(AreResticPodsRunning(namespace), timeoutMultiplier*time.Minute*3, time.Second*5).Should(BeTrue())
Eventually(AreNodeAgentPodsRunning(namespace), timeoutMultiplier*time.Minute*3, time.Second*5).Should(BeTrue())
}
if brCase.BackupRestoreType == CSI {
if provider == "aws" || provider == "ibmcloud" || provider == "gcp" || provider == "azure" {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/dpa_deployment_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ var _ = Describe("Configuration testing for DPA Custom Resource", func() {
//restic installation
if dpa.Spec.Configuration.Restic != nil && *dpa.Spec.Configuration.Restic.Enable {
log.Printf("Waiting for restic pods to be running")
Eventually(AreResticPodsRunning(namespace), timeoutMultiplier*time.Minute*3, time.Second*5).Should(BeTrue())
Eventually(AreNodeAgentPodsRunning(namespace), timeoutMultiplier*time.Minute*3, time.Second*5).Should(BeTrue())
} else {
log.Printf("Waiting for restic daemonset to be deleted")
Eventually(IsResticDaemonsetDeleted(namespace), timeoutMultiplier*time.Minute*3, time.Second*5).Should(BeTrue())
Expand Down