Skip to content

Commit d08d6c6

Browse files
committed
✨ Add -migrations to the job name to make it clearer what they are.
1 parent 9699be0 commit d08d6c6

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

components/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (comp *migrationsComponent) Reconcile(ctx *cu.Context) (cu.Result, error) {
196196

197197
migrationJob := &batchv1.Job{
198198
ObjectMeta: metav1.ObjectMeta{
199-
Name: obj.Name,
199+
Name: obj.Name + "-migrations",
200200
Namespace: obj.Namespace,
201201
Labels: obj.Labels,
202202
Annotations: map[string]string{},

components/migrations_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var _ = Describe("Migrations component", func() {
6161
}
6262
job = &batchv1.Job{
6363
ObjectMeta: metav1.ObjectMeta{
64-
Name: "testing",
64+
Name: "testing-migrations",
6565
Namespace: "default",
6666
},
6767
Spec: batchv1.JobSpec{
@@ -110,9 +110,9 @@ var _ = Describe("Migrations component", func() {
110110
It("starts a migration", func() {
111111
helper.TestClient.Create(pod)
112112
helper.MustReconcile()
113-
Expect(helper.Events).To(Receive(Equal("Normal MigrationsStarted Started migration job default/testing using image myapp:latest")))
113+
Expect(helper.Events).To(Receive(Equal("Normal MigrationsStarted Started migration job default/testing-migrations using image myapp:latest")))
114114
Expect(obj).To(HaveCondition("MigrationsReady").WithReason("MigrationsRunning").WithStatus("False"))
115-
helper.TestClient.GetName("testing", job)
115+
helper.TestClient.GetName("testing-migrations", job)
116116
Expect(job.Spec.Template.Spec.Containers[0].Name).To(Equal("migrations"))
117117
Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("myapp:latest"))
118118
})
@@ -123,7 +123,7 @@ var _ = Describe("Migrations component", func() {
123123
helper.MustReconcile()
124124
Expect(obj).To(HaveCondition("MigrationsReady").WithReason("MigrationsRunning").WithStatus("False"))
125125
job2 := &batchv1.Job{}
126-
helper.TestClient.GetName("testing", job2)
126+
helper.TestClient.GetName("testing-migrations", job2)
127127
Expect(job.Spec).To(Equal(job2.Spec))
128128
})
129129

@@ -133,7 +133,7 @@ var _ = Describe("Migrations component", func() {
133133
helper.TestClient.Create(job)
134134
helper.MustReconcile()
135135
Expect(obj).To(HaveCondition("MigrationsReady").WithReason("StaleJob").WithStatus("False"))
136-
err := helper.Client.Get(context.Background(), types.NamespacedName{Name: "testing", Namespace: "default"}, job)
136+
err := helper.Client.Get(context.Background(), types.NamespacedName{Name: "testing-migrations", Namespace: "default"}, job)
137137
Expect(kerrors.IsNotFound(err)).To(BeTrue())
138138
})
139139

@@ -143,7 +143,7 @@ var _ = Describe("Migrations component", func() {
143143
helper.TestClient.Create(job)
144144
helper.MustReconcile()
145145
Expect(obj).To(HaveCondition("MigrationsReady").WithStatus("True"))
146-
err := helper.Client.Get(context.Background(), types.NamespacedName{Name: "testing", Namespace: "default"}, job)
146+
err := helper.Client.Get(context.Background(), types.NamespacedName{Name: "testing-migrations", Namespace: "default"}, job)
147147
Expect(kerrors.IsNotFound(err)).To(BeTrue())
148148
})
149149

@@ -154,7 +154,7 @@ var _ = Describe("Migrations component", func() {
154154
helper.MustReconcile()
155155
Expect(obj).To(HaveCondition("MigrationsReady").WithStatus("False").WithReason("MigrationsFailed"))
156156
job2 := &batchv1.Job{}
157-
helper.TestClient.GetName("testing", job2)
157+
helper.TestClient.GetName("testing-migrations", job2)
158158
Expect(job.Spec).To(Equal(job2.Spec))
159159
})
160160

@@ -173,15 +173,15 @@ var _ = Describe("Migrations component", func() {
173173
pod2.Spec.Containers[0].Image = "two:latest"
174174
helper.TestClient.Create(pod2)
175175
helper.MustReconcile()
176-
helper.TestClient.GetName("testing", job)
176+
helper.TestClient.GetName("testing-migrations", job)
177177
Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("two:latest"))
178178
})
179179

180180
It("applies image override", func() {
181181
obj.Spec.Image = "other:1"
182182
helper.TestClient.Create(pod)
183183
helper.MustReconcile()
184-
helper.TestClient.GetName("testing", job)
184+
helper.TestClient.GetName("testing-migrations", job)
185185
Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("other:1"))
186186
})
187187

@@ -190,7 +190,7 @@ var _ = Describe("Migrations component", func() {
190190
obj.Spec.Command = &command
191191
helper.TestClient.Create(pod)
192192
helper.MustReconcile()
193-
helper.TestClient.GetName("testing", job)
193+
helper.TestClient.GetName("testing-migrations", job)
194194
Expect(job.Spec.Template.Spec.Containers[0].Command).To(Equal([]string{"run", "migrations"}))
195195
})
196196

@@ -199,7 +199,7 @@ var _ = Describe("Migrations component", func() {
199199
obj.Spec.Args = &args
200200
helper.TestClient.Create(pod)
201201
helper.MustReconcile()
202-
helper.TestClient.GetName("testing", job)
202+
helper.TestClient.GetName("testing-migrations", job)
203203
Expect(job.Spec.Template.Spec.Containers[0].Args).To(Equal([]string{"run", "migrations"}))
204204
})
205205

@@ -246,7 +246,7 @@ var _ = Describe("Migrations component", func() {
246246
helper.TestClient.Create(pod)
247247

248248
helper.MustReconcile()
249-
helper.TestClient.GetName("testing", job)
249+
helper.TestClient.GetName("testing-migrations", job)
250250
Expect(job.Spec.Template.Spec.Containers[0].Image).To(Equal("myapp:v1"))
251251
})
252252
})

controllers/migrator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var _ = Describe("Migrator controller", func() {
8282

8383
// Mark the job as successful.
8484
job := &batchv1.Job{}
85-
c.EventuallyGetName("testing", job)
85+
c.EventuallyGetName("testing-migrations", job)
8686
job.Status.Succeeded = 1
8787
c.Status().Update(job)
8888

@@ -92,8 +92,8 @@ var _ = Describe("Migrator controller", func() {
9292

9393
// Make sure the job doesn't come back.
9494
Consistently(func() error {
95-
return helper.Client.Get(context.Background(), types.NamespacedName{Name: "testing", Namespace: helper.Namespace}, job)
96-
}, 5).Should(MatchError("Job.batch \"testing\" not found"))
95+
return helper.Client.Get(context.Background(), types.NamespacedName{Name: "testing-migrations", Namespace: helper.Namespace}, job)
96+
}, 5).Should(MatchError("Job.batch \"testing-migrations\" not found"))
9797

9898
// Update the pod image and see if a new migration is run.
9999
c.Delete(pod)
@@ -104,7 +104,7 @@ var _ = Describe("Migrator controller", func() {
104104
c.EventuallyGetName("testing", migrator, c.EventuallyCondition("Ready", "False"))
105105

106106
// Mark the new job as successful.
107-
c.EventuallyGetName("testing", job)
107+
c.EventuallyGetName("testing-migrations", job)
108108
job.Status.Succeeded = 1
109109
c.Status().Update(job)
110110

0 commit comments

Comments
 (0)