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

Fix RPM Systemd Artifact Support #310

Merged
merged 7 commits into from
Jul 8, 2024

Conversation

adamperlin
Copy link
Contributor

@adamperlin adamperlin commented Jul 3, 2024

What this PR does / why we need it:
Fixes #301. It is not good practice to include .preset files in an RPM package so this PR changes the %post section of dalec-generated RPM Specs to enable/disable systemd units manually.

Additionally, I discovered in the course of changing this behavior that systemd was not actually marked as a post, preun and postun dependency, meaning that prost, preun, and postun scripts using the systemd_* macros were actually broken to begin with. This PR fixes that issue as well.

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #

Special notes for your reviewer:

@adamperlin adamperlin requested a review from a team as a code owner July 3, 2024 20:04
@@ -317,6 +325,22 @@ func (w *specWrapper) PreUn() fmt.Stringer {
return b
}

func systemdPostScript(unitName string, cfg dalec.SystemdUnitConfig) string {
verb := "disable"
Copy link
Member

Choose a reason for hiding this comment

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

This should take into account the default value and do nothing.

Copy link
Member

Choose a reason for hiding this comment

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

Actually thinking about it we should probably only ever enable and do nothing when false.
I wrote up that other PR to make it a *bool with the idea that we have these preset files but I'm thinking maybe we don't need that?

basically

if !cfg.Enable {
  return ""
}

// systemctl enable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that seems reasonable. Because I believe systemctl disable is essentially a no-op unless the service is already enabled, right?

Copy link
Member

Choose a reason for hiding this comment

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

And also potentially something we don't want to do willy-nilly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this should be fixed. It does actually complicate things a bit though, because if we aren't explicitly disabling units, then we don't necessarily need a %post section or %post systemd dependency if no enabled units have been specified in the spec. I've added some logic to account for this

@cpuguy83
Copy link
Member

cpuguy83 commented Jul 5, 2024

Can you add a revert of #307 since given this change I don't think we need it?

@adamperlin adamperlin force-pushed the adamperlin/fix-systemd-support branch from fd0e806 to 5f6f703 Compare July 8, 2024 20:13
@adamperlin
Copy link
Contributor Author

Can you add a revert of #307 since given this change I don't think we need it?

This is done!

@adamperlin adamperlin requested a review from cpuguy83 July 8, 2024 21:25
@cpuguy83 cpuguy83 merged commit 9099c58 into Azure:main Jul 8, 2024
9 checks passed
@adamperlin adamperlin deleted the adamperlin/fix-systemd-support branch August 12, 2024 17:57
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.

[BUG] DALEC should not be using systemd preset files
2 participants