Commit graph

7 commits

Author SHA1 Message Date
Ben Schumacher
3df25e6904
[MM-65830] Fix mmctl system status exit code for health check failures (#33970)
* [MM-65830] Fix mmctl system status exit code for health check failures

Make mmctl system status return non-zero exit codes when health checks fail.
This addresses the customer blocker issue where AWS ECS health checks were
broken after the distroless Docker image change, as they rely on exit codes
to determine service health.

Changes:
- Return error (non-zero exit) when server status != "OK"
- Return error when database_status != "OK"
- Return error when filestore_status != "OK"
- Return success (exit code 0) only when all components are healthy
- Add comprehensive test coverage for all health check scenarios
- Maintain backward compatibility for missing status fields

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [MM-65830] Refactor mmctl system status to exit silently on health failures

Update mmctl system status to exit with code 1 when components are unhealthy
without outputting error messages. This addresses the customer blocker where
AWS ECS health checks were broken after the distroless Docker image change,
as they rely on exit codes to determine service health.

Changes:
- Add withClientAndExitCode wrapper for commands returning (bool, error)
- Modify systemStatusCmdF to return (bool, error) instead of error
- Return (true, nil) when any component is unhealthy (causes exit code 1)
- Return (false, nil) when all components are healthy (causes exit code 0)
- Return (false, error) for actual API/network failures
- Always print status information before checking health
- Update comprehensive test coverage for all scenarios

The refactored approach uses a clean adapter pattern that converts (bool, error)
signatures to standard error returns while delegating to existing withClient
infrastructure to avoid code duplication.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [MM-65830] Ensure printer output is flushed before exit

Add printer.Flush() call before os.Exit(1) in withClientAndExitCode wrapper
to ensure all buffered output is properly written before the program exits.
This ensures status information is always displayed to users even when
exiting with non-zero exit codes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add godoc comment

* Output content then error out

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-06 10:49:46 +00:00
Ben Schumacher
ae35dd93a9
[MM-64844] Remove deprecated mmctl commands and flags (#33435)
* Remove deprecated mmctl commands and flags

  Remove the following deprecated commands:
  - `channel add` (use `channel users add`)
  - `channel remove` (use `channel users remove`)
  - `channel restore` (use `channel unarchive`)
  - `channel make-private` (use `channel modify --private`)
  - `command delete` (use `command archive`)
  - `permissions show` (use `permissions role show`)

  Remove the following deprecated flags:
  - `--config-path` (use `--config`)
  - `--display_name` (use `--display-name`)
  - `--system_admin` (use `--system-admin`)
  - `--email_verified` (use `--email-verified`)
  - `--attachments` from export create
  - `--resume` from export download
2025-07-18 11:08:29 +02:00
Seth Foss
2117a4ed30
MM-56632 Display warning if requested mage size exceeds max (#26022) (#27216) 2024-11-06 15:45:56 +01:00
Ben Schumacher
213ebc57fb
Print panic message when mmctl panics (#27390) 2024-07-02 13:58:37 +02:00
Nathan
44f3482fee
Trims whitespace from command arguments in RootCmd (#24218)
- Prevents commands from receiving potential whitespace characters
- Adds a new root test case ensuring various whitespace characters are removed

Co-authored-by: Nathan Geist <ngeist@spiria.com>
2023-08-17 10:19:09 +02:00
Agniva De Sarker
efaa6264cc
MM-53032: Fix module path after repo rename (#23689)
It was a good decision in hindsight to keep the public module as 0.x
because this would have been a breaking change again.

https://mattermost.atlassian.net/browse/MM-53032
```release-note
Changed the Go module path from github.com/mattermost/mattermost-server/server/v8 to github.com/mattermost/mattermost/server/v8.

For the public facing module, it's path is also changed from github.com/mattermost/mattermost-server/server/public to github.com/mattermost/mattermost/server/public
```
2023-06-11 10:54:35 +05:30
Miguel de la Cruz
951456c780
Includes mmctl into the mono-repo (#23091)
* Includes mmctl into the mono-repo

* Update to use the new public module paths

* Adds docs check to the mmctl CI

* Fix public utils import path

* Tidy up modules

* Fix linter

* Update CI tasks to use the new file structure

* Update CI references
2023-06-05 12:42:55 +02:00