Major-version upgrade preflight ignores `GetMemberData` error

Open Beginner friendly
#3,253 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, kubernetes, postgresql
Domain
backend, databases

Research direction

Read pkg/cluster/majorversionupgrade.go, especially the pod scan around line 156 and the later GetMemberData error check around line 215. Trace how failed Patroni reads affect replica logging and primary detection; done means the failure is handled clearly and a failed read cannot silently produce a false “no master” result. Add or update focused tests for these cases if the surrounding code has tests.

Written by the indexing model from the issue text.

Description

During the major-version upgrade check, majorVersionUpgrade ignores the error returned by c.patroni.GetMemberData(&pod) while scanning cluster pods, even though the same function checks GetMemberData errors a few lines later at line 215:

ps, _ := c.patroni.GetMemberData(&pod)

When the Patroni request fails in the pod loop, ps is a zero-value struct (State == "", Role == "", ServerVersion == 0), which causes two issues:

  1. If a replica read fails, ps.State is "", so the operator logs identified non running pod, potentially skipping major version upgrade without showing that the Patroni request failed.
  2. If the primary read fails, masterPod is never set and c.currentMajorVersion is not updated from the primary, so the operator logs no master in the cluster (even when a healthy primary exists) and skips the upgrade with nil error.

Is ignoring the error returned by GetMemberData at pkg/cluster/majorversionupgrade.go#L156 intentional, or should it be checked and logged/returned?

Dominant language
Go
Stars
5.3k
Forks
1.1k
Avg merge
3d 17h
Merged PRs (30d)
11

Getting set up

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.

More from zalando/postgres-operator

All issues in zalando/postgres-operator

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.