Skip to content

wip: Service manager #3134

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Williangalvani
Copy link
Member

@Williangalvani Williangalvani commented Feb 8, 2025

fix #2868

needs some cleanup
image

Summary by Sourcery

Add a service management section to the settings menu, allowing users to enable or disable BlueOS services.

New Features:

  • Introduce a service management section in the settings menu to enable and disable BlueOS services.

Tests:

  • Updated snapshots.

Copy link

sourcery-ai bot commented Feb 8, 2025

Reviewer's Guide by Sourcery

This pull request implements a work-in-progress service manager feature by modifying both frontend and backend components. On the frontend, it updates the SettingsMenu layout to integrate a new ServiceDisabler component for toggling service states. On the backend, it adds new API endpoints in the commander and versionchooser services to manage environment variables and control (kill/restart) services. Additional utility functions and service definitions have been added to support these operations, along with corresponding OpenAPI spec updates and minor UI/styling improvements.

Sequence diagram for ServiceDisabler toggle interaction

sequenceDiagram
  actor User
  participant SD as ServiceDisabler
  participant CS as CommanderStore
  participant API as Commander API
  participant VAPI as VersionChooser API

  User->>SD: Toggle service switch (e.g., disable/enable 'autopilot')
  alt Service Disable
    SD->>CS: killService('autopilot')
    CS->>API: POST /services/kill(service_name='autopilot', i_know_what_i_am_doing=true)
    API-->>CS: 200 OK
  else Service Enable
    SD->>CS: restartService('autopilot')
    CS->>API: POST /services/restart(service_name='autopilot', i_know_what_i_am_doing=true)
    API-->>CS: 200 OK
  end

  SD->>CS: Retrieve current environment variables
  CS->>API: GET /environment_variables
  API-->>CS: Environment variables
  CS->>VAPI: GET /version-chooser/v1.0/version/environment_variables
  VAPI-->>CS: Version environment variables

  alt Service Disable
    CS->>API: POST /version-chooser/v1.0/version/environment_variables
      note right of API: Update disable list to include service
  else Service Enable
    CS->>API: POST /version-chooser/v1.0/version/environment_variables
      note right of API: Update disable list to remove service
  end

  SD-->>User: Display success notification
Loading

Updated CommanderStore & Service Definitions Class Diagram

classDiagram
  class CommanderStore {
    +getVersionChooserEnvironmentVariables() : Promise<Record<string, unknown> | undefined>
    +setVersionChooserEnvironmentVariables(variables: Record<string, unknown>) : Promise<void>
    +setEnvironmentVariables(variables: Record<string, unknown>) : Promise<void>
    +killService(service: string) : Promise<void>
    +restartService(service: string) : Promise<void>
  }

  class Service {
    +command : string
    +memory_limit : int
    +priority : bool
  }

  note for Service "Represents a BlueOS service with command, memory limit, and priority attributes."

  note for CommanderStore "Manages API interactions for service state updates and environment variable operations."
Loading

File-Level Changes

Change Details Files
Updated the frontend SettingsMenu with UI layout improvements and ServiceDisabler integration.
  • Reorganized SettingsMenu using v-row and v-col for a more responsive layout.
  • Modified dialog properties in SettingsMenu (max-width set to 50%, added scrollable attribute).
  • Repositioned and encapsulated Reset Settings, log file management, and vehicle configuration wizard actions.
  • Integrated the new ServiceDisabler component for managing service states.
core/frontend/src/components/app/SettingsMenu.vue
Added new API functions and adjusted existing ones in the commander store.
  • Imported axios and updated call timeouts for environment variable retrieval.
  • Added functions to get and set version chooser environment variables.
  • Introduced new functions for killing and restarting services via axios calls.
core/frontend/src/store/commander.ts
Introduced new API endpoints in the commander service for service control.
  • Added endpoints to kill and restart services using tmux commands.
  • Enhanced logging and response messaging for service control endpoints.
core/services/commander/main.py
Enhanced the versionchooser service with environment variable management capabilities.
  • Updated the OpenAPI spec to include GET and POST endpoints for environment variables.
  • Implemented asynchronous functions in chooser.py to get and set environment variables from a configuration file.
  • Added corresponding endpoints in versionchooser main.py to utilize new environment variable handlers.
core/services/versionchooser/openapi/versionchooser.yaml
core/services/versionchooser/utils/chooser.py
core/services/versionchooser/main.py
Introduced a new ServiceDisabler Vue component for frontend service management.
  • Implemented a switch-based UI for toggling service states with Vue.js.
  • Included tooltips providing details about each service and their impact.
  • Added logic to update environment variables and restart or kill services based on user interactions.
core/frontend/src/components/settings/serviceDisabler.vue
Added centralized service definitions for BlueOS services.
  • Created a new module to define service commands, memory limits, and priority status.
  • Provided helper functions to retrieve priority and regular service lists and to get a specific service definition.
core/services/commander/service_definitions.py
Minor update in network manager configuration for WiFi connectivity.
  • Added configuration for ipv6 with mode disabled in the networkmanager file.
core/services/wifi/wifi_handlers/networkmanager/networkmanager.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Williangalvani Williangalvani force-pushed the service-manager branch 2 times, most recently from cf31246 to 5b62ae4 Compare February 8, 2025 19:45
@Williangalvani
Copy link
Member Author

@ES-Alexander mentioned this should probably be on "available services" instead. that does mean we need to make sure the "tmux" names of the services can be properly mapped to the available services entries

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.

core: frontend: allow disabling core services
1 participant