Skip to content

Commit

Permalink
add admin workload docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Jan 5, 2025
1 parent f1c0924 commit 4d9bf34
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (n *NodeClient) AdminRestartAll(ctx context.Context) error {
return n.bus.Call(ctx, n.nodeTwin, cmd, nil, nil)
}

// AdminShowLogs returns a l lines of zinit logs
// AdminShowLogs returns l lines of zinit logs
func (n *NodeClient) AdminShowLogs(ctx context.Context, l int) (logs []byte, err error) {
const cmd = "zos.admin.show_logs"

Expand Down
82 changes: 74 additions & 8 deletions docs/manual/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ so `used = user_used + system`, while `system` is only the amount of resourced r
| `zos.storage.pools` | - |`[]Pool`|

List all node pools with their types, size and used space
where

Where

```json
Pool {
Expand Down Expand Up @@ -151,29 +152,95 @@ it means it can act like an access node to user private networks

## Admin

The next set of commands are ONLY possible to be called by the `farmer` only.
The next set of commands are ONLY possible to be called by the `farmer` owning the node.

### Reboot Node

| command |body| return|
|---|---|---|
| `zos.admin.reboot` | - | - |

Stops all services then reboot the node
Stops all services then reboots the node

### Restart Service

| command |body| return|
|---|---|---|
| `zos.admin.reboot` | string | - |
| `zos.admin.restart` | string | - |

Restarts a service running on the node

### Restart All Services

| command |body| return|
|---|---|---|
| `zos.admin.restart_all` | - | - |

Restarts all zinit services running on the node

### Show Logs

| command |body| return|
|---|---|---|
| `zos.admin.show_logs` | int | []byte |

Shows a number of lines of zinit logs

### Show Resolve

| command |body| return|
|---|---|---|
| `zos.admin.show_resolve` | - | []byte |

Shows the content of /etc/resolv.conf

### Show Open Connections

| command |body| return|
|---|---|---|
| `zos.admin.show_open_connections` | - | []byte |

Shows information about all open connections in the node

### Stop Workload

| command |body| return|
|---|---|---|
| `zos.admin.Stop` | `Args` | - |

Where

```json
Args {
"twin_id": "uint32",
"workload_id": "uint64",
}
```

Stops a workload

### Resume Workload

| command |body| return|
|---|---|---|
| `zos.admin.resume` | `Args` | - |

Where

```json
Args {
"twin_id": "uint32",
"workload_id": "uint64",
}
```

Resumes a stopped workload

### List Physical Interfaces

| command |body| return|
|---|---|---|
| `zos.network.admin.interfaces` | - |`map[string]Interface` |
| `zos.admin.interfaces` | - |`map[string]Interface` |

Where

Expand All @@ -191,7 +258,7 @@ Those interfaces then can be used as an input to `set_public_nic`

| command |body| return|
|---|---|---|
| `zos.network.admin.get_public_nic` | - |`ExitDevice` |
| `zos.admin.get_public_nic` | - |`ExitDevice` |

Where

Expand All @@ -209,7 +276,7 @@ returns the interface used by public traffic (for user workloads)

| command |body| return|
|---|---|---|
| `zos.network.admin.set_public_nic` | `name` |- |
| `zos.admin.set_public_nic` | `name` |- |

name must be one of (free) names returned by `zos.network.admin.interfaces`

Expand Down Expand Up @@ -239,7 +306,6 @@ name must be one of (free) names returned by `zos.network.admin.interfaces`
|---|---|---|
| `zos.system.node_features_get` | - |`[]NodeFeature` |


Where

```json
Expand Down
4 changes: 1 addition & 3 deletions pkg/primitives/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ func (s *statsStream) Total() gridtypes.Capacity {
}

func (s *statsStream) OpenConnections() ([]byte, error) {
args := []string{"-ptn", "state", "established"}
cmd := exec.Command("ss", args...)
return cmd.Output()
return exec.Command("ss", "-ptn", "state", "established").Output()
}

func (s *statsStream) openConnectionsCount() (int, error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type Statistics interface {
GetCounters() (Counters, error)
ListGPUs() ([]GPUInfo, error)
OpenConnections() ([]byte, error)
// Pause(id gridtypes.WorkloadID) error
}

type Counters struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/zinit/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (c *Client) List() (out map[string]ServiceState, err error) {
}

// List returns all the service monitored and their status
func (c *Client) Log(n int) (out string, err error) {
func (c *Client) Log(n int) (out []byte, err error) {
cmd1 := exec.Command("zinit", "log", "-s")
cmd2 := exec.Command("tail", "-n", fmt.Sprint(n))

Expand All @@ -231,7 +231,7 @@ func (c *Client) Log(n int) (out string, err error) {
return
}

return string(output), err
return output, err
}

// Status returns the status of a service
Expand Down

0 comments on commit 4d9bf34

Please sign in to comment.