From 051aaec4c349cc8e8c74012d534fdd43006e0d98 Mon Sep 17 00:00:00 2001
From: Richard Kojedzinszky <richard@kojedz.in>
Date: Sat, 23 Mar 2024 20:56:10 +0100
Subject: [PATCH] fix(upgrade): jobs inherit more settings from final
 StatefulSet

---
 private/upgrade/primary.go          | 7 +++++--
 private/upgrade/secondary-client.go | 7 +++++--
 private/upgrade/secondary-stream.go | 5 ++++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/private/upgrade/primary.go b/private/upgrade/primary.go
index 38d4e79..a334bdc 100644
--- a/private/upgrade/primary.go
+++ b/private/upgrade/primary.go
@@ -158,8 +158,11 @@ func (primaryUpgradeHandler) handle(ctx pcontext.Context, p *v1alpha1.PatroniPos
 								},
 							},
 						},
-						RestartPolicy:   v1.RestartPolicyOnFailure,
-						SecurityContext: security.DatabasePodSecurityContext,
+						RestartPolicy:    v1.RestartPolicyOnFailure,
+						SecurityContext:  security.DatabasePodSecurityContext,
+						ImagePullSecrets: p.Spec.ImagePullSecrets,
+						NodeSelector:     p.Spec.NodeSelector,
+						Tolerations:      p.Spec.Tolerations,
 					},
 				},
 			},
diff --git a/private/upgrade/secondary-client.go b/private/upgrade/secondary-client.go
index 156001d..b8b4445 100644
--- a/private/upgrade/secondary-client.go
+++ b/private/upgrade/secondary-client.go
@@ -112,8 +112,11 @@ func upgradeSecondariesEnsureseclients(ctx pcontext.Context, p *v1alpha1.Patroni
 									},
 								},
 							},
-							RestartPolicy:   v1.RestartPolicyOnFailure,
-							SecurityContext: security.DatabasePodSecurityContext,
+							RestartPolicy:    v1.RestartPolicyOnFailure,
+							SecurityContext:  security.DatabasePodSecurityContext,
+							ImagePullSecrets: p.Spec.ImagePullSecrets,
+							NodeSelector:     p.Spec.NodeSelector,
+							Tolerations:      p.Spec.Tolerations,
 						},
 					},
 				},
diff --git a/private/upgrade/secondary-stream.go b/private/upgrade/secondary-stream.go
index 98ec306..8a9b8a9 100644
--- a/private/upgrade/secondary-stream.go
+++ b/private/upgrade/secondary-stream.go
@@ -118,7 +118,10 @@ func upgradeSecondariesEnsurestreamer(ctx pcontext.Context, p *v1alpha1.PatroniP
 								},
 							},
 						},
-						SecurityContext: security.DatabasePodSecurityContext,
+						SecurityContext:  security.DatabasePodSecurityContext,
+						ImagePullSecrets: p.Spec.ImagePullSecrets,
+						NodeSelector:     p.Spec.NodeSelector,
+						Tolerations:      p.Spec.Tolerations,
 					},
 				},
 			},