Compare commits
No commits in common. "517a6c732429f58178cf0a7e9e961ae2c7c99764" and "e69b25bae01e029a0cacd802a48c77a1877ce0e3" have entirely different histories.
517a6c7324
...
e69b25bae0
@ -13,7 +13,7 @@ func (r *BackupConfigurationReconciler) DeleteSidecar(backupConf formolv1alpha1.
|
|||||||
for i, container := range podSpec.Containers {
|
for i, container := range podSpec.Containers {
|
||||||
for _, targetContainer := range target.Containers {
|
for _, targetContainer := range target.Containers {
|
||||||
if targetContainer.Name == container.Name {
|
if targetContainer.Name == container.Name {
|
||||||
if len(container.Env) > 1 && container.Env[len(container.Env)-1].Name == formolv1alpha1.TARGETCONTAINER_TAG {
|
if container.Env[len(container.Env)-1].Name == formolv1alpha1.TARGETCONTAINER_TAG {
|
||||||
podSpec.Containers[i].Env = container.Env[:len(container.Env)-1]
|
podSpec.Containers[i].Env = container.Env[:len(container.Env)-1]
|
||||||
} else {
|
} else {
|
||||||
for j, e := range container.Env {
|
for j, e := range container.Env {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
batchv1 "k8s.io/api/batch/v1"
|
batchv1 "k8s.io/api/batch/v1"
|
||||||
//"time"
|
//"time"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
//appsv1 "k8s.io/api/apps/v1"
|
||||||
//corev1 "k8s.io/api/core/v1"
|
//corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
@ -130,24 +130,6 @@ var _ = Describe("BackupConfiguration controller", func() {
|
|||||||
}, timeout, interval).Should(Equal("1 0 * * *"))
|
}, timeout, interval).Should(Equal("1 0 * * *"))
|
||||||
Expect(*cronJob.Spec.Suspend).Should(BeTrue())
|
Expect(*cronJob.Spec.Suspend).Should(BeTrue())
|
||||||
})
|
})
|
||||||
When("The BackupType is an OnlineKind", func() {
|
|
||||||
It("Should create a sidecar container", func() {
|
|
||||||
deployment := &appsv1.Deployment{}
|
|
||||||
Eventually(func() bool {
|
|
||||||
if err := k8sClient.Get(ctx, types.NamespacedName{
|
|
||||||
Name: DEPLOYMENT_NAME,
|
|
||||||
Namespace: NAMESPACE_NAME,
|
|
||||||
}, deployment); err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return len(deployment.Spec.Template.Spec.Containers) == 2
|
|
||||||
}, timeout, interval).Should(BeTrue())
|
|
||||||
|
|
||||||
By("Should add Env labels")
|
|
||||||
Expect(deployment.Spec.Template.Spec.Containers[0].Env[0].Name).Should(Equal(formolv1alpha1.TARGETCONTAINER_TAG))
|
|
||||||
Expect(deployment.Spec.Template.Spec.Containers[1].Name).Should(Equal(formolv1alpha1.SIDECARCONTAINER_NAME))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
Context("Deleting a BackupConf", func() {
|
Context("Deleting a BackupConf", func() {
|
||||||
JustBeforeEach(func() {
|
JustBeforeEach(func() {
|
||||||
@ -179,33 +161,5 @@ var _ = Describe("BackupConfiguration controller", func() {
|
|||||||
}, timeout, interval).Should(BeFalse())
|
}, timeout, interval).Should(BeFalse())
|
||||||
|
|
||||||
})
|
})
|
||||||
When("The BackupType is an OnlineKind", func() {
|
|
||||||
It("Should delete the sidecar container", func() {
|
|
||||||
deployment := &appsv1.Deployment{}
|
|
||||||
Eventually(func() bool {
|
|
||||||
if err := k8sClient.Get(ctx, types.NamespacedName{
|
|
||||||
Name: DEPLOYMENT_NAME,
|
|
||||||
Namespace: NAMESPACE_NAME,
|
|
||||||
}, deployment); err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return len(deployment.Spec.Template.Spec.Containers) == 2
|
|
||||||
}, timeout, interval).Should(BeTrue())
|
|
||||||
Expect(deployment.Spec.Template.Spec.Containers[0].Env[0].Name).Should(Equal(formolv1alpha1.TARGETCONTAINER_TAG))
|
|
||||||
Expect(deployment.Spec.Template.Spec.Containers[1].Name).Should(Equal(formolv1alpha1.SIDECARCONTAINER_NAME))
|
|
||||||
By("The sidecar container has been created. Now deleting the BackupConfiguration")
|
|
||||||
Expect(k8sClient.Delete(ctx, backupConf)).Should(Succeed())
|
|
||||||
Eventually(func() bool {
|
|
||||||
if err := k8sClient.Get(ctx, types.NamespacedName{
|
|
||||||
Name: DEPLOYMENT_NAME,
|
|
||||||
Namespace: NAMESPACE_NAME,
|
|
||||||
}, deployment); err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return len(deployment.Spec.Template.Spec.Containers) == 1
|
|
||||||
}, timeout, interval).Should(BeTrue())
|
|
||||||
Expect(len(deployment.Spec.Template.Spec.Containers[0].Env)).Should(Equal(0))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -50,7 +50,6 @@ const (
|
|||||||
DEPLOYMENT_NAME = "test-deployment"
|
DEPLOYMENT_NAME = "test-deployment"
|
||||||
CONTAINER_NAME = "test-container"
|
CONTAINER_NAME = "test-container"
|
||||||
DATAVOLUME_NAME = "data"
|
DATAVOLUME_NAME = "data"
|
||||||
SECRET_NAME = "test-secret"
|
|
||||||
timeout = time.Second * 10
|
timeout = time.Second * 10
|
||||||
interval = time.Millisecond * 250
|
interval = time.Millisecond * 250
|
||||||
)
|
)
|
||||||
@ -90,32 +89,6 @@ var (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
secret = &corev1.Secret{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: SECRET_NAME,
|
|
||||||
Namespace: NAMESPACE_NAME,
|
|
||||||
},
|
|
||||||
Data: map[string][]byte{
|
|
||||||
"RESTIC_PASSWORD": []byte("toto"),
|
|
||||||
"AWS_ACCESS_KEY_ID": []byte("titi"),
|
|
||||||
"AWS_SECRET_ACCESS_KEY": []byte("tata"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
repo = &formolv1alpha1.Repo{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: REPO_NAME,
|
|
||||||
Namespace: NAMESPACE_NAME,
|
|
||||||
},
|
|
||||||
Spec: formolv1alpha1.RepoSpec{
|
|
||||||
Backend: formolv1alpha1.Backend{
|
|
||||||
S3: &formolv1alpha1.S3{
|
|
||||||
Server: "raid5.desmojim.fr:9000",
|
|
||||||
Bucket: "testbucket2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RepositorySecrets: "test-secret",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
cfg *rest.Config
|
cfg *rest.Config
|
||||||
k8sClient client.Client
|
k8sClient client.Client
|
||||||
testEnv *envtest.Environment
|
testEnv *envtest.Environment
|
||||||
@ -154,8 +127,6 @@ var _ = BeforeSuite(func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(k8sClient).NotTo(BeNil())
|
Expect(k8sClient).NotTo(BeNil())
|
||||||
Expect(k8sClient.Create(ctx, namespace)).Should(Succeed())
|
Expect(k8sClient.Create(ctx, namespace)).Should(Succeed())
|
||||||
Expect(k8sClient.Create(ctx, secret)).Should(Succeed())
|
|
||||||
Expect(k8sClient.Create(ctx, repo)).Should(Succeed())
|
|
||||||
Expect(k8sClient.Create(ctx, deployment)).Should(Succeed())
|
Expect(k8sClient.Create(ctx, deployment)).Should(Succeed())
|
||||||
|
|
||||||
k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
|
k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user