Problem with config creation of special agent in 2.3 with the migrate_to_password function

Hi all,

i´m trying to use the migrate_to_password function in the (form) valuespec definition to migrate already existing pre 2.3 special agent configs with a password to work with the new 2.3 Password Formspec.

When i enable the ruleset, i get the following error message:

WARNING: Config creation for special agent netappeseries failed on simulator_explicitpassword: Got invalid argument list from SSC plugin: (‘password’, ‘Passwort’) at index 3 in [‘-u’, ‘monitor’, ‘–password-id’, (‘password’, ‘Passwort’), ‘127.0.0.1’]. Expected either str or Secret.

The old ruleset coming from 2.2 :

special_agents['netappeseries'] = [
{'id': 'ae7891fc-cf93-4f32-b2db-feb8aaa77b63', 'value': {'user': 'monitor', 'password': ('password', 'Passwort')}, 'condition': {'host_name': ['simulator_explicitpassword']}, 'options': {'disabled': False}},
] + special_agents['netappeseries']

This is the valuespec:

            "password": DictElement(
                parameter_form=Password(
                    title=Title("Password"),
                    custom_validate=(LengthInRange(min_value=1),),
                    migrate=migrate_to_password,
                ),
                required=True

I tried it like this in the server side call, but i´m getting an assertion error:


  assert isinstance(secret := params["password"], Secret)

    args: list[str | Secret] = [
        "-u", params["user"],
        "--password-id", secret,
    ]

Any idea, what i´m doing wrong ?
Thank you :slight_smile:

@moritz

This is what I was talking about yesterday, would be awesome if you could take a look :slight_smile:

1 Like

I don’t see anything wrong with your code. The error message suggests that your value has not been migrated. Did you run cmk-update-config after changing the ruleset?

Thank you Moritz,

do i have to care about the migration of the rule myself or are alle rules with a password migrated automatically during the checkmk update ?

The migration function (if provided) will be called whenever the stored value is “loaded into the ruleset mask”, that is: When a user opens the rule for editing, or when it is rendered.
In addition we deliberately trigger this during cmk-update-config, by loading all rules and writing them back on disk.
So if you have a rules.mk file with the old value, you should see the new value in it after you ran cmk-update-config.

I updated a prod system of one of my customers today and i saw that the ruleset was not migrated during the update and a successfull run of cmk-update-config.


            "password": DictElement(
                parameter_form=Password(
                    title=Title("Password"),
                    custom_validate=(LengthInRange(min_value=1),),
                    migrate=migrate_to_password,
                ),
                required=True,

checkmk complained with the same error message as in my first post above, I had to open and save the ruleset to make it work again.
Is there something I can test to see why the rule is not updated during the update ?

As a site node : My old mkp package was disabled during the update and I installed the new one after 2.3 was running…

That might be the issue. Just to clarify: In the exact moment when cmk-update-config was run, was your MKP enabled and active?

I think from looking into the log file - first the version incompatible MKPs are disabled and then 02_cmk-update-config is running.
I reran cmk-update-config afterwards again, because of an other error I had, but i have not done that after the installation of the 2.3 MKP.
I will have to test that in my dev environment.