Skip to content

feat: parameterize logs location and make etcd relation optional#445

Merged
patriciareinoso merged 17 commits intocanonical:DPE-9349-rolling-ops-maintenancefrom
patriciareinoso:DPE-9350-logs-location
Apr 24, 2026
Merged

feat: parameterize logs location and make etcd relation optional#445
patriciareinoso merged 17 commits intocanonical:DPE-9349-rolling-ops-maintenancefrom
patriciareinoso:DPE-9350-logs-location

Conversation

@patriciareinoso
Copy link
Copy Markdown

@patriciareinoso patriciareinoso commented Apr 23, 2026

Description

This PR

  1. Allows to define the base_dir where all the files related to rolling ops will be written.

We write:
- Log file for the background proces
- TLS certificates
- ETCDCTL configuration file

The new parameter is optional, if not provided we default to /var/lib/rollingops

  1. Makes the etcd_relation_name and cluter_id optional parameters. If not provided they default to None. In this case we would only be using the peer backend.

  2. Add a is_waiting function.

There are no functional changes in:

  • rollingops/src/charmlibs/rollingops/etcd/_certificates.py
  • rollingops/src/charmlibs/rollingops/etcd/_etcdctl.py

But the diff is not nicely shown in github. I changed those modules to replace static functions with objects

* patch: etcd rolling ops version

* first working version

* fix format

* fix linting

* add tenacity to integration test

* remove unnecessary logs

* add dataplatform as reviewes

* rename and add integration tests

* linting and rebase

* first part of comments

* more comments answered

* more comments answered

* fix linting job

* fix UT

* mark tests as only k8s

* fix integration tests

* use charmlibs apt

* remove sans dns

* add dependencies to .toml

* add uv lock

* add wait in itnegration tests

* increate timeout

* increase log count

* unlimited debug-log

* comments review

* fix paths

* migrate v1

* fix integration tests

* fix integration tests

* add lock and integration tests

* unify operations

* add tenacity

* draft

* fallback implementation

* add sync lock and state

* feat: advanced rolling ops using etcd (canonical#364)

## Context

All the code on this PR is new

This implementation is based on [DA241
Spec](https://docs.google.com/document/d/1ez4h6vOOyHy5mu6xDblcBt8PPAtMe7MUp75MtgG1sns/edit?tab=t.0)

- The content of
`charmlibs/advanced-rollingops/src/charmlibs/advanced_rollingops/_dp_interfaces_v1.py`
belongs to another library that is currently being migrated to charmlibs
so you can ignore it for now.

## Summary

This PR is the first part of the implementation of advanced rolling ops
at cluster level.

This PR includes:
- Management of the client certificate used to connect to etcd
- The leader unit creates a self-signed certificate with live of 50
years
  - Share the certificate with the other units using a peer relation
- Implementation of the integration with etcd
  - Share the mtls certificate
  - Observe the `resource_created` event 
  - Observe the `endpoints_changed` event
- Management of a env file needed to connecto etcd via `etcdctl`
 
This PR does not implement the locking mechanism. In here we only test
that we can connect to etcd from each unit.

## Current workflow:

1. The unit make a request
2. A new background process is spawn
3. The background process dispatches a Juju hook
4. The unit observes that hook
5. The unit writes and read a value in etcd
6. If the unit was able to connect to etcd, it executes the "restart"
function.

This is a very simplified workflow to be able to test that the units
from different apps can reach etcd.

## To do
- Implement the actual locking mechanism
- Figure out how to properly install etcdctl

* feat: migrate rollingops v1 from charm-rolling-ops repo (canonical#415)

* define syn lock backend

* fix merge

* clean up

* fix peer integration tests

* fix integration tests

* fix integration tests

* docstrings

* add update status handled and improve integration tests

* general cleanup
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
@patriciareinoso patriciareinoso changed the title patch: Dpe 9350 logs location feat: Dpe 9350 logs location Apr 23, 2026
@patriciareinoso patriciareinoso changed the title feat: Dpe 9350 logs location feat: parameterize logs location and make etcd relation optional Apr 23, 2026
@patriciareinoso patriciareinoso marked this pull request as ready for review April 24, 2026 11:52
@patriciareinoso patriciareinoso requested a review from a team as a code owner April 24, 2026 11:52
Copy link
Copy Markdown

@sinclert-canonical sinclert-canonical left a comment

Choose a reason for hiding this comment

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

🧡 Thanks for the quick iteration on MySQL's feedback. This is looking great.


Please consider that, even if making the ETCD relation optional is the greatest requirement lift you could make for library consumers (thanks again!), it is only a piece of a greater pattern:

This library is, rightfully, offering a way to deal with both:

  • Intra-application rolling-ops (thought the peer relation).
  • Inter-application rolling-ops (thought the ETCD relation).

The library is also, rightfully, offering a way to emit / react to both:

  • Synchronous events (less common within charms).
  • Asynchronous events (most common within charms).

In both scenarios, library consumers may want to deal with one, the other, or both. Therefore, the big pattern here would be to make all RollingOpsManager arguments that deal with these functionalities, optional, so each consumer can tweak the instantiation to their particular needs.

Comment thread rollingops/src/charmlibs/rollingops/_rollingops_manager.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/_rollingops_manager.py
Comment thread rollingops/src/charmlibs/rollingops/_rollingops_manager.py
Copy link
Copy Markdown
Contributor

@Gu1nness Gu1nness left a comment

Choose a reason for hiding this comment

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

Mostly moving from str to pathops.LocalPath IMHO.
Otherwise, all good.

About the is_ready is it is_waiting that you implemented ? Do that solve our problem ?

Comment thread rollingops/src/charmlibs/rollingops/common/_base_worker.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/common/_utils.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/etcd/_backend.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/etcd/_certificates.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/etcd/_etcd.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/etcd/_rollingops.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/peer/_backend.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/peer/_rollingops.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/_rollingops_manager.py Outdated
Comment thread rollingops/src/charmlibs/rollingops/_rollingops_manager.py
Copy link
Copy Markdown

@sinclert-canonical sinclert-canonical left a comment

Choose a reason for hiding this comment

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

Thanks for your tireless efforts. This is looking great!

@patriciareinoso patriciareinoso merged commit d154e98 into canonical:DPE-9349-rolling-ops-maintenance Apr 24, 2026
42 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants