Skip to content

Adapt agama config to return error code when no validates#3304

Merged
teclator merged 4 commits intomasterfrom
agama_config_return_codes
Mar 20, 2026
Merged

Adapt agama config to return error code when no validates#3304
teclator merged 4 commits intomasterfrom
agama_config_return_codes

Conversation

@teclator
Copy link
Copy Markdown
Contributor

@teclator teclator commented Mar 19, 2026

Problem

When running agama config load, agama config generate or agama config validate it always returns 0 even when the profile is invalid.

Solution

Return Err (return code 1) in case of invalid profile.

Testing

  • Tested manually

agama config generate

suse@vikingo-laptop:~$ ~/agama_not_fix/agama config generate profile.jsonnet || echo $?
{
   "hostname": {
      "static": "Agama"
   },
   "product": {
      "ID": "Tumbleweed"
   },
   "scripts": {
      "post": [
         {
            "chroot": true,
            "content": "#!/usr/bin/env bash\necho 'PermitRootLogin yes' > /etc/ssh/sshd_config.d/root.conf\nsystemctl enable sshd\n",
            "name": "enable root login"
         }
      ]
   }
}
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

suse@vikingo-laptop:~$ ~/agama_fix/agama config generate profile.jsonnet || echo $?
{
   "hostname": {
      "static": "Agama"
   },
   "product": {
      "ID": "Tumbleweed"
   },
   "scripts": {
      "post": [
         {
            "chroot": true,
            "content": "#!/usr/bin/env bash\necho 'PermitRootLogin yes' > /etc/ssh/sshd_config.d/root.conf\nsystemctl enable sshd\n",
            "name": "enable root login"
         }
      ]
   }
}
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

The profile is not valid
1

agama config load

suse@vikingo-laptop:~$ ~/agama_not_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

suse@vikingo-laptop:~$ ~/agama_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

The profile is not valid
1

agama config validate

suse@vikingo-laptop:~$ ~/agama_not_fix/agama config validate profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

suse@vikingo-laptop:~$ ~/agama_fix/agama config validate profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

The profile is not valid
1

@teclator teclator changed the title Adapt agama config to return proper return codes Adapt agama config to return error code when no validates Mar 19, 2026
@teclator teclator marked this pull request as ready for review March 19, 2026 17:56
Copy link
Copy Markdown
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it looks good. Please, remove the reference to InstallSettings.

@teclator teclator merged commit 3f9da8e into master Mar 20, 2026
26 checks passed
@teclator teclator deleted the agama_config_return_codes branch March 20, 2026 09:20
teclator added a commit that referenced this pull request Mar 23, 2026
…3310)

Same than #3304 but for SLE-16

In contrary to SLE-16.1, in SLE-16 the `agama config load` returns 1 in
both cases when there is no product but continues otherwise.

## Tests

- *Tested manually*

### agama config validate

```bash
agama:~ # agama_not_fix/agama config validate profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

agama:~ # agama_fix/agama config validate profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

The profile is not valid
1
```

### agama config load

```bash
agama:~ # agama_not_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

Cannot proceed with profile without specified product
1
agama:~ # agama_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

The profile is not valid
1
agama:~ # agama_not_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('test' was unexpected). 

[1/2] Analyze disks
[2/2] Configure software

agama:~ # nmcli c
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  91b9fecf-4020-35ec-97f8-d8e2cdcff413  ethernet  enp1s0 
Wired connection 2  12b49824-ddaa-3f0f-a73f-ec0f1ccd12ae  ethernet  enp2s0 
Wired connection 3  b33b1b08-3513-3155-b8b4-16ceba7ee8bd  ethernet  enp3s0 
lo                  567dce11-cedd-4227-b2a5-d249da7d82d1  loopback  lo 

agama:~ # cat profile.json | jq ".network .connections"
[
  {
    "id": "Wired connection 3",
    "status": "removed"
  }
]
agama:~ # agama_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('test' was unexpected). 

The profile is not valid
1
agama:~ # agama_not_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('test' was unexpected). 

agama:~ # nmcli c
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  91b9fecf-4020-35ec-97f8-d8e2cdcff413  ethernet  enp1s0 
Wired connection 2  12b49824-ddaa-3f0f-a73f-ec0f1ccd12ae  ethernet  enp2s0 
lo                  567dce11-cedd-4227-b2a5-d249da7d82d1  loopback  lo     
º
```

### agama config generate

```bash
agama:~ # agama_not_fix/agama config generate profile.jsonnet || echo $?
{
   "hostname": {
      "static": "Agama"
   },
   "product": {
      "ID": "Tumbleweed"
   },
   "scripts": {
      "post": [
         {
            "chroot": true,
            "content": "#!/usr/bin/env bash\necho 'PermitRootLogin yes' > /etc/ssh/sshd_config.d/root.conf\nsystemctl enable sshd\n",
            "name": "enable root login"
         }
      ]
   }
}
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

agama:~ # agama_fix/agama config generate profile.jsonnet || echo $?
{
   "hostname": {
      "static": "Agama"
   },
   "product": {
      "ID": "Tumbleweed"
   },
   "scripts": {
      "post": [
         {
            "chroot": true,
            "content": "#!/usr/bin/env bash\necho 'PermitRootLogin yes' > /etc/ssh/sshd_config.d/root.conf\nsystemctl enable sshd\n",
            "name": "enable root login"
         }
      ]
   }
}
✗ The profile is not valid. Please, check the following errors:

        * Additional properties are not allowed ('ID' was unexpected). /product
        * "id" is a required property. /product

The profile is not valid
1
```

Also tested with edit

```bash
agama:~/agama_fix # agama config edit 
✗ The profile is not valid. Please, check the following errors:

	* Additional properties are not allowed ('test' was unexpected). 

agama:~/agama_fix # echo $?
0
agama:~/agama_fix # ./agama config edit 
✗ The profile is not valid. Please, check the following errors:

	* Additional properties are not allowed ('test' was unexpected). 

The profile is not valid
agama:~/agama_fix # echo $?
1
```
mvidner added a commit that referenced this pull request Mar 27, 2026
invalid profile now returns an error exit code, as fixed in #3304
mvidner added a commit that referenced this pull request Mar 27, 2026
## Problem

- invalid profile now returns an error exit code, as fixed in #3304

## Solution

- tell Cheetah to allow that exit code

## Testing

- this **is** a test, run daily on schedule

## Screenshots

No

## Documentation

No
@imobachgs imobachgs mentioned this pull request Apr 14, 2026
imobachgs added a commit that referenced this pull request Apr 14, 2026
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.

2 participants