Skip to content
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

[hostcfgd] Fix Boolean String Evaluation #5248

Merged

Conversation

tahmed-dev
Copy link
Contributor

@tahmed-dev tahmed-dev commented Aug 25, 2020

New attribute 'has_timer' introduced to init_cfg.json does not evaluate
as Bool, rather it evaluates as string. This PR fixes this issue. Also,
this PR fixes an issue when there is system config unit (snmp. telemetry)
has no installation config (WantedBy=, RequiredBy=, Also=, Alias=) settings
in the [Install] section. In the latter case, the .service should not be enabled.

signed-off-by: Tamer Ahmed [email protected]

The issue appears to be stemming from config_db as the new has_timer is stored as string in the config_db

    "FEATURE": {
        "bgp": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "database": {
            "auto_restart": "disabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "dhcp_relay": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "lldp": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "mgmt-framework": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "nat": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "disabled"
        }, 
        "pmon": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "radv": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "sflow": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "disabled"
        }, 
        "snmp": {
            "auto_restart": "enabled", 
            "has_timer": "True", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "swss": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "syncd": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "teamd": {
            "auto_restart": "enabled", 
            "has_timer": "False", 
            "high_mem_alert": "disabled", 
            "state": "enabled"
        }, 
        "telemetry": {
            "auto_restart": "enabled", 
            "has_timer": "True", 
            "high_mem_alert": "disabled", 
            "state": "enabled", 
            "status": "enabled"
        }
    }, 

- Why I did it
To fix service start noticed during test.

- How I did it
Add code to properly evaluate newly added field

- How to verify it
config load_minigraph does not shoe lldp.timer as started.

- Which release branch to backport (provide reason below if selected)
N/A

  • 201811
  • 201911
  • 202006

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

New attribute 'has_timer' introduced to init_cfg.json does not evaluate
as Bool, rather it evaluates as string. This PR fixes this issue

signed-off-by: Tamer Ahmed <[email protected]>
jleveque
jleveque previously approved these changes Aug 25, 2020
tahmed-dev referenced this pull request Aug 25, 2020
Commit e484ae9 introduced systemd .timer unit to hostcfgd.
However, when stopping service that has timer, there is possibility that
timer is not running and the service would not be stopped. This PR
address this situation by handling both .timer and .service units.

signed-off-by: Tamer Ahmed <[email protected]>
if has no installation config (WantedBy=, RequiredBy=, Also=, Alias=
settings in the [Install] section
@abdosi
Copy link
Contributor

abdosi commented Aug 26, 2020

@tahmed-dev not able to completely follow PR description .
Eg: snmp.timer has Install section but still we do do not want to enable snmp.service ?
[Install]
WantedBy=timers.target

@tahmed-dev
Copy link
Contributor Author

tahmed-dev commented Aug 26, 2020

@tahmed-dev not able to completely follow PR description .
Eg: snmp.timer has Install section but still we do do not want to enable snmp.service ?
[Install]
WantedBy=timers.target

@abdosi, This is correct, we do not want to enable snmp/telemetry .service. The issue was reported by systemd as follows:

Aug 25 18:47:59.248264 str-s6000-acs-14 INFO hostcfgd[22667]: The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Aug 25 18:47:59.250047 str-s6000-acs-14 INFO hostcfgd[22667]: Alias= settings in the [Install] section, and DefaultInstance= for template
Aug 25 18:47:59.251773 str-s6000-acs-14 INFO hostcfgd[22667]: units). This means they are not meant to be enabled using systemctl.
Aug 25 18:47:59.254822 str-s6000-acs-14 INFO hostcfgd[22667]:  
Aug 25 18:47:59.256584 str-s6000-acs-14 INFO hostcfgd[22667]: Possible reasons for having this kind of units are:
Aug 25 18:47:59.262071 str-s6000-acs-14 INFO hostcfgd[22667]: • A unit may be statically enabled by being symlinked from another unit's
Aug 25 18:47:59.263599 str-s6000-acs-14 INFO hostcfgd[22667]:   .wants/ or .requires/ directory.
Aug 25 18:47:59.265389 str-s6000-acs-14 INFO hostcfgd[22667]: • A unit's purpose may be to act as a helper for some other unit which has
Aug 25 18:47:59.268989 str-s6000-acs-14 INFO hostcfgd[22667]:   a requirement dependency on it.
Aug 25 18:47:59.270647 str-s6000-acs-14 INFO hostcfgd[22667]: • A unit may be started when needed via activation (socket, path, timer,
Aug 25 18:47:59.272414 str-s6000-acs-14 INFO hostcfgd[22667]:   D-Bus, udev, scripted systemctl call, ...).
Aug 25 18:47:59.274089 str-s6000-acs-14 INFO hostcfgd[22667]: • In case of template units, the unit is meant to be enabled with some
Aug 25 18:47:59.275855 str-s6000-acs-14 INFO hostcfgd[22667]:   instance name specified.
Aug 25 18:47:59.279172 str-s6000-acs-14 INFO hostcfgd: Running cmd: 'sudo systemctl start snmp.service'

@jleveque
Copy link
Contributor

Retest vsimage please

@tahmed-dev tahmed-dev merged commit 7d3ec60 into sonic-net:master Aug 27, 2020
abdosi pushed a commit that referenced this pull request Aug 27, 2020
New attribute 'has_timer' introduced to init_cfg.json does not evaluate
as Bool, rather it evaluates as string. This PR fixes this issue. Also,
this PR fixes an issue when there is system config unit (snmp, telemetry) that
has no installation config (WantedBy=, RequiredBy=, Also=, Alias=) settings
in the [Install] section. In the latter case, the .service should not be enabled.

signed-off-by: Tamer Ahmed <[email protected]>
santhosh-kt pushed a commit to santhosh-kt/sonic-buildimage that referenced this pull request Feb 25, 2021
New attribute 'has_timer' introduced to init_cfg.json does not evaluate
as Bool, rather it evaluates as string. This PR fixes this issue. Also,
this PR fixes an issue when there is system config unit (snmp, telemetry) that
has no installation config (WantedBy=, RequiredBy=, Also=, Alias=) settings
in the [Install] section. In the latter case, the .service should not be enabled.

signed-off-by: Tamer Ahmed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants