Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 controllers/postgres_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ func (r *PostgresReconciler) updatePatroniReplicationConfigOnAllPods(log logr.Lo
log.V(debugLogLevel).Info("no spilo pods found at all, requeueing")
return errors.New("no spilo pods found at all")
} else if len(pods.Items) < int(instance.Spec.NumberOfInstances) {
log.V(debugLogLevel).Info("expected %d pods, but only found %d (might be ok if it is still creating)", instance.Spec.NumberOfInstances, len(pods.Items))
log.V(debugLogLevel).Info("unexpected number of pods (might be ok if it is still creating)")
}

// iterate all spilo pods
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func main() {

if enableFsGroupChangePolicyWebhook {
svcClusterMgr.GetWebhookServer().Register(
"/mutate-apps-v1-statefulset",
"/mutate-v1-pod",
&webhook.Admission{
Handler: &webhooks.FsGroupChangePolicySetter{
SvcClient: svcClusterMgr.GetClient(),
Expand Down
13 changes: 6 additions & 7 deletions pkg/webhooks/fsGroupChangePolicySetter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"github.com/go-logr/logr"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand All @@ -26,21 +25,21 @@ func (a *FsGroupChangePolicySetter) Handle(ctx context.Context, req admission.Re
log := a.Log.WithValues("name", req.Name, "ns", req.Namespace)
log.V(1).Info("handling admission request")

sts := &appsv1.StatefulSet{}
err := a.Decoder.Decode(req, sts)
pod := &v1.Pod{}
err := a.Decoder.Decode(req, pod)
if err != nil {
log.Error(err, "failed to decode request")
return admission.Errored(http.StatusBadRequest, err)
}

// when the fsGroup field is set, also set the fsGroupChangePolicy to OnRootMismatch
if sts.Spec.Template.Spec.SecurityContext != nil && sts.Spec.Template.Spec.SecurityContext.FSGroup != nil {
if pod.Spec.SecurityContext != nil && pod.Spec.SecurityContext.FSGroup != nil {
p := v1.FSGroupChangeOnRootMismatch
sts.Spec.Template.Spec.SecurityContext.FSGroupChangePolicy = &p
log.V(1).Info("Mutating StatefulSet", "sts", sts)
pod.Spec.SecurityContext.FSGroupChangePolicy = &p
log.V(1).Info("Mutating Pod", "pod", pod)
}

marshaledSts, err := json.Marshal(sts)
marshaledSts, err := json.Marshal(pod)
if err != nil {
log.Error(err, "failed to marshal response")
return admission.Errored(http.StatusInternalServerError, err)
Expand Down
Loading