fix(lease-broker): no lease held is a no-op success, not a denied transition (#1339)
ci/woodpecker/push/publish Pipeline was successful
ci/woodpecker/push/publish Pipeline was successful
This commit was merged in pull request #1339.
This commit is contained in:
@@ -54,6 +54,22 @@ def main(
|
||||
arguments = parser.parse_args(argv)
|
||||
source_environment = os.environ if environ is None else environ
|
||||
|
||||
# D29: a session that never held a lease has nothing to revoke, and that is a
|
||||
# SUCCESS, not a failed revocation. The block below is deliberately fail-closed
|
||||
# for a broker that is unreachable, which is right — but it cannot distinguish
|
||||
# "the broker is down" from "there was never a lease", so a bare-launched
|
||||
# session was denied every lifecycle transition, including compaction. Denying
|
||||
# compaction protects nothing there; it converts a recoverable context limit
|
||||
# into a lost session.
|
||||
#
|
||||
# Absence must be TOTAL to qualify. If exactly one variable is present the
|
||||
# session is half-provisioned, which is real misconfiguration, and it still
|
||||
# takes the fail-closed path below.
|
||||
lease_variables = ("MOSAIC_LEASE_BROKER_SOCKET", "MOSAIC_LEASE_SESSION_ID")
|
||||
present = [name for name in lease_variables if source_environment.get(name)]
|
||||
if not present:
|
||||
return 0
|
||||
|
||||
try:
|
||||
if not arguments.reason or len(arguments.reason) > 128:
|
||||
raise ValueError("invalid revoke reason")
|
||||
|
||||
Reference in New Issue
Block a user