Merge ~rmalz/charm-advanced-routing:rmalz/perform_config_during_update into charm-advanced-routing:master

Proposed by Robert Malz
Status: Needs review
Proposed branch: ~rmalz/charm-advanced-routing:rmalz/perform_config_during_update
Merge into: charm-advanced-routing:master
Diff against target: 23 lines (+7/-1)
1 file modified
src/reactive/advanced_routing.py (+7/-1)
Reviewer Review Type Date Requested Status
🤖 prod-jenkaas-bootstack (community) continuous-integration Needs Fixing
Giuseppe Petralia Needs Fixing
Eric Chen Needs Fixing
Review via email: mp+455309@code.launchpad.net

Commit message

Reapply configuration during charm update process

Description of the change

With recent change:
https://git.launchpad.net/charm-advanced-routing/commit/?id=28162e0fb93b07f3894b00ad40d2093c12bbe234
charm will create a new systemd configuration file which helps solving according issue.
However new configuration will not be applied if user upgrades charm from older version without reapplying configuration which:
A) should be either documented
B) handled within charm itself.

This patch runs a configuration routine during upgrade-charm hook.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Robert Malz (rmalz) wrote :
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Eric Chen (eric-chen) wrote :

Please check my inline comment

review: Needs Fixing
Revision history for this message
Robert Malz (rmalz) wrote :

Following guidance we will have a different behavior.
Current one will always apply configuration without notifying user about the change.

Eric proposal will put unit into blocked state and force user to run apply-changes action.
This way it will explicitly state that to finish upgrade configuration must be reapplied.

Putting this comment after DM with Eric to ramp up more discussion on this topic.

Revision history for this message
Eric Chen (eric-chen) wrote :

The default value of is_action_managed is true.

"Changes need to be applied by running the 'apply-changes' action"

In order to maintain original behavior (update won't apply new routing config until user trigger it), that's why I purpose we should follow the behavior in reconfigure_routing when there is any routing config.

In ideal case, if we know there is no new routing config, we can avoid the charm enter blocked state. That will need some extra effort.

Revision history for this message
Giuseppe Petralia (peppepetra) wrote :

Applying the routing on charm upgrade makes sense, but we should use `reconfigure_routing` to make sure this is only done when the is_action_managed is false and is_advanced_routing_enabled is true.

review: Needs Fixing
Revision history for this message
Robert Malz (rmalz) wrote :

Updated according to the discussion.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Malz (rmalz) wrote :

CI has some issues:
charmcraft internal error: LXDError(brief="failed to inject host'\''s snap '\''charmcraft'\'' into target environment.", details=None, resolution=None)
Full execution log: '\''/home/ubuntu/.local/state/charmcraft/log/charmcraft-20231117-094222.612993.log'\''
make: *** [Makefile:55: build] Error 1

Unmerged commits

b0ff7cb... by Robert Malz <email address hidden>

Reapply configuration during charm update process

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/reactive/advanced_routing.py b/src/reactive/advanced_routing.py
2index 0fc273e..005a071 100644
3--- a/src/reactive/advanced_routing.py
4+++ b/src/reactive/advanced_routing.py
5@@ -4,7 +4,7 @@ import sys
6 from advanced_routing_helper import AdvancedRoutingHelper, PolicyRoutingExists
7
8 from charms.layer import status
9-from charms.reactive import clear_flag, set_flag, when, when_not
10+from charms.reactive import clear_flag, hook, set_flag, when, when_not
11
12 from routing_validator import RoutingConfigValidatorError
13
14@@ -64,3 +64,9 @@ def reconfigure_routing():
15 return
16
17 status.active("Unit is ready")
18+
19+
20+@hook("upgrade-charm")
21+def upgrade_charm():
22+ """Perform upgrade related operations."""
23+ reconfigure_routing()

Subscribers

People subscribed via source and target branches

to all changes: