Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for 'swarm' backend in schema ,cli and core extensions #149

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

sanjay7178
Copy link
Contributor

@sanjay7178 sanjay7178 commented Mar 4, 2025

This PR implements support for Docker Swarm commands in Sugar, expanding its capabilities beyond Docker Compose.

As this PR might be take prolong time to complete support Swarm to Sugar

Solve for #126 and #124

How to test these changes

These are the currently working CLI commands

sugar swarm init # Initialize a swarm
sugar swarm --help # Sugar swarm help manual
sugar swarm node [COMMAND] # Implemented swarm multiple node management , Note: replace [COMMAND] with args from `sugar swarm node --help`

Pull Request checklists

This PR is a:

  • new feature

PR Checklist:

  • Add unit tests for swarm functionality (tests/unit/extensions/test_swarm.py)
  • Add smoke tests for swarm commands in .makim.yaml
  • Docker Swarm visualizer using the Docker Engine API , Textual/Rich and Plotille (ie ..TUI Integration)
  • Updated core.py to integrate the swarm extension
  • Added proper documentation for all commands.

Sugar Swarm CLI Specific Checklist :

  • sugar swarm init - Initialize a swarm
  • sugar swarm join - Join a swarm as a node and/or manager
  • sugar swarm create - Create a new service
  • sugar swarm inspect - Display detailed information on services
  • sugar swarm logs - Fetch service/task logs
  • sugar swarm ls - List services
  • sugar swarm ps - List service tasks
  • sugar swarm rm - Remove services
  • sugar swarm rollback - Revert service configuration changes
  • sugar swarm scale - Scale replicated services
  • sugar swarm update - Update services
  • sugar swarm node - Manage Swarm nodes

Additional information

Screenshots attached as far current progress

image
image

Copy link
Member

@xmnlab xmnlab 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 working on that @sanjay7178
I added a few comments here.
also please add some tests on ci

@sanjay7178
Copy link
Contributor Author

Thanks for working on that @sanjay7178
I added a few comments here.
also please add some tests on ci

Thanks , sure by this end of day I'll make changes

@xmnlab
Copy link
Member

xmnlab commented Mar 7, 2025

Hi @sanjay7178 , could you please rebase this branch on top of the upstream/main?

I just pushed this new mechanism: #157

you maybe could use that for the node command

@sanjay7178
Copy link
Contributor Author

Hi @sanjay7178 , could you please rebase this branch on top of the upstream/main?

I just pushed this new mechanism: #157

you maybe could use that for the node command

Sure ivan

Copy link
Member

@xmnlab xmnlab left a comment

Choose a reason for hiding this comment

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

I will review more carefully soon ... but I am already sharing some comments here
thanks for working on that

# Test node commands
sugar ${{ vars.SUGAR_FLAGS }} node ls
NODE_ID=$(docker node ls --format "{{.ID}}" | head -n1)
sugar ${{ vars.SUGAR_FLAGS }} node inspect --options $NODE_ID
Copy link
Member

Choose a reason for hiding this comment

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

I was expecting something like

          # sugar ${{ vars.SUGAR_FLAGS }} swarm create --service my-nginx --options --name my-web nginx:latest
          # sugar ${{ vars.SUGAR_FLAGS }} swarm ls
          # sugar ${{ vars.SUGAR_FLAGS }} swarm inspect --services my-web
          # sugar ${{ vars.SUGAR_FLAGS }} swarm ps --services my-web
          # sugar ${{ vars.SUGAR_FLAGS }} swarm scale --services my-web --options my-web=2
          # sugar ${{ vars.SUGAR_FLAGS }} swarm update --services my-web --options --replicas 1
          # Test node commands
          sugar ${{ vars.SUGAR_FLAGS }} swarm node ls
          NODE_ID=$(docker node ls --format "{{.ID}}" | head -n1)
          sugar ${{ vars.SUGAR_FLAGS }} swarm node inspect --options $NODE_ID

in other words, after flag ${{ vars.SUGAR_FLAGS }}, I would expect the command swarm

Copy link
Member

Choose a reason for hiding this comment

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

@sanjay7178 , a friendly reminder about this comment

@xmnlab
Copy link
Member

xmnlab commented Mar 13, 2025

@sanjay7178 , please ping me again when this pr is ready for review.

@sanjay7178
Copy link
Contributor Author

@sanjay7178 , please ping me again when this pr is ready for review.

Sure 😊

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.

2 participants