Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Add ecs systemd unit for al2 #171

Merged
merged 10 commits into from
Jun 5, 2018
Merged

Add ecs systemd unit for al2 #171

merged 10 commits into from
Jun 5, 2018

Conversation

jahkeup
Copy link
Member

@jahkeup jahkeup commented May 31, 2018

Summary

This change wraps the existing ecs-init daemon (with minor semantic modifications) with a systemd unit to run under Amazon Linux 2.

Implementation details

Minor modifications have been made to the entrypoints in the ecs-init binary to include the stop verb to align with systemd semantics surrounding service lifecycle. Though there is no difference from post-stop from upstart land, this allows the two to coexist in code if a change in handling is required at a later time.

The updated RPM spec accommodates both Amazon Linux and Amazon Linux 2 (thanks @ilianaw!) and includes a unit file suitable for running ecs-init on Amazon Linux 2 (with systemctl start ecs).

Testing

The RPM was built both for Amazon Linux and Amazon Linux 2 and run in an ECS Cluster with some tasks to confirm no functional differences were present.

New tests cover the changes: no

Description for the changelog

Add Amazon Linux 2 systemd unit to RPM spec

Licensing

This contribution is under the terms of the Apache 2.0 License: yes

ExecStopPost=/usr/libexec/amazon-ecs-init post-stop

[Install]
WantedBy=multi-user.target
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a newline

fi

%post
# Symlink the bundled ECS Agent at loadable path.
ln -sf ecs-agent-v%{bundled_agent_version}.tar %{cache_dir}/ecs-agent.tar
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this got dropped in the amzn1 section...

License: Apache 2.0
Summary: Amazon Elastic Container Service initialization application
BuildArch: x86_64
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExclusiveArch: x86_64
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change from BuildArch to ExclusiveArch?

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -31,6 +31,7 @@ const (
PRESTART = "pre-start"
START = "start"
PRESTOP = "pre-stop"
STOP = "stop"
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't appear to have updated the manpage to reflect this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed! I'll update and clarify how these targets should be used in the context of upstart and systemd.

touch $RPM_BUILD_ROOT/%{conf_dir}/ecs.config
touch $RPM_BUILD_ROOT/%{conf_dir}/ecs.config.json
install -D amazon-ecs-init %{buildroot}%{_libexecdir}/amazon-ecs-init
install -D scripts/amazon-ecs-init.1 %{buildroot}%{_mandir}/man1/amazon-ecs-init.1
Copy link
Contributor

Choose a reason for hiding this comment

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

We were explicitly compressing this before, but aren't here. Why?

Copy link
Contributor

Choose a reason for hiding this comment

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

https://fedoraproject.org/wiki/Packaging:Guidelines#Manpages

When installing man pages, note that they should be installed uncompressed as the build system will compress them as needed.

Requires=docker.service
After=docker.service

[Service]
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't mind seeing Type=simple set explicitly here. Otherwise people will need to understand the rules around the different defaults in order to understand this unit's behavior.

Name: ecs-init
Version: 1.18.0
Release: 1%{?dist}
Group: System Environment/Base
Vendor: Amazon.com
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we no longer set Group or Vendor?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is that? Does that apply to all packages? It's not clear from that doc if there are fedora-specific reasons to avoid these tags or if they must not be present even in third-party packages.

Copy link
Contributor

Choose a reason for hiding this comment

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

AL2 inherits the packaging guidelines from Fedora / EPEL, except for the ones we are explicitly incompatible with (such as ones requiring changes in RPM 4.14) or otherwise simply don't like (none of these are documented yet).

The Group field, I believe, is not listed in yum repodata (deprecated in favor of yum's groups in comps.xml). The Vendor field gets overwritten by our build system anyway.

@@ -0,0 +1,13 @@
[Unit]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the license header to this file?

@jahkeup
Copy link
Member Author

jahkeup commented Jun 4, 2018

See rendered man page here. Please leave comments in the PR and file.

Copy link
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

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

LGTM

@jahkeup
Copy link
Member Author

jahkeup commented Jun 4, 2018

Trimmed down the commits. @samuelkarp PTAL at the man page updates specifically.

The process executed by the ecs.service is going to remain running to
supervise the ECS agent and handles lifecycle with the Exec*
directives and also internally where required (eg: for agent upgrade
functionality).
[Unit]
Description=ECS Agent
Requires=docker.service
After=docker.service
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably have this run after cloud-init.target so that you can configure the ECS agent using user-data.

jahkeup added a commit to jahkeup/amazon-ecs-init that referenced this pull request Jun 6, 2018
This was inadvertently merged directly into the master and
needs to be restaged.

This reverts commit 52d5792.
jahkeup added a commit that referenced this pull request Jun 11, 2018
This was inadvertently merged directly into the master and
needs to be restaged.

This reverts commit 52d5792.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants