agama/rust/agama-lib/share
Knut Alejandro Anderssen González 76007c61ef
fix(rust) Do not return Err when a connection activation fails during writing but log the error (#2629)
## Problem

Currently the add_or_update_connection client method not only
add_or_update a connection in NetworkManager but it also tries to
activate or deactivate it based on the status property. The problem is
that the activation could fail in some situations like:

  - The interface bind to the connection is not present.
- The interface bind to the connection is already applying other
connection.
  - In case of Wireless, wireless could be disabled by hardware.
  
.... and other cases.

When this happen it returns with an error and the write operation does a
rollback to the checkpoint created before starting with the write.

-
https://trello.com/c/c7HAWvBz/5020-1245548-modifying-a-network-connection-binding-settings-does-not-apply-the-changes-to-the-active-connection

## Solution

- When the activation or deactivation of a connection return an error it
will be just logged in order to finish with the write of the
connections.
- Before activating a connection, if it is bind to an specific interface
which is applying a different connection then the device will be
disconnected in order to be able to activate the latest one. Example,
the default connection created by dracut which could be applied to
multiple-connections.

## Testing

- Tested manually
```bash
suse@vikingo:~$ cat test.json 
{
  "network": {
    "connections": [
      {
        "id": "br0",
        "interface": "br0",
        "status": "up",
        "persistent": true,
        "bridge": {
          "ports": ["eth0"],
          "stp": false
        }
      }
    ]
  }
}

suse@vikingo:~$ agama config load < test.json 
✓ The profile is valid.

# Logs from agama-web-server
2025-07-30T13:04:07.370000Z  INFO agama_network::nm::adapter: agama-network/src/nm/adapter.rs:152: No change detected for connection Sarambeque (cb47c266-d391-409d-97a2-12cbb311aca6)                             
2025-07-30T13:04:07.370012Z  INFO agama_network::nm::adapter: agama-network/src/nm/adapter.rs:152: No change detected for connection default (bd03462f-6398-4b8b-83b7-3d9196e85030)                                
2025-07-30T13:04:07.370020Z  INFO agama_network::nm::adapter: agama-network/src/nm/adapter.rs:172: Updating connection br0 (9464a892-baf8-4446-b4a5-12bd476a132e)                                                  
2025-07-30T13:04:07.391704Z  INFO agama_network::nm::client: agama-network/src/nm/client.rs:354: Activating connection br0                                                                                         
2025-07-30T13:04:07.398749Z  INFO agama_network::nm::adapter: agama-network/src/nm/adapter.rs:172: Updating connection eth0 (13d5f018-6304-472c-9c55-3a56597ce693)                                                 
2025-07-30T13:04:07.429485Z  INFO agama_network::nm::client: agama-network/src/nm/client.rs:339: Disconnecting default because the connection is eth0                                                              
2025-07-30T13:04:07.458868Z  INFO agama_network::nm::client: agama-network/src/nm/client.rs:354: Activating connection eth0    
```
2025-08-04 12:22:34 +01:00
..
examples Merge remote-tracking branch 'origin/master' into only_required 2025-06-24 13:45:23 +02:00
.gitignore Fix the JSON schema and validate it in CI (#2635) 2025-08-04 12:35:34 +02:00
examples space test fixtures: do not make an infinite directory loop with symlinks 2025-04-02 10:49:38 +02:00
examples%20percent test fixtures: do not make an infinite directory loop with symlinks 2025-04-02 10:49:38 +02:00
iscsi.schema.json Fix the JSON schema and validate it in CI (#2635) 2025-08-04 12:35:34 +02:00
package-lock.json Fix the JSON schema and validate it in CI (#2635) 2025-08-04 12:35:34 +02:00
package.json Fix the JSON schema and validate it in CI (#2635) 2025-08-04 12:35:34 +02:00
profile.schema.json fix(rust) Do not return Err when a connection activation fails during writing but log the error (#2629) 2025-08-04 12:22:34 +01:00
README-weird-filenames.md agama profile validate: integration tests 2025-03-21 14:12:44 +01:00
README.md Fix the JSON schema and validate it in CI (#2635) 2025-08-04 12:35:34 +02:00
storage.model.schema.json schema: use separate definition for mdRaid 2025-05-16 12:57:42 +01:00
storage.schema.json Fix the JSON schema and validate it in CI (#2635) 2025-08-04 12:35:34 +02:00

JSON schema definition

See the JSON schema documentation for more details. The Agama schemas uses the Draft 2019-09 version.

Autoinstallation profile

The Agama autoinstallation profile JSON schema is defined in these files:

Agama REST API

The storage.model.schema.json file describes the structure of the storage data passed via the internal REST API. This is important only for Agama developers, it is not intended to be used by end users.

Validation

To verify that the definitions are correct run these commands:

# install needed NPM packages
npm ci

# verify the schema
npm run validate

These commands are run in the CI automatically whenever a schema file is modified.