Andrey Kolkov ac00577eb7 fix(clickhouse): scheme the backup S3_ENDPOINT on the system-bucket flow (#3963)
## What this PR does

On the default `cozy-default` / `useSystemBucket` backup flow, the
ClickHouse chart pointed the `clickhouse-backup` sidecar's `S3_ENDPOINT`
straight at the projected `cozy-backups-creds.endpoint`, which the
backup credentials projector stores as a **bare host** (no scheme) by
design. `altinity/clickhouse-backup` runs `S3_ENDPOINT` through the
aws-sdk-go-v2 endpoint resolver, which rejects a scheme-less value with
`Custom endpoint 's3.host' was not a valid URI` — so every ClickHouse
backup and restore on the default flow failed. Reproduced live on a
v1.6.2 cluster: a `cozy-default` `BackupJob` against a `useSystemBucket:
true` ClickHouse hangs, and the sidecar logs `S3 ResolveEndpoint ... was
not a valid URI`.

The fix prepends `https://` on the `useSystemBucket` path via a helper
env plus `$(VAR)` expansion (a `secretKeyRef` value can't be
string-interpolated), mirroring the platform's
`backupstrategy-controller.endpoint` helper which force-prepends
`https://` for the always-TLS external S3 ingress. The legacy and
bring-your-own-Secret paths keep reading `endpoint` verbatim, since that
value is tenant-supplied and already carries its own scheme.

ClickHouse was the only `cozy-default` app hit by this. I audited every
default-flow app: the CNPG/postgres, etcd and velero strategies already
get a scheme'd URL from the endpoint helper, and mariadb and
foundationdb deliberately pair a bare host with a separate TLS flag;
mongodb reads a full URL from its own chart values. So this is the
single scheme-class fix needed.

Not addressed here (separate, non-scheme gaps surfaced during the audit,
flagged for follow-up): MongoDB has no `useSystemBucket` wiring at all
(its `cozy-default` strategy assumes a manually-configured
`backup.endpointURL` + per-app S3 creds), and FoundationDB's
self-signed-CA trust to the operator pod is a known gap.

### Screenshots

Not applicable (no UI changes).

### Downstream repositories

No schema or API change (only a chart template and its helm-unittest).
`values.yaml` / `values.schema.json` / the CRD are untouched, so nothing
downstream is affected. Leaving every box unticked per the trigger-map
guidance.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:

### Release note

```release-note
fix(clickhouse): backup and restore now work on the default system-bucket (useSystemBucket) flow — the clickhouse-backup sidecar receives a scheme'd https:// S3_ENDPOINT instead of the projected bare host, which the S3 client rejected as an invalid URI.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Corrected ClickHouse backup endpoint configuration when using the
system bucket.
* Ensured backup connections consistently use the required HTTPS
endpoint format.
* Improved handling of backup credentials across system bucket, legacy,
and custom-secret configurations.

* **Tests**
* Added coverage validating endpoint and credential wiring for supported
backup configurations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-28 15:05:14 +04:00
2025-10-08 09:43:34 +05:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

Open Source Apache-2.0 License Support Active GitHub Release GitHub Commit OpenSSF Best Practices OpenSSF Scorecard

Cozystack

Cozystack is a free platform and framework for building clouds.

Cozystack is a CNCF Sandbox Level Project that was originally built and sponsored by Ænix.

With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.

Use Cozystack to build your own cloud or provide a cost-effective development environment.

Cozystack user interface

Use-Cases

Documentation

The documentation is located on the cozystack.io website.

Read the Getting Started section for a quick start.

If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.

Versioning

Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.

Contributions

Contributions are highly appreciated and very welcomed!

In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.

You can express your intention to on the fix on your own. Commits are used to generate the changelog, and their author will be referenced in it.

If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.

Community

You are welcome to join our Telegram group and come to our weekly community meetings. Add them to your Google Calendar or iCal for convenience.

License

Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.

Commercial Support

A list of companies providing commercial support for this project can be found on official site.

Languages
Go 47.2%
Shell 37.6%
TypeScript 7%
Go Template 5.4%
Makefile 1.4%
Other 1.2%