Repository navigation
Fix Portainer stack discovery and update environment handling - #137
Merged
Merged
Conversation
…pdates that keep what runs Stacks are recovered from what the machine runs and each gets an owner: Portainer (known by its /data/compose/<id> directory — Portainer writes no label of its own) or compose. Update is the owner's own act: Portainer's API (environment and stored git credentials handed back, deployment waited out), compose pull + up -d with the recorded files, or, with neither, a pull and an Engine-level recreation of each container that keeps its settings, volumes and aliases and puts the old one back if the new one does not stay up. A Portainer on the machine is found from its container; connecting it reads and pins its certificate. Check for updates compares registry digests through the daemon. The panel is rewritten: summary, stacks with what Update will do, containers, images, volumes and networks, Portainer. Fixed on the way (BUGSVULNS 110-113): Portainer stacks never recognised; a Portainer redeploy erased the stack's environment; a stack update reported failed after 25 s; the Docker and Logs panels never loaded on open; a token accepted over plain HTTP to any host; compose assumed from a docker binary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018DwLKZQBnKWkWwTCQ2RKCW
Keeps main's BUGSVULNS 110-116 and renumbers this branch's entries 117-120, with the references to them; version 0.4.116, one step past main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018DwLKZQBnKWkWwTCQ2RKCW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes critical defects in Docker stack management that prevented Portainer stacks from being recognized and caused their environment variables to be erased during updates. The changes refactor stack discovery and update logic into a new dedicated module while fixing the underlying issues.
Key Changes
New module
fleet_stacks.py: Extracted and rewrote stack discovery and update logic fromfleet_docker.py. This module now:/data/compose/<id>) rather than a non-existent labelFixed Portainer stack recognition: Portainer does not write
io.portainer.stack.namelabels on containers. Stacks are now correctly identified by their working directory path matching the pattern/data/compose/<id>, with the numeric ID extracted for exact matching against Portainer's records.Fixed environment preservation: When updating a Portainer stack through Portainer's API, the stack's environment (stored in Portainer's database) is now handed back on redeploy rather than being lost.
Refactored Docker panel UI: Replaced card-based layout with tabbed navigation (Stacks, Containers, Images, Volumes & Networks, Portainer) for better organization and scalability.
Improved operation handling: Separated fast Docker reads from slow operations (pulls, updates, deploys) with independent concurrency limits, allowing the UI to remain responsive while long operations run.
Updated
fleet_docker.py: Removed stack-specific logic, keeping only Engine API operations. Removed unused labels (LABEL_CONFIG,LABEL_WORKDIR,LABEL_PORTAINER).Enhanced testing: Added comprehensive test suite in
test_fleet_stacks.pycovering:Notable Implementation Details
https://claude.ai/code/session_018DwLKZQBnKWkWwTCQ2RKCW