Skip to content

Commit e9a370d

Browse files
authored
Merge pull request #289 from anynines/develop
Merge develop to main
2 parents f4b7ccf + 4636980 commit e9a370d

File tree

11 files changed

+133
-19
lines changed

11 files changed

+133
-19
lines changed

.github/pull_request_template.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Short Description
2+
23
_Please provide a brief summary of your changes_
4+
35
# Details
46

7+
# Note
8+
9+
WARNING: Only users listed in the CODEOWNERS file can approve PRs!
10+
511
# Checks
12+
613
- [ ] Documentation has been adjusted
714
- [ ] Architectural decisions have been documented
815
- [ ] Changelog has been updated
16+
- [ ] PR is approved by a code owner
917
- [ ] Manifests are updated
1018
- [ ] Commit message adheres to our [guideline](https://anynines.atlassian.net/wiki/spaces/DS/pages/2423193626/Version+Control+Workflow)

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @abdulhaseeb3 @mkfdoherty @lhaendler

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ This repo contains:
1111
- some guidance for application developers on how to use a8s to provision and manage (e.g. take a
1212
backup) PostgreSQL instances that their applications can use.
1313

14-
> WARNING: **a8s is in beta** and the only data service that it currently supports is
15-
PostgreSQL 13 and 14. **Don't use it for production workloads**. Some features may still be fragile
16-
and some breaking API changes may occur. For known issues and limitations please consult
17-
[Current Limitations](docs/current_limitations.md).
14+
> WARNING: a8s offers support for both PostgreSQL 13 and 14. Refer to [Current Limitations](docs/current_limitations.md)
15+
for information on any known issues or limitations.
1816

1917
## Main features
2018

deploy/a8s/manifests/backup-manager.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,15 @@ spec:
628628
- --metrics-bind-address=127.0.0.1:8080
629629
- --leader-elect
630630
command:
631-
- a8s-backup-manager
631+
- ./manager
632632
env:
633633
- name: systemNamespace
634634
valueFrom:
635635
fieldRef:
636636
fieldPath: metadata.namespace
637637
- name: BACKUP_CREDENTIAL_PATH
638638
value: /etc/backup-store-secrets
639-
image: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/backup-manager:2616f22c4fe670541c3c78131ae018902f8471bf
639+
image: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/backup-manager:2616f22c4fe670541c3c78131aw018902e847rbf
640640
livenessProbe:
641641
httpGet:
642642
path: /healthz

deploy/a8s/manifests/postgresql-images.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v1
22
data:
3-
backupAgentImage: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/backup-agent:781ca7b6e9bb4af66aeedb5046b50dc1c2b6c638
3+
backupAgentImage: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/backup-agent:81450cbb7f94fa020441361d8c64ew89499acd13
44
extensionCleanupImage: alpine:3.16.0
55
extensionImageRegistry: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/postgresql-operator/postgresql-extensions
66
spiloImage: ghcr.io/zalando/spilo-15:3.0-p1

deploy/a8s/manifests/postgresql-operator.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,8 +1672,8 @@ spec:
16721672
- --metrics-bind-address=127.0.0.1:8080
16731673
- --leader-elect
16741674
command:
1675-
- postgresql-operator
1676-
image: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/postgresql-operator:c01af5af858b4a5186460a51d5a1f34a5d428317
1675+
- ./manager
1676+
image: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/postgresql-operator:37d4a2e9d311ff66d8fc5b1d570a08232a20754x
16771677
livenessProbe:
16781678
httpGet:
16791679
path: /healthz
@@ -1808,3 +1808,4 @@ webhooks:
18081808
resources:
18091809
- postgresqls
18101810
sideEffects: None
1811+

deploy/a8s/manifests/service-binding-controller.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ spec:
345345
- args:
346346
- --config=/config/controller_manager_config.yaml
347347
command:
348-
- a8s-service-binding-controller
348+
- ./manager
349349
- --postgresql-root-role=a9s_user
350350
- --postgresql-default-database=a9s_apps_default_db
351-
image: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/service-binding-controller:a2903616cb2f52885f1cdb93b5fd1c95d6a7694a
351+
image: public.ecr.aws/w5n9a2g2/a9s-ds-for-k8s/dev/service-binding-controller:a3f2694dc93e7ace07829cb1b8a3b5f6s4d1527c
352352
livenessProbe:
353353
httpGet:
354354
path: /healthz

test/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,24 @@ test cases test the same coarse-grained functionality.
3030

3131
- To run *all* the test suites currently available run `go test ./...` from
3232
inside the test directory.
33-
- To run the end-to-end tests use `go test ./e2e/..`
33+
- To run the end-to-end tests use `go test ./e2e/...`
3434
- To run only the chaos tests use `go test ./chaos-tests`
3535
- To run a *single* suite/piece of functionality, for example the backup
3636
end-to-end tests, run `go test ./e2e/backup` from inside the test directory.
3737
- `go test` can also be replaced by `ginkgo` for more informative output.
3838

39+
Some tests are not compatible with certain environments. They are labeled accordingly
40+
so they can be skipped using the GinkGo CLI. For example the following command will
41+
skip tests that don't work in Kind.
42+
43+
``` sh
44+
ginkgo run --label-filter='!KindIncompatible' ./...
45+
```
46+
3947
If your run includes the `chaos-tests`, you will have to install
4048
[ChaosMesh](https://chaos-mesh.org/). As the installation is specific to the
4149
container runtime used in your cluster, refer to the [official installation
42-
guide](https://chaos-mesh.org/docs/production-installation-using-helm/).
50+
guide](https://chaos-mesh.org/docs/production-installation-using-helm/).
4351

4452
### Adding or Modifying Tests
4553

test/e2e/postgresql/exposed_cluster_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
SSLModeRequired = "require"
2222
)
2323

24-
var _ = Describe("end-to-end tests for exposed instances", func() {
24+
var _ = Describe("end-to-end tests for exposed instances", Label("ExternalLoadbalancer", "KindIncompatible"), func() {
2525

2626
Context("Instance exposed via Load Balancer", Ordered, func() {
2727
AfterAll(func() {

test/e2e/postgresql/postgresql_test.go

Lines changed: 99 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,40 @@ var _ = Describe("PostgreSQL Operator end-to-end tests", func() {
172172
Expect(svc.Spec.Ports[0].Name).To(Equal("postgresql"))
173173
Expect(svc.Spec.Ports[0].Port).To(Equal(int32(5432)))
174174
Expect(svc.Spec.Ports[0].Protocol).To(Equal(corev1.ProtocolTCP))
175+
Expect(svc.Spec.Ports).To(HaveLen(1))
176+
})
177+
178+
By("creating a Service that points to all of the pods for the Patroni API", func() {
179+
svc := &corev1.Service{}
180+
Expect(k8sClient.Get(ctx,
181+
types.NamespacedName{
182+
Name: postgresql.PatroniService(
183+
instance.GetName()),
184+
Namespace: instance.GetNamespace()},
185+
svc)).To(Succeed())
186+
187+
By("checking a8s labels added to Service", func() {
188+
Expect(svc.Labels).To(HaveKeyWithValue("a8s.a9s/dsi-name", pg.Name))
189+
Expect(svc.Labels).
190+
To(HaveKeyWithValue("a8s.a9s/dsi-group", "postgresql.anynines.com"))
191+
Expect(svc.Labels).
192+
To(HaveKeyWithValue("a8s.a9s/dsi-kind", "Postgresql"))
193+
})
194+
195+
By("checking a8s labels as selector", func() {
196+
Expect(svc.Spec.Selector).To(HaveKeyWithValue("a8s.a9s/dsi-name", pg.Name))
197+
Expect(svc.Spec.Selector).
198+
To(HaveKeyWithValue("a8s.a9s/dsi-group", "postgresql.anynines.com"))
199+
Expect(svc.Spec.Selector).To(HaveKeyWithValue("a8s.a9s/dsi-kind", "Postgresql"))
200+
Expect(svc.Spec.Selector).To(HaveKeyWithValue("a8s.a9s/replication-role", "master"))
201+
Expect(len(svc.Spec.Selector)).To(Equal(4))
202+
})
203+
204+
Expect(svc.Spec.Type).To(Equal(corev1.ServiceTypeClusterIP))
205+
Expect(svc.Spec.Ports[0].Name).To(Equal("patroni"))
206+
Expect(svc.Spec.Ports[0].Port).To(Equal(int32(8008)))
207+
Expect(svc.Spec.Ports[0].Protocol).To(Equal(corev1.ProtocolTCP))
208+
Expect(svc.Spec.Ports).To(HaveLen(1))
175209
})
176210

177211
By("creating the ServiceAccount", func() {
@@ -301,10 +335,10 @@ var _ = Describe("PostgreSQL Operator end-to-end tests", func() {
301335
},
302336
})).To(Succeed(), "failed to list events emitted for test DSI")
303337

304-
Expect(len(instanceEvents.Items)).To(Equal(6), "found more events than expected, "+
338+
Expect(len(instanceEvents.Items)).To(Equal(7), "found more events than expected, "+
305339
"there should be one for every secondary API object that the Operator "+
306-
"directly creates (ServiceAccount, RoleBinding, master Service, StatefulSet, "+
307-
"two Secrets)")
340+
"directly creates (ServiceAccount, RoleBinding, master Service, patroni Service, "+
341+
"StatefulSet, two Secrets)")
308342

309343
// Sort events by message so that we know for which secondary API object each event
310344
// is created w/o having to inspect the event first. *This is a hack that makes the
@@ -320,8 +354,9 @@ var _ = Describe("PostgreSQL Operator end-to-end tests", func() {
320354
adminSecretEvent := instanceEvents.Items[1]
321355
standbySecretsEvent := instanceEvents.Items[2]
322356
masterSvcEvent := instanceEvents.Items[3]
323-
svcAccountEvent := instanceEvents.Items[4]
324-
ssetEvent := instanceEvents.Items[5]
357+
patroniSvcEvent := instanceEvents.Items[4]
358+
svcAccountEvent := instanceEvents.Items[5]
359+
ssetEvent := instanceEvents.Items[6]
325360

326361
By("emitting an event for the creation of the roleBinding", func() {
327362
Expect(roleBindingEvent.Message).To(Equal("Successfully created roleBinding"),
@@ -397,6 +432,25 @@ var _ = Describe("PostgreSQL Operator end-to-end tests", func() {
397432
"wrong event involvedObject.apiVersion")
398433
})
399434

435+
By("emitting an event for the creation of the patroni service", func() {
436+
Expect(patroniSvcEvent.Message).
437+
To(Equal(fmt.Sprintf("Successfully created service: %s/%s-patroni",
438+
pg.Namespace,
439+
pg.Name)),
440+
"wrong event message")
441+
Expect(patroniSvcEvent.Type).To(Equal(corev1.EventTypeNormal),
442+
"wrong event type")
443+
Expect(patroniSvcEvent.Reason).To(Equal("Created"), "wrong event reason")
444+
Expect(patroniSvcEvent.Count).To(Equal(int32(1)), "wrong event count")
445+
Expect(patroniSvcEvent.Source.Component).To(Equal("postgresql-controller"),
446+
"wrong event source.component")
447+
Expect(patroniSvcEvent.InvolvedObject.Kind).To(Equal("Postgresql"),
448+
"wrong event involvedObject.kind")
449+
Expect(patroniSvcEvent.InvolvedObject.APIVersion).
450+
To(Equal("postgresql.anynines.com/v1beta3"),
451+
"wrong event involvedObject.apiVersion")
452+
})
453+
400454
By("emitting an event for the creation of the serviceAcccount", func() {
401455
Expect(svcAccountEvent.Message).To(Equal("Successfully created serviceAccount"),
402456
"wrong event message")
@@ -615,6 +669,35 @@ var _ = Describe("PostgreSQL Operator end-to-end tests", func() {
615669
}, asyncOpsTimeoutMins, 1*time.Second).Should(Succeed())
616670
})
617671

672+
By("Ensuring patroni service labels are updated", func() {
673+
Eventually(func(g Gomega) {
674+
svc := &corev1.Service{}
675+
Expect(k8sClient.Get(ctx,
676+
types.NamespacedName{
677+
Name: postgresql.PatroniService(
678+
instance.GetName()),
679+
Namespace: instance.GetNamespace()},
680+
svc)).To(Succeed())
681+
g.Expect(err).To(BeNil())
682+
683+
g.Expect(svc.Labels).To(HaveKeyWithValue("test-label-1", "val3"))
684+
g.Expect(svc.Labels).To(HaveKeyWithValue("test-label-4", "val4"))
685+
g.Expect(svc.Labels).To(HaveKeyWithValue("a8s.a9s/dsi-name", instance.GetName()))
686+
g.Expect(svc.Labels).
687+
To(HaveKeyWithValue("a8s.a9s/dsi-group", "postgresql.anynines.com"))
688+
g.Expect(svc.Labels).To(HaveKeyWithValue("a8s.a9s/dsi-kind", "Postgresql"))
689+
g.Expect(len(svc.Labels)).To(Equal(numA8SLabels + 2))
690+
691+
g.Expect(svc.Spec.Selector).
692+
To(HaveKeyWithValue("a8s.a9s/replication-role", "master"))
693+
g.Expect(svc.Spec.Selector).To(HaveKeyWithValue("a8s.a9s/dsi-name", instance.GetName()))
694+
g.Expect(svc.Spec.Selector).
695+
To(HaveKeyWithValue("a8s.a9s/dsi-group", "postgresql.anynines.com"))
696+
g.Expect(svc.Spec.Selector).To(HaveKeyWithValue("a8s.a9s/dsi-kind", "Postgresql"))
697+
g.Expect(len(svc.Spec.Selector)).To(Equal(numA8SLabels + 1))
698+
}, asyncOpsTimeoutMins, 1*time.Second).Should(Succeed())
699+
})
700+
618701
By("Ensuring ServiceAccount labels are updated", func() {
619702
Eventually(func(g Gomega) {
620703
sa := &corev1.ServiceAccount{}
@@ -751,6 +834,17 @@ var _ = Describe("PostgreSQL Operator end-to-end tests", func() {
751834
}, asyncOpsTimeoutMins).Should(BeTrue())
752835
})
753836

837+
By("removing the service that points to the patroni API", func() {
838+
Eventually(func() bool {
839+
err := k8sClient.Get(ctx,
840+
types.NamespacedName{
841+
Name: postgresql.PatroniService(instance.GetName()),
842+
Namespace: instance.GetNamespace()},
843+
&corev1.Service{})
844+
return err != nil && k8serrors.IsNotFound(err)
845+
}, asyncOpsTimeoutMins).Should(BeTrue())
846+
})
847+
754848
By("removing the RoleBinding between the PostgreSQL instance service account and the Spilo role", func() {
755849
Eventually(func() bool {
756850
err := k8sClient.Get(

0 commit comments

Comments
 (0)