Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1beta2/foundationdbbackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func (backup *FoundationDBBackup) GetEncryptionKey() (string, error) {

// UseUnifiedImage returns true if the unified image should be used.
func (backup *FoundationDBBackup) UseUnifiedImage() bool {
imageType := ImageTypeSplit
imageType := ImageTypeUnified
if backup.Spec.ImageType != nil {
imageType = *backup.Spec.ImageType
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/backup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var _ = Describe("backup_controller", func() {
Expect(*deployment.Spec.Replicas).To(Equal(int32(3)))
Expect(
deployment.Spec.Template.Spec.Containers[0].Image,
).To(Equal(fmt.Sprintf("foundationdb/foundationdb:%s", cluster.Spec.Version)))
).To(Equal(fmt.Sprintf("foundationdb/fdb-kubernetes-monitor:%s", cluster.Spec.Version)))
})

It("should update the status on the resource", func() {
Expand Down Expand Up @@ -319,7 +319,7 @@ var _ = Describe("backup_controller", func() {
Expect(deployments.Items[0].ObjectMeta.Annotations).To(Equal(map[string]string{
"fdb-test-1": "test-value-1",
"fdb-test-2": "test-value-2",
"foundationdb.org/last-applied-spec": "8d2e3abf517313fabdf4e19e50b46f9d5b63e5c5d587a01565008945a2dec87f",
"foundationdb.org/last-applied-spec": "946b41ecc6985d5f56d9749e9366132ba4e8cb250eb3bcfe73b037ad1f47c7f4",
}))
})
})
Expand Down
35 changes: 18 additions & 17 deletions internal/pod_models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3576,7 +3576,7 @@ var _ = Describe("pod_models", func() {
fdbv1beta2.BackupDeploymentLabel: string(cluster.ObjectMeta.UID),
}))
Expect(deployment.ObjectMeta.Annotations).To(Equal(map[string]string{
"foundationdb.org/last-applied-spec": "8d2e3abf517313fabdf4e19e50b46f9d5b63e5c5d587a01565008945a2dec87f",
"foundationdb.org/last-applied-spec": "946b41ecc6985d5f56d9749e9366132ba4e8cb250eb3bcfe73b037ad1f47c7f4",
}))
})

Expand Down Expand Up @@ -3639,7 +3639,7 @@ var _ = Describe("pod_models", func() {
It("should set the image and command for the backup agent", func() {
Expect(
container.Image,
).To(Equal(fmt.Sprintf("foundationdb/foundationdb:%s", cluster.Spec.Version)))
).To(Equal(fmt.Sprintf("foundationdb/fdb-kubernetes-monitor:%s", cluster.Spec.Version)))
Expect(container.Command).To(Equal([]string{"backup_agent"}))
Expect(container.Args).To(Equal([]string{
"--log",
Expand Down Expand Up @@ -3690,13 +3690,18 @@ var _ = Describe("pod_models", func() {
It("should set the image and command for the container", func() {
Expect(
container.Image,
).To(Equal(fmt.Sprintf("foundationdb/foundationdb-kubernetes-sidecar:%s-1", cluster.Spec.Version)))
).To(Equal(fmt.Sprintf("foundationdb/fdb-kubernetes-monitor:%s", cluster.Spec.Version)))
Expect(container.Args).To(Equal([]string{
"--copy-file",
"fdb.cluster",
"--require-not-empty",
"fdb.cluster",
"--init-mode",
"--mode",
"init",
"--output-dir",
"/var/output-files",
"--input-dir",
"/var/input-files",
}))
})

Expand Down Expand Up @@ -3897,7 +3902,7 @@ var _ = Describe("pod_models", func() {
"foundationdb.org/backup-for": string(cluster.ObjectMeta.UID),
}))
Expect(deployment.ObjectMeta.Annotations).To(Equal(map[string]string{
"foundationdb.org/last-applied-spec": "879780b88956de7a05e245cdbf16c565b95fe5c956e3a89e7ea259cd9b209d97",
"foundationdb.org/last-applied-spec": "23b6a2501f83a4cfcf760f639b1d841203ef4f44d496da072ebd1542870ad53f",
}))

Expect(
Expand Down Expand Up @@ -3925,7 +3930,7 @@ var _ = Describe("pod_models", func() {
).To(Equal("foundationdb/foundationdb:dev"))
Expect(
deployment.Spec.Template.Spec.InitContainers[0].Image,
).To(Equal("foundationdb/foundationdb-kubernetes-sidecar:dev-1"))
).To(Equal("foundationdb/foundationdb:dev"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seemed a bit suspect to me -- shouldn't the init container be the fdb-kubernetes-monitor? The failure message indicated that it was actually the same image as the main container.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test the image config is changed and the main image config is set to foundationdb/foundationdb:dev. Since the default image is now the unified image for the backup pods, the init image and the main image will be the same, in this case foundationdb/foundationdb:dev and the sidecar image config will be ignored.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Even though this is valid from the operator's perspective, this would not actually work right, because the foundationdb image can't be used as the init container image?

})
})

Expand Down Expand Up @@ -3963,36 +3968,32 @@ var _ = Describe("pod_models", func() {
})
})

When("using the unified image", func() {
When("using the split image", func() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed that we still want to test the split image behavior, so test swaps with pod_models when getting the backup deployment with a basic deployment the init container [It] should set the image and command for the container

BeforeEach(func() {
imageType := fdbv1beta2.ImageTypeUnified
imageType := fdbv1beta2.ImageTypeSplit
backup.Spec.ImageType = &imageType
deployment, err = GetBackupDeployment(backup)
Expect(err).NotTo(HaveOccurred())
Expect(deployment).NotTo(BeNil())
})

It("should use the unified image as main and init container", func() {
It("should use the split image as main container and the sidecar image as the init container", func() {
Expect(deployment.Spec.Template.Spec.InitContainers).To(HaveLen(1))
Expect(deployment.Spec.Template.Spec.Containers).To(HaveLen(1))

Expect(
deployment.Spec.Template.Spec.InitContainers[0].Image,
).To(HavePrefix(fdbv1beta2.FoundationDBKubernetesBaseImage))
).To(HavePrefix(fdbv1beta2.FoundationDBSidecarBaseImage))
Expect(deployment.Spec.Template.Spec.InitContainers[0].Args).To(ConsistOf(
"--copy-file",
"fdb.cluster",
"--require-not-empty",
"fdb.cluster",
"--mode",
"init",
"--output-dir",
"/var/output-files",
"--input-dir",
"/var/input-files"))
"--init-mode",
))
Expect(
deployment.Spec.Template.Spec.Containers[0].Image,
).To(HavePrefix(fdbv1beta2.FoundationDBKubernetesBaseImage))
).To(HavePrefix(fdbv1beta2.FoundationDBBaseImage))
})
})
})
Expand Down
Loading