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

deb and rpm packaging for all binaries #6456

Merged
merged 4 commits into from
Aug 1, 2022

Conversation

julienduchesne
Copy link
Member

@julienduchesne julienduchesne commented Jun 22, 2022

There is currently deb and rpm packages being published for logcli amd64 but they aren't signed

In this PR:

  • Add RPM and deb packages for logcli, loki-canary loki and promtail for arm, arm64 and amd64
  • Sign them with the Grafana GPG key (packages.grafana.com/gpg.key). This will be the same key for all Grafana products
  • Add CI steps to test the RPM and deb packages. This launches a docker image with systemd installed, then it installs both loki and promtail and does a logcli query on the Loki instance

@julienduchesne julienduchesne requested a review from a team as a code owner June 22, 2022 02:00
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0.1%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0.6%

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Thanks for this @julienduchesne! 🎉
@KMiller-Grafana could you please have a look at the verbiage in tools/package-nfpm.jsonnet to see if there's anything you'd like to change before I merge?

Copy link
Contributor

@chaudum chaudum left a comment

Choose a reason for hiding this comment

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

Thanks for your efforts to make OS packages happen also for Loki. However I have a big concern which I raised in a comment.

tools/package-nfpm.jsonnet Outdated Show resolved Hide resolved
Copy link
Contributor

@jeschkies jeschkies left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started 🙂

tools/package-nfpm.jsonnet Outdated Show resolved Hide resolved
@julienduchesne julienduchesne force-pushed the julienduchesne/packaging-deb-rpm-all-products branch from bdea709 to 9868c51 Compare June 27, 2022 16:57
@pull-request-size pull-request-size bot added size/L and removed size/M labels Jun 27, 2022
@julienduchesne julienduchesne force-pushed the julienduchesne/packaging-deb-rpm-all-products branch 3 times, most recently from 2f4fb48 to 505e063 Compare June 27, 2022 17:15
@julienduchesne julienduchesne marked this pull request as draft June 27, 2022 17:21
Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

File contents for tools/packaging/nfpm.jsonnet look good to me.

@julienduchesne julienduchesne force-pushed the julienduchesne/packaging-deb-rpm-all-products branch from 60d654a to 49b73e3 Compare June 28, 2022 02:32
@julienduchesne
Copy link
Member Author

@jeschkies @chaudum. Re-requesting a review. I added systemd configs for both deb and RPM. I also added a CI test to check that everything keeps working. The CI check uses CentOS and Debian. It installs loki and promtail and then queries with logcli to see that everything works well

@julienduchesne julienduchesne requested review from chaudum, jeschkies and a team June 28, 2022 02:39
@julienduchesne julienduchesne marked this pull request as ready for review June 28, 2022 02:39
@julienduchesne julienduchesne force-pushed the julienduchesne/packaging-deb-rpm-all-products branch from 49b73e3 to bfa9c6a Compare June 28, 2022 02:41
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0.1%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@jeschkies jeschkies mentioned this pull request Jun 28, 2022
Copy link
Contributor

@jeschkies jeschkies left a comment

Choose a reason for hiding this comment

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

