Skip to content

[Featured][systemd] Generated service should not be enabled in featured#383

Open
mlok-nokia wants to merge 1 commit into
sonic-net:masterfrom
mlok-nokia:skip_enable_generated_service
Open

[Featured][systemd] Generated service should not be enabled in featured#383
mlok-nokia wants to merge 1 commit into
sonic-net:masterfrom
mlok-nokia:skip_enable_generated_service

Conversation

@mlok-nokia

@mlok-nokia mlok-nokia commented May 11, 2026

Copy link
Copy Markdown
Contributor

Why I did it

On multiasic platform, with Trixie, there will be services that will be defined in /run/systemd/generator as "generatad" UnitFileState. Such as PMON, SNMP, radv and other are generated service. Enabling such services fails because it's assumed to be always enabled. This PR modifies the featured to skip enabling the generated services. Fix issue sonic-net/sonic-buildimage#25414

Work item tracking
  • Microsoft ADO (number only):

How I did it

Featured always enabled the service files based on the configuration of the feature table. This PR add code to check is UnitFileState is generated, skip and not append the "systemctl enable " command to the cmds list.

How to verify it

bootup the new image in the multiasic platform, the following log should not be seen in the syslog:

2026 Feb  4 05:37:49.443422  sonic ERR featured: ['sudo', 'systemctl', 'enable', 'eventd.service'] - failed: return code - 1, output:              
2026 Feb  4 05:37:55.587767 sonic ERR featured: ['sudo', 'systemctl', 'enable', 'pmon.service'] - failed: return code - 1, output:             
2026 Feb  4 05:37:58.027168 soinc ERR featured: ['sudo', 'systemctl', 'enable', 'radv.service'] - failed: return code - 1, output:
2026 Feb  4 05:40:41.483658 sonic ERR featured: ['sudo', 'systemctl', 'enable', 'gnmi.service'] - failed: return code - 1, output:              
2026 Feb  4 05:40:49.039632 sonic ERR featured: ['sudo', 'systemctl', 'enable', 'mgmt-framework.service'] - failed: return code - 1, output:              
2026 Feb  4 05:40:51.358646 sonic ERR featured: ['sudo', 'systemctl', 'enable', 'snmp.service'] - failed: return code - 1, output:

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

@mssonicbld

Copy link
Copy Markdown

This PR has backport request for branch(es): 202511.
Added label(s) for branch(es) 202511.

---Powered by SONiC BuildBot

@yijingyan2

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rlhui
rlhui requested a review from abdosi June 24, 2026 17:46
@abdosi

abdosi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@anamehra : please sign-off if this looks good.

@anamehra

Copy link
Copy Markdown
Contributor

@anamehra : please sign-off if this looks good.

I will take a look. Thanks

@anamehra
anamehra self-requested a review July 15, 2026 18:03

@anamehra anamehra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, need test coverage.

Comment thread scripts/featured
# otherwise, start/enable corresponding systemd .service unit

cmds.append(["sudo", "systemctl", "enable", "{}.{}".format(feature_name, feature_suffixes[-1])])
if unit_file_state != "generated":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This behavior looks fine functionally: generated units should not be enabled, and this still keeps the start path intact. Could you add one targeted unit test in tests/featured/featured_test.py for enable_feature() with get_systemd_unit_state() returning generated, asserting unmask and start are called but no systemctl enable command is issued?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants