Skip to content

[hostcfgd] wrong behavior for disable_feature #15

@wenyiz2021

Description

@wenyiz2021

In enable_feature:

        for suffix in feature_suffixes:
            cmds.append("sudo systemctl unmask {}.{}".format(feature_name, suffix))
        cmds.append("sudo systemctl enable {}.{}".format(feature_name, feature_suffixes[-1]))
        cmds.append("sudo systemctl start {}.{}".format(feature_name, feature_suffixes[-1]))

While in disable_feature, this iteration looks wrong:

        for suffix in reversed(feature_suffixes):
            cmds.append("sudo systemctl stop {}.{}".format(feature_name, suffix))
            cmds.append("sudo systemctl disable {}.{}".format(feature_name, feature_suffixes[-1]))
            cmds.append("sudo systemctl mask {}.{}".format(feature_name, feature_suffixes[-1]))

My idea is to change to:

        for suffix in reversed(feature_suffixes):
            cmds.append("sudo systemctl stop {}.{}".format(feature_name, suffix))
            cmds.append("sudo systemctl disable {}.{}".format(feature_name, suffix))
            cmds.append("sudo systemctl mask {}.{}".format(feature_name, suffix))

Let's say,
telemetry has feature_suffixes = ['service', 'timer']

enable_feature:

sudo systemctl unmask t.service
sudo systemctl unmask t.timer

sudo systemctl enable t.timer   
sudo systemctl start t.timer

=> ok

disable_feature:

sudo systemctl stop t.timer
sudo systemctl disable t.timer
sudo systemctl mask t.timer

sudo systemctl stop t.service
sudo systemctl disable t.timer  ?? why do it again
sudo systemctl mask t.timer ??

With new change:
disable:

sudo systemctl stop t.timer
sudo systemctl disable t.timer
sudo systemctl mask t.timer

sudo systemctl stop t.service
sudo systemctl disable t.service
sudo systemctl mask t.service

dhcp has [service]

enable:

sudo systemctl unmask d.service	
sudo systemctl enable d.service
sudo systemctl start d.service

=>ok
disable:

sudo systemctl stop d.service
sudo systemctl disable d.service  
sudo systemctl mask d.service 

=>ok

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions