Bug 241925 - net-mgmt/prometheus2: Frontend files missing in 2.14.0
Summary: net-mgmt/prometheus2: Frontend files missing in 2.14.0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Dmitri Goutnik
URL:
Keywords: buildisok, patch-ready
Depends on:
Blocks:
 
Reported: 2019-11-12 18:12 UTC by David O'Rourke
Modified: 2019-11-13 21:44 UTC (History)
2 users (show)

See Also:


Attachments
net-mgmt/prometheus2: Add UI assets (1.84 KB, patch)
2019-11-13 18:54 UTC, David O'Rourke
dor.bsd: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David O'Rourke 2019-11-12 18:12:14 UTC
In net-mgmt/prometheus2 2.14.0, some frontend files are missing after the update to the new React UI.

This does not affect the ability of Prometheus to scrape metrics, or to be visualized in tools like Grafana, or alerting, but does mean that the Prometheus UI cannot be accessed at the moment.

I am currently working on a fix for this, apologies for the breakage.

-David
Comment 1 Ryan Steinmetz freebsd_committer freebsd_triage 2019-11-12 22:16:26 UTC
This was caused by two things:

1. We don't pass all the correct build flags.  We need to add this to the Makefile:

GO_BUILDFLAGS+=-mod=vendor -a -tags netgo,builtinassets

2. Which causes the build to expect two new go source files which must be provided or build.  In their Makefile, they expect that 'gmake assets' gets called before the build starts, which runs yarn, compiles/downloads a bunch of stuff and creates two required go files for the above to work:
web/ui/ui.go
web/ui/assets_vfsdata.go

assets_vfsdata.go is ~14M and has all of the HTML from the templates/ dir embedded in it.

We probably don't want to run `gmake assets` as we do not want to reach out to the Internet during the port build phase.  So, as a workaround, I'd suggest hosting the above two files somewhere.  Then, open a PR with the prometheus developers to request that they build/embed these files in their release tarballs moving forward.
Comment 2 Ryan Steinmetz freebsd_committer freebsd_triage 2019-11-12 22:19:24 UTC
A second workaround could include deploying the templates/ directory to disk via the port.  You would need to figure out how to tell prometheus the full path to this as I think the source expects that it's relative.
Comment 3 Ryan Steinmetz freebsd_committer freebsd_triage 2019-11-12 23:16:45 UTC
These are the generated/required files for 2.14.0:

https://people.freebsd.org/~zi/ui.go
https://people.freebsd.org/~zi/assets_vfsdata.go
Comment 4 Dmitri Goutnik freebsd_committer freebsd_triage 2019-11-12 23:57:42 UTC
(In reply to Ryan Steinmetz from comment #1)
"-mod=vendor" and "-a" are not needed - go.mk already sets "-mod=vendor" as a result of USES=go:modules and "-a" will cause a rebuild of everything including standard library bits. I'm not sure why upstream needed -a, probably some CI workaround.
Comment 5 Ryan Steinmetz freebsd_committer freebsd_triage 2019-11-13 03:45:48 UTC
Regardless, the important bit is adding -tags netgo,builtinassets.
Comment 6 David O'Rourke 2019-11-13 10:03:31 UTC
I'll be hosting the pre-compiled assets on Github, which I should have a patch for later today.
Comment 7 David O'Rourke 2019-11-13 18:54:05 UTC
Created attachment 209135 [details]
net-mgmt/prometheus2: Add UI assets

This patch updates net-mgmt/prometheus2 to pull in pre-compiled assets from the ports-assets/net-mgmt_prometheus2 GitHub repository and use them when compiling Prometheus, enabling the new UI to function properly.

The assets are copied over in the post-patch stage and testing shows the Prometheus UI to be functional again.

Apologies again for the breakage,

-David
Comment 8 Automation User 2019-11-13 19:14:17 UTC
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/95741184
Comment 9 commit-hook freebsd_committer freebsd_triage 2019-11-13 21:44:16 UTC
A commit references this bug:

Author: dmgk
Date: Wed Nov 13 21:43:56 UTC 2019
New revision: 517390
URL: https://svnweb.freebsd.org/changeset/ports/517390

Log:
  net-mgmt/prometheus2: Add missing frontend files

  Pull in pre-compiled assets from the ports-assets/net-mgmt_prometheus2 GitHub
  repository and use them when compiling Prometheus, enabling the new UI to
  function properly.

  While here, remove GO_PKGNAME which is not needed with USES=go:modules.

  PR:		241925
  Submitted by:	David O'Rourke <dor.bsd@xm0.uk> (maintainer)
  Approved by:	tz (mentor, implicit)

Changes:
  head/net-mgmt/prometheus2/Makefile
  head/net-mgmt/prometheus2/distinfo
Comment 10 Dmitri Goutnik freebsd_committer freebsd_triage 2019-11-13 21:44:53 UTC
Committed with some changes, thanks for the quick fix!