This is really awesome! Just so I understand. The packages are not published yet, right?

}),
run('test packaging',
commands=[
'go install github.com/google/go-jsonnet/cmd/jsonnet@latest', // Test, install in build image instead
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand this step. Why do you install a Go dependency here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Installed in the build image here: #6526

{
name: 'test deb package',
image: 'docker',
commands: ['./tools/packaging/verify-deb-install.sh'],
Copy link
Contributor

Choose a reason for hiding this comment

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

This is awesome. I'd use some test library but am totally fine with a shell script for now.

for name in loki loki-canary logcli promtail; do
for arch in amd64 arm64 arm; do
config_path="dist/tmp/config-${name}-${arch}.json"
jsonnet -V "name=${name}" -V "arch=${arch}" "tools/packaging/nfpm.jsonnet" > "${config_path}"
Copy link
Contributor

Choose a reason for hiding this comment

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

...ah this is why you need to install Jsonnet 🙂


cat <<EOF | docker exec --interactive "${image}" sh
# Install loki and check it's running
dpkg -i ${dir}/dist/loki_0.0.0~rc0_amd64.deb
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the binary have a version?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh dang, that'll fail on actual releases. Will fix

Comment on lines +30 to +33
sleep 5
labels_found=\$(logcli labels)
echo "Found labels: \$labels_found"
[ "\$labels_found" != "" ] || (echo "no logs found with logcli" && exit 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use a loop but this is a great start. We can always iterate.

@julienduchesne
Copy link
Member Author

julienduchesne commented Jun 28, 2022

This is really awesome! Just so I understand. The packages are not published yet, right?

No, we're working on a global repository (apt.grafana.com and rpm.grafana.com) where we will publish all packages. It'll just be an additional Drone step. For now, the deb and rpm files will be in the releases. I'm hoping to have the repositories ready before end of July

julienduchesne added a commit that referenced this pull request Jun 28, 2022
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

-           ingester	-0.1%
-        distributor	-0.3%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@rightaway
Copy link

@julienduchesne The debian package will install directly on the system not through docker?

Where can I see what the .service files will look like on debian for loki and promtail packages?

dst: '/etc/systemd/system/loki.service',
},
{
src: './cmd/loki/loki-local-config.yaml',
Copy link
Contributor

Choose a reason for hiding this comment

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

This config file configures Loki to write to /tmp/loki. Not sure if this is the ideal default location, but I think it's good enough for a first iteration.

julienduchesne added a commit that referenced this pull request Jun 30, 2022
* Add jsonnet to build image
Needed for #6456

* Add pipeline step to build image
@julienduchesne julienduchesne force-pushed the julienduchesne/packaging-deb-rpm-all-products branch 2 times, most recently from 0b98a00 to faf6c92 Compare July 5, 2022 12:01
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0.3%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Type=simple
User=promtail
ExecStart=/usr/bin/promtail -config.file /etc/promtail/config.yml

Copy link

Choose a reason for hiding this comment

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

Wouldn't it be a neat idea if promtail would also be Restart = on-failure, just like in loki.service?

There is currently deb and rpm packages being published for logcli amd64 but they aren't signed

In this PR:
- Add RPM and deb packages for `logcli`, `loki-canary` `loki` and `promtail` for arm, arm64 and amd64
- Sign them with the Grafana GPG key (packages.grafana.com/gpg.key). This will be the same key for all Grafana products
- Add CI steps to test the RPM and deb packages. This launches a docker image with systemd installed, then it installs both loki and promtail and does a `logcli` query on the Loki instance
@julienduchesne julienduchesne force-pushed the julienduchesne/packaging-deb-rpm-all-products branch from faf6c92 to dcc0d74 Compare August 1, 2022 13:00
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@julienduchesne julienduchesne merged commit 7b70d3d into main Aug 1, 2022
@julienduchesne julienduchesne deleted the julienduchesne/packaging-deb-rpm-all-products branch August 1, 2022 13:22
lxwzy pushed a commit to lxwzy/loki that referenced this pull request Nov 7, 2022
* deb and rpm packaging for all binaries
There is currently deb and rpm packages being published for logcli amd64 but they aren't signed

In this PR:
- Add RPM and deb packages for `logcli`, `loki-canary` `loki` and `promtail` for arm, arm64 and amd64
- Sign them with the Grafana GPG key (packages.grafana.com/gpg.key). This will be the same key for all Grafana products
- Add CI steps to test the RPM and deb packages. This launches a docker image with systemd installed, then it installs both loki and promtail and does a `logcli` query on the Loki instance

* Remove specific version in test scripts

* Bump build image to 0.22.0

* Add restart policy for promtail's service
jeschkies added a commit that referenced this pull request Mar 23, 2023
**What this PR does / why we need it**:
With #6456 we started providing native packages of Loki, Promtail and
logcli. They've been added to Grafana's repository in the meantime.

In order to spread the knowledge of the packages and the repo it should
be documented.

**Which issue(s) this PR fixes**:
Fixes #52


**Checklist**
- [ ] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`

---------

Co-authored-by: René Scheibe <rene.scheibe@gmail.com>
Co-authored-by: J Stickler <julie.stickler@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants