Skip to content

feat(bladectl): add more bladectl commands #91

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

Merged
merged 3 commits into from
Jun 6, 2025

Conversation

cedi
Copy link
Member

@cedi cedi commented Jun 6, 2025

This PR introduces a comprehensive set of new subcommands to bladectl, expanding its capabilities for querying and managing compute blade state. It also includes an internal refactor to simplify interface management across the gRPC API.

  • get

    • fan: Returns current fan speed.
    • identify: Indicates whether the identify mode is active.
    • stealth: Shows if stealth mode is currently enabled.
    • status: Prints a full blade status report.
    • temperature: Retrieves current SoC temperature.
    • critical: Shows whether critical mode is active.
    • power: Reports the current power source (e.g., PoE+ or USB).
  • set

    • stealth: Enables stealth mode.
  • remove

    • stealth: Disables stealth mode.
  • describe

    • fan: Outputs the current fan curve configuration.
  • monitor: plot some charts about the state of the compute-blade-agent

  • gRPC API refactor: The gRPC service definitions previously located in internal/api have been folded into internal/agent. This eliminates redundant interface declarations and ensures that all ComputeBladeAgent implementations are directly compatible with the gRPC API. This reduces duplication and improves long-term maintainability and clarity of the interface contract.

bladectl set fan --percent 90 --blade 1 --blade 2
bladectl unset identify --blade 1 --blade 2 --blade 3 --blade 4
bladectl set stealth --blade 1 --blade 2 --blade 3 --blade 4
bladectl get status --blade 1 --blade 2 --blade 3 --blade 4
┌───────┬─────────────┬────────────────────┬───────────────┬──────────────┬──────────┬───────────────┬──────────────┐
│ BLADE │ TEMPERATURE │ FAN SPEED OVERRIDE │ FAN SPEED     │ STEALTH MODE │ IDENTIFY │ CRITICAL MODE │ POWER STATUS │
├───────┼─────────────┼────────────────────┼───────────────┼──────────────┼──────────┼───────────────┼──────────────┤
│ 1     │ 50°C        │ 90%                │ 5825 RPM(90%) │ Active       │ Off      │ Off           │ poe+         │
│ 2     │ 48°C        │ 90%                │ 5825 RPM(90%) │ Active       │ Off      │ Off           │ poe+         │
│ 3     │ 49°C        │ Not set            │ 4643 RPM(56%) │ Active       │ Off      │ Off           │ poe+         │
│ 4     │ 49°C        │ Not set            │ 4774 RPM(58%) │ Active       │ Off      │ Off           │ poe+         │
└───────┴─────────────┴────────────────────┴───────────────┴──────────────┴──────────┴───────────────┴──────────────┘
bladectl rm stealth --blade 1 --blade 2 --blade 3 --blade 4
bladectl rm fan --blade 1 --blade 2 --blade 3 --blade 4
bladectl get status --blade 1 --blade 2 --blade 3 --blade 4
┌───────┬─────────────┬────────────────────┬───────────────┬──────────────┬──────────┬───────────────┬──────────────┐
│ BLADE │ TEMPERATURE │ FAN SPEED OVERRIDE │ FAN SPEED     │ STEALTH MODE │ IDENTIFY │ CRITICAL MODE │ POWER STATUS │
├───────┼─────────────┼────────────────────┼───────────────┼──────────────┼──────────┼───────────────┼──────────────┤
│ 1     │ 51°C        │ Not set            │ 5177 RPM(66%) │ Off          │ Off      │ Off           │ poe+         │
│ 2     │ 49°C        │ Not set            │ 5177 RPM(58%) │ Off          │ Off      │ Off           │ poe+         │
│ 3     │ 50°C        │ Not set            │ 4659 RPM(60%) │ Off          │ Off      │ Off           │ poe+         │
│ 4     │ 48°C        │ Not set            │ 4659 RPM(54%) │ Off          │ Off      │ Off           │ poe+         │
└───────┴─────────────┴────────────────────┴───────────────┴──────────────┴──────────┴───────────────┴──────────────┘

when having multiple compute-blades in your bladeconfig:

blades:
    - name: 1
      blade:
        server: blade-pi1:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 2
      blade:
        server: blade-pi2:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 3
      blade:
        server: blade-pi3:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 4
      blade:
        server: blade-pi4:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 4
      blade:
        server: blade-pi4:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
current-blade: 1

should help with #5
closes #4
closes #9 (at least partially)

@github-actions github-actions bot added enhancement New feature or request api API related changes cli CLI related changes agent agent related changes hardware changes related to hardware interactions util changes related to utilities labels Jun 6, 2025
@cedi cedi marked this pull request as ready for review June 6, 2025 17:51
@cedi cedi force-pushed the feature/add_mode_bladectl_cmds branch from 2608d84 to c0bde16 Compare June 6, 2025 17:52
@cedi cedi requested a review from xvzf June 6, 2025 17:52
@cedi cedi force-pushed the feature/add_mode_bladectl_cmds branch from c0bde16 to b2eeb71 Compare June 6, 2025 20:32
cedi added 2 commits June 6, 2025 22:55
This PR introduces a comprehensive set of new subcommands to bladectl, expanding its capabilities for querying and managing compute blade state. It also includes an internal refactor to simplify interface management across the gRPC API.

* `get`
	* `fan`: Returns current fan speed.
	* `identify`: Indicates whether the identify mode is active.
	* `stealth`: Shows if stealth mode is currently enabled.
	* `status`: Prints a full blade status report.
	* `temperature`: Retrieves current SoC temperature.
	* `critical`: Shows whether critical mode is active.
	* `power`: Reports the current power source (e.g., PoE+ or USB).
* `set`
	* `stealth`: Enables stealth mode.
* `remove`
	* `stealth`: Disables stealth mode.
* `describe`
	* `fan`: Outputs the current fan curve configuration.
* `monitor`: plot some charts about the state of the compute-blade-agent

* **gRPC API refactor**: The gRPC service definitions previously located in `internal/api` have been folded into `internal/agent`. This eliminates redundant interface declarations and ensures that all ComputeBladeAgent implementations are directly compatible with the gRPC API.
This reduces duplication and improves long-term maintainability and clarity of the interface contract.

```bash
bladectl set fan --percent 90 --blade 1 --blade 2
bladectl unset identify --blade 1 --blade 2 --blade 3 --blade 4
bladectl set stealth --blade 1 --blade 2 --blade 3 --blade 4
bladectl get status --blade 1 --blade 2 --blade 3 --blade 4
┌───────┬─────────────┬────────────────────┬───────────────┬──────────────┬──────────┬───────────────┬──────────────┐
│ BLADE │ TEMPERATURE │ FAN SPEED OVERRIDE │ FAN SPEED     │ STEALTH MODE │ IDENTIFY │ CRITICAL MODE │ POWER STATUS │
├───────┼─────────────┼────────────────────┼───────────────┼──────────────┼──────────┼───────────────┼──────────────┤
│ 1     │ 50°C        │ 90%                │ 5825 RPM(90%) │ Active       │ Off      │ Off           │ poe+         │
│ 2     │ 48°C        │ 90%                │ 5825 RPM(90%) │ Active       │ Off      │ Off           │ poe+         │
│ 3     │ 49°C        │ Not set            │ 4643 RPM(56%) │ Active       │ Off      │ Off           │ poe+         │
│ 4     │ 49°C        │ Not set            │ 4774 RPM(58%) │ Active       │ Off      │ Off           │ poe+         │
└───────┴─────────────┴────────────────────┴───────────────┴──────────────┴──────────┴───────────────┴──────────────┘
bladectl rm stealth --blade 1 --blade 2 --blade 3 --blade 4
bladectl rm fan --blade 1 --blade 2 --blade 3 --blade 4
bladectl get status --blade 1 --blade 2 --blade 3 --blade 4
┌───────┬─────────────┬────────────────────┬───────────────┬──────────────┬──────────┬───────────────┬──────────────┐
│ BLADE │ TEMPERATURE │ FAN SPEED OVERRIDE │ FAN SPEED     │ STEALTH MODE │ IDENTIFY │ CRITICAL MODE │ POWER STATUS │
├───────┼─────────────┼────────────────────┼───────────────┼──────────────┼──────────┼───────────────┼──────────────┤
│ 1     │ 51°C        │ Not set            │ 5177 RPM(66%) │ Off          │ Off      │ Off           │ poe+         │
│ 2     │ 49°C        │ Not set            │ 5177 RPM(58%) │ Off          │ Off      │ Off           │ poe+         │
│ 3     │ 50°C        │ Not set            │ 4659 RPM(60%) │ Off          │ Off      │ Off           │ poe+         │
│ 4     │ 48°C        │ Not set            │ 4659 RPM(54%) │ Off          │ Off      │ Off           │ poe+         │
└───────┴─────────────┴────────────────────┴───────────────┴──────────────┴──────────┴───────────────┴──────────────┘
```

when having multiple compute-blades in your bladeconfig:

```yaml
blades:
    - name: 1
      blade:
        server: blade-pi1:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 2
      blade:
        server: blade-pi2:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 3
      blade:
        server: blade-pi3:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 4
      blade:
        server: blade-pi4:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 4
      blade:
        server: blade-pi4:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
current-blade: 1
```

Fixes #4, #9 (partially), should help with #5
@cedi cedi force-pushed the feature/add_mode_bladectl_cmds branch from b2eeb71 to bc3c8c7 Compare June 6, 2025 20:55
Copy link
Contributor

github-actions bot commented Jun 6, 2025

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/compute-blade-community/compute-blade-agent/api/bladeapi/v1alpha1 0.00% (ø)
github.com/compute-blade-community/compute-blade-agent/cmd/agent 0.00% (ø)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl 0.00% (ø)
github.com/compute-blade-community/compute-blade-agent/internal/agent 0.00% (ø)
github.com/compute-blade-community/compute-blade-agent/internal/api 0.00% (ø)
github.com/compute-blade-community/compute-blade-agent/pkg/agent 100.00% (ø)
github.com/compute-blade-community/compute-blade-agent/pkg/fancontroller 100.00% (ø)
github.com/compute-blade-community/compute-blade-agent/pkg/hal 0.00% (ø)
github.com/compute-blade-community/compute-blade-agent/pkg/ledengine 76.67% (+4.25%) 👍
github.com/compute-blade-community/compute-blade-agent/pkg/util 85.19% (+85.19%) 🌟

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/compute-blade-community/compute-blade-agent/api/bladeapi/v1alpha1/blade.pb.go 0.00% (ø) 182 (+38) 0 182 (+38)
github.com/compute-blade-community/compute-blade-agent/api/bladeapi/v1alpha1/blade_grpc.pb.go 0.00% (ø) 92 (+15) 0 92 (+15)
github.com/compute-blade-community/compute-blade-agent/cmd/agent/main.go 0.00% (ø) 91 (+17) 0 91 (+17)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_fan.go 0.00% (ø) 82 (+74) 0 82 (+74)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_get_misc.go 0.00% (ø) 40 (+40) 0 40 (+40)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_identify.go 0.00% (ø) 39 (+16) 0 39 (+16)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_monitor.go 0.00% (ø) 70 (+70) 0 70 (+70)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_root.go 0.00% (ø) 73 (+18) 0 73 (+18)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_status.go 0.00% (ø) 16 (+16) 0 16 (+16)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_stealth.go 0.00% (ø) 30 (+30) 0 30 (+30)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/cmd_verbs.go 0.00% (ø) 4 (+2) 0 4 (+2)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/main.go 0.00% (ø) 17 (+5) 0 17 (+5)
github.com/compute-blade-community/compute-blade-agent/cmd/bladectl/util.go 0.00% (ø) 28 (+28) 0 28 (+28)
github.com/compute-blade-community/compute-blade-agent/internal/agent/agent.go 0.00% (ø) 106 (-48) 0 106 (-48)
github.com/compute-blade-community/compute-blade-agent/internal/agent/api.go 0.00% (ø) 51 (+51) 0 51 (+51)
github.com/compute-blade-community/compute-blade-agent/internal/agent/api_certificates.go 0.00% (ø) 122 (+122) 0 122 (+122)
github.com/compute-blade-community/compute-blade-agent/internal/agent/handler.go 0.00% (ø) 31 (+31) 0 31 (+31)
github.com/compute-blade-community/compute-blade-agent/internal/agent/options.go 0.00% (ø) 5 (+5) 0 5 (+5)
github.com/compute-blade-community/compute-blade-agent/internal/agent/utils.go 0.00% (ø) 6 (+6) 0 6 (+6)
github.com/compute-blade-community/compute-blade-agent/internal/api/api.go 0.00% (ø) 0 (-49) 0 0 (-49)
github.com/compute-blade-community/compute-blade-agent/internal/api/config.go 0.00% (ø) 0 0 0
github.com/compute-blade-community/compute-blade-agent/internal/api/options.go 0.00% (ø) 0 (-11) 0 0 (-11)
github.com/compute-blade-community/compute-blade-agent/pkg/agent/agent.go 0.00% (ø) 0 0 0
github.com/compute-blade-community/compute-blade-agent/pkg/agent/config.go 0.00% (ø) 0 0 0
github.com/compute-blade-community/compute-blade-agent/pkg/fancontroller/fancontroller.go 100.00% (ø) 30 (+2) 30 (+2) 0
github.com/compute-blade-community/compute-blade-agent/pkg/hal/hal.go 0.00% (ø) 4 0 4
github.com/compute-blade-community/compute-blade-agent/pkg/hal/hal_bcm2711.go 0.00% (ø) 192 (+4) 0 192 (+4)
github.com/compute-blade-community/compute-blade-agent/pkg/hal/hal_bcm2711_simulated.go 0.00% (ø) 0 0 0
github.com/compute-blade-community/compute-blade-agent/pkg/hal/hal_bcm2711_standardfanunit.go 0.00% (ø) 31 0 31
github.com/compute-blade-community/compute-blade-agent/pkg/hal/hal_mock.go 0.00% (ø) 20 (+2) 0 20 (+2)
github.com/compute-blade-community/compute-blade-agent/pkg/ledengine/ledengine.go 76.67% (+4.25%) 30 (+1) 23 (+2) 7 (-1) 👍
github.com/compute-blade-community/compute-blade-agent/pkg/ledengine/options.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/compute-blade-community/compute-blade-agent/pkg/fancontroller/fancontroller_test.go
  • github.com/compute-blade-community/compute-blade-agent/pkg/ledengine/ledengine_test.go
  • github.com/compute-blade-community/compute-blade-agent/pkg/util/clock_test.go
  • github.com/compute-blade-community/compute-blade-agent/pkg/util/file_exist_test.go
  • github.com/compute-blade-community/compute-blade-agent/pkg/util/host_ips_test.go

@cedi cedi merged commit a52c606 into main Jun 6, 2025
14 checks passed
@cedi cedi deleted the feature/add_mode_bladectl_cmds branch June 6, 2025 21:03
cedi added a commit that referenced this pull request Jun 6, 2025
This PR introduces a comprehensive set of new subcommands to bladectl, expanding its capabilities for querying and managing compute blade state. It also includes an internal refactor to simplify interface management across the gRPC API.

* `get`
	* `fan`: Returns current fan speed.
	* `identify`: Indicates whether the identify mode is active.
	* `stealth`: Shows if stealth mode is currently enabled.
	* `status`: Prints a full blade status report.
	* `temperature`: Retrieves current SoC temperature.
	* `critical`: Shows whether critical mode is active.
	* `power`: Reports the current power source (e.g., PoE+ or USB).
* `set`
	* `stealth`: Enables stealth mode.
* `remove`
	* `stealth`: Disables stealth mode.
* `describe`
	* `fan`: Outputs the current fan curve configuration.
* `monitor`: plot some charts about the state of the compute-blade-agent

* **gRPC API refactor**: The gRPC service definitions previously located in `internal/api` have been folded into `internal/agent`. This eliminates redundant interface declarations and ensures that all ComputeBladeAgent implementations are directly compatible with the gRPC API.
This reduces duplication and improves long-term maintainability and clarity of the interface contract.

```bash
bladectl set fan --percent 90 --blade 1 --blade 2
bladectl unset identify --blade 1 --blade 2 --blade 3 --blade 4
bladectl set stealth --blade 1 --blade 2 --blade 3 --blade 4
bladectl get status --blade 1 --blade 2 --blade 3 --blade 4
┌───────┬─────────────┬────────────────────┬───────────────┬──────────────┬──────────┬───────────────┬──────────────┐
│ BLADE │ TEMPERATURE │ FAN SPEED OVERRIDE │ FAN SPEED     │ STEALTH MODE │ IDENTIFY │ CRITICAL MODE │ POWER STATUS │
├───────┼─────────────┼────────────────────┼───────────────┼──────────────┼──────────┼───────────────┼──────────────┤
│ 1     │ 50°C        │ 90%                │ 5825 RPM(90%) │ Active       │ Off      │ Off           │ poe+         │
│ 2     │ 48°C        │ 90%                │ 5825 RPM(90%) │ Active       │ Off      │ Off           │ poe+         │
│ 3     │ 49°C        │ Not set            │ 4643 RPM(56%) │ Active       │ Off      │ Off           │ poe+         │
│ 4     │ 49°C        │ Not set            │ 4774 RPM(58%) │ Active       │ Off      │ Off           │ poe+         │
└───────┴─────────────┴────────────────────┴───────────────┴──────────────┴──────────┴───────────────┴──────────────┘
bladectl rm stealth --blade 1 --blade 2 --blade 3 --blade 4
bladectl rm fan --blade 1 --blade 2 --blade 3 --blade 4
bladectl get status --blade 1 --blade 2 --blade 3 --blade 4
┌───────┬─────────────┬────────────────────┬───────────────┬──────────────┬──────────┬───────────────┬──────────────┐
│ BLADE │ TEMPERATURE │ FAN SPEED OVERRIDE │ FAN SPEED     │ STEALTH MODE │ IDENTIFY │ CRITICAL MODE │ POWER STATUS │
├───────┼─────────────┼────────────────────┼───────────────┼──────────────┼──────────┼───────────────┼──────────────┤
│ 1     │ 51°C        │ Not set            │ 5177 RPM(66%) │ Off          │ Off      │ Off           │ poe+         │
│ 2     │ 49°C        │ Not set            │ 5177 RPM(58%) │ Off          │ Off      │ Off           │ poe+         │
│ 3     │ 50°C        │ Not set            │ 4659 RPM(60%) │ Off          │ Off      │ Off           │ poe+         │
│ 4     │ 48°C        │ Not set            │ 4659 RPM(54%) │ Off          │ Off      │ Off           │ poe+         │
└───────┴─────────────┴────────────────────┴───────────────┴──────────────┴──────────┴───────────────┴──────────────┘
```

when having multiple compute-blades in your bladeconfig:

```yaml
blades:
    - name: 1
      blade:
        server: blade-pi1:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 2
      blade:
        server: blade-pi2:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 3
      blade:
        server: blade-pi3:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 4
      blade:
        server: blade-pi4:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
    - name: 4
      blade:
        server: blade-pi4:8081
        cert:
            certificate-authority-data: <redacted>
            client-certificate-data: <redacted>
            client-key-data: <redacted>
current-blade: 1
```

Fixes #4, #9 (partially), should help with #5

* test: improve unit-testing

* fix: pin github.com/warthog618/gpiod

---------

Co-authored-by: Cedric Kienzler <cedric@specht-labs.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent agent related changes api API related changes cli CLI related changes enhancement New feature or request hardware changes related to hardware interactions util changes related to utilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bcm2711] Temperature reporting & events [bladectl] status command
1 participant