Pending opened ports aren't returned by opened-ports in same hook

Bug #2008035 reported by Ben Hoyt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Medium
Nicolas Vinuesa

Bug Description

While testing the new open_ports API in Python Operator Framework (https://github.com/canonical/operator/pull/905), I found that opened-ports doesn't return the pending opened ports that have just been opened by open-port previously in the same hook execution. (It does return them correctly in the next hook execution, after they've been committed.)

This is inconsistent with how other pending objects are returned, for example pending secrets are visible to get-secret.

It makes writing charms slightly more annoying as whenever you call opened_ports() you have to think "did I just open ports in this hook? If so, merge the opened_ports() return value with what I might have just opened".

Here are some logs from a test charm showing the issue: open-port ran successfully 4 times (opening three unique ports), but then opened_ports() returned an empty set:

unit-database-0: 16:33:34 INFO unit.database/0.juju-log Running legacy hooks/start.
unit-database-0: 16:33:34 INFO unit.database/0.juju-log TODO 1 _on_start
unit-database-0: 16:33:34 INFO unit.database/0.juju-log TODO 3 success opening port 8080/tcp
unit-database-0: 16:33:34 INFO unit.database/0.juju-log TODO 5 success opening port 8080/tcp (again)
unit-database-0: 16:33:34 INFO unit.database/0.juju-log TODO 7 success opening port 8081/udp
unit-database-0: 16:33:34 INFO unit.database/0.juju-log TODO 9 success opening port icmp
unit-database-0: 16:33:34 INFO unit.database/0.juju-log TODO 11 success opened_ports: set()

Tags: hook
Ben Hoyt (benhoyt)
description: updated
tags: added: hook
Changed in juju:
importance: Undecided → Medium
milestone: none → 3.1.2
status: New → Triaged
assignee: nobody → Nicolas Vinuesa (nvinuesa)
Changed in juju:
status: Triaged → In Progress
Changed in juju:
milestone: 3.1.2 → 3.1.1
Revision history for this message
Nicolas Vinuesa (nvinuesa) wrote :
Changed in juju:
status: In Progress → Fix Committed
Harry Pidcock (hpidcock)
Changed in juju:
milestone: 3.1.1 → 3.1.2
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.