Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework postgres access, introduce automated install/upgrade tests #148

Merged
merged 28 commits into from
Jan 9, 2025

Conversation

fibbs
Copy link
Contributor

@fibbs fibbs commented Jan 8, 2025

What this PR does / why we need it:

Redesign of postgresAccess: existingSecret, keys...

In order to make the Helm Chart a bit less complex and also to be able to do a "out-of-the-box" deployment with server HA enabled, the following changes have been made:

  • postgresAccess.useUnifiedSecret has been removed. Now, ALWAYS a unified secret will be used, either an existing one supplied by the user, or one generated with a fixed name (name of the release + some suffix)
  • postgresAccess.unifiedSecretAutoCreate has been removed in favor of postgresAccess.existingSecretName. When this value is set, it will be assumed that an existing secret is already in the namespace having the DB-relevant settings in the keys specified under postgresAccess
  • postgresAccess.unifiedSecretXXXKey values are renamed into postgresAccess.secretXXXXKey for easiness. I didn't like the naming of "unifiedSecret" anymore, even I did implement this myself and I think now is a good moment to get rid
    of these value names
  • postgresAccess.passwordSecret and postgresAccess.passwordSecretKey have been removed. Either use one secret for all DB relevant settings or supply all settings, including password, in the values.yaml file
  • The DB-Init-Upgrade job will get all DB connection relevant settings handed in as literal env variables instead of references to the secret when postgresAccess.existingSecretName is not set. The reason is that the job runs as Helm "pre-install" / "pre-upgrade" job and therefore will run BEFORE any manifest would be rendered, including the secret itself... (Chicken-egg-problem)
  • Reworked readme, examples, mentioning the changes in "Breaking Changes" + some fixes of typos and such in README.md.gotmpl
  • Removed compatibility for pre-1.21 batch/v1beta1
  • Helm Chart will fail in case postgresql.enabled=true is set (internal DB) and zabbixServer.zabbixServerHA.enabled=true is also set, as this situation is not supported anymore, due to the above mentioned limitations in how Helm Jobs work.
Implemented automated tests using helm install and helm upgrade

In order to verify proper functionality of the different use cases and scenarios in which this Helm Chart should work, I have implemented automated tests for different installation and upgrade situations the Chart should work in:

  • internal database (postgresql.enabled=true), HA disabled, no existing secret supplied
  • external database, HA enabled, existing secret supplied
  • external database, HA enabled, no existing secret supplied
    In any of these scenarios, I have build tests to deploy "as simple as possible" as well as installing the latest supported LTS version of Zabbix (6.0) and upgrading to 7.0 and 7.2, respectively.

The jobs have been unified with the already existing linter jobs. They have been enabled for manual execution (in development branches in private forks, for example) and to be mandatorily running on Pull Requests.

Which issue this PR fixes

Special notes for your reviewer:

#143 is NOT yet fixed with this PR, other than previously discussed. @aeciopires I suggest as follows: we first merge this PR into main, then I start working on the labels. This way we can already use the tests introduced in this PR (they have to be in main to be working).

Checklist

  • DCO signed
  • Variables are documented in values.yaml with Helm-Docs comments, as we build README.md using this utility

Christian Anton added 27 commits December 31, 2024 17:59
In order to make the Helm Chart a bit less complex and also to be able
to do a "out-of-the-box" deployment with server HA enabled, the
following changes have been made:

- `postgresAccess.useUnifiedSecret` has been removed. Now, ALWAYS a
  unified secret will be used, either an existing one supplied by the
  user, or one generated with a fixed name (name of the release + some
  suffix)
- `postgresAccess.unifiedSecretAutoCreate` has been removed in favor
  of `postgresAccess.existingSecretName`. When this value is set, it
  will be assumed that an existing secret is already in the namespace
  having the DB-relevant settings in the keys specified under
  `postgresAccess`
- `postgresAccess.unifiedSecretXXXKey` values are renamed into `postgresAccess.secretXXXXKey` for
  easiness. I didn't like the naming of "unifiedSecret" anymore, even I
  did implement this myself and I think now is a good moment to get rid
  of these value names
- `postgresAccess.passwordSecret` and `postgresAccess.passwordSecretKey`
  have been removed. Either use one secret for all DB relevant settings
  or supply all settings, including password, in the values.yaml file
- The DB-Init-Upgrade job will get all DB connection relevant settings
  handed in as literal env variables instead of references to the secret
  when `postgresAccess.existingSecretName` is not set. The reason is
  that the job runs as Helm "pre-install" / "pre-upgrade" job and
  therefore will run BEFORE any manifest would be rendered, including
  the secret itself... (Chicken-egg-problem)

The changes mentioned above have yet been only roughly tested.

Also, documentation, examples, etc. will have to be reworked before
creating a PR out of this.
Due to the checken-and-egg problem of Helm, not being able to deploy any
manifests before actual pre-install / pre-upgrade jobs are being
executed and the need of employing exactly these due to how Zabbix
Server interacts with the database (in HA mode), we decided not to bloat
the Helm Chart with even more options but clearly refuse the combination
of "internal database" and Server HA.
in order to prepare automated testing of this helm chart, two simple
tests, verifying successful connection to zabbix server and zabbix web
frontend, have been implemented and can now be used with the "helm test
<releasename>" command.
@fibbs fibbs requested a review from aeciopires as a code owner January 8, 2025 16:11
@aeciopires aeciopires added bug Something isn't working documentation Improvements or additions to documentation labels Jan 8, 2025
@aeciopires aeciopires added the break change A change in one part of a software system that potentially causes other components to fail label Jan 8, 2025
charts/zabbix/README.md Outdated Show resolved Hide resolved
Copy link
Member

@aeciopires aeciopires left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow @fibbs!

Thanks a lot!

You made a big and great job in this PR.

Thanks, man.

I made little comments before merge.

Copy link
Member

@aeciopires aeciopires left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge this PR. Thanks again.

@fibbs fibbs merged commit b08c4f9 into zabbix-community:main Jan 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
break change A change in one part of a software system that potentially causes other components to fail bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
2 participants