zalando / zalando/postgres-operator

Wrong validation of KUBERNETES_SERVICE_HOST in logical backup dump.sh?

Open
#2,047 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
5.2k
Forks
1.1k
Avg merge
2d 16h
Merged PRs (30d)
3

Description

Hello,

I've recognized, that you introduced the following lines in the logical-backup images dump.sh in version 1.8.0 by commit a081173f26f2d6b7dd6408d7cee8b307fd8e6578 .

if [ "$KUBERNETES_SERVICE_HOST" != "${KUBERNETES_SERVICE_HOST#*[0-9].[0-9]}" ]; then
  echo "IPv4"
  K8S_API_URL=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1
elif [ "$KUBERNETES_SERVICE_HOST" != "${KUBERNETES_SERVICE_HOST#*:[0-9a-fA-F]}" ]; then
  echo "IPv6"
  K8S_API_URL=https://[$KUBERNETES_SERVICE_HOST]:$KUBERNETES_SERVICE_PORT/api/v1
else
  echo "Unrecognized IP format '$KUBERNETES_SERVICE_HOST'"
fi

This check leads to a problem in our environment cause KUBERNETES_SERVICE_HOST is not an IP. It's a DNS name (like api.myk8s.customer.cloud). I was wondering if this was done by intent cause normally one has an IP for his Service Host or not?
Would it be an idea to rethink this decision?

Kind regards
Philip

Please, answer some short questions which should help us to understand your problem / question better?

  • Which image of the operator are you using? e.g. registry.opensource.zalan.do/acid/postgres-operator:v1.8.2
    registry.opensource.zalan.do/acid/logical-backup:v1.8.2
  • Where do you run it - cloud or metal? Kubernetes or OpenShift? [AWS K8s | GCP ... | Bare Metal K8s]
    K8s
  • Are you running Postgres Operator in production? [yes | no]
    yes
  • Type of issue? [Bug report, question, feature request, etc.]
    Question

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the logical-backup image's dump.sh and the validation of KUBERNETES_SERVICE_HOST. Reproduce the case where the variable is a DNS name such as api.myk8s.customer.cloud, then compare it with the existing IPv4 and IPv6 cases. Done means the configured DNS name is handled without the unrecognized-format path while existing address formats continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, postgresql, shell
Domain
databases, infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.