Skip to content

Replace vfsgen with embed for static web assets - #10220

Merged
juliusv merged 4 commits into
prometheus:mainfrom
jan--f:replace-genvfs
Mar 9, 2022
Merged

juliusv merged 4 commits into
prometheus:mainfrom
jan--f:replace-genvfs

Conversation

@jan--f

@jan--f jan--f commented Jan 28, 2022

Copy link
Copy Markdown
Contributor

Another attempt at #9719.

Is a v0.1.0 release of common/assets preferable over using v0.0.0-20220106224503-00591a3ea9c0?

@jan--f
jan--f requested a review from juliusv as a code owner January 28, 2022 14:28
@juliusv

juliusv commented Feb 1, 2022

Copy link
Copy Markdown
Member

Thanks, looks good (although I would be happy if sometime in the future the compression step in the Makefile could be removed).

@roidelapluie can you answer the common/assets module versioning question?

@roidelapluie

Copy link
Copy Markdown
Member

I have released v0.1.0

Comment thread Makefile Outdated
common-build: promu
@bash -c "trap 'echo \">> restoring assets\"; scripts/compress_assets.sh -d;' EXIT; \
echo '>> compressing assets'; \
scripts/compress_assets.sh; \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not having this in "assets" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Apologies if I misunderstand...
This compresses the assets that are specific to prometheus and are located in this repo. For, say alertmanager the assets are different and in a different location. I'm not sure how that could be handled from the common repo.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean, put this under "make assets" not "make build"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahh I see.
The main idea is that I can clean up (i.e. decompress) the assets in case the build fails. If we put the compression into the asset target, we need an extra decompress target. And it also becomes more awkward to run this automatically in case the build fails.
I'd even argue this is the right place conceptually. The assets are ready to go as is, the compression step is really an optimization to keep the binary size a bit smaller. Building prometheus without the compression step still yields a correct binary, its just ~10 MB larger.

@roidelapluie roidelapluie Feb 8, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still think it should be part of make assets, and not build. Why would we need a decompress? Do we need decompress if we have make clean?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also think that using trap is an advanced move, I am not sure we should do this.

Signed-off-by: Jan Fajerski <[email protected]>
Comment thread Makefile

.PHONY: assets
assets: ui-install ui-build
@echo ">> writing assets"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is where I would write it

This requires go 1.16.

Signed-off-by: Jan Fajerski <[email protected]>
This commit add compression before (and decompression after) prometheus
is build. This ensures that gzipped assets are embeded in the prometheus
binary, if the builtinassets build tag is passed. If the build tag is
not passed this step is still executed but has no effect.
All this is executed in a subshell so that we can run the decompress
step even if the build step fails, but retain the exit code of promu.
This cleanup could also cover interrupts, but I left that out for now.

Signed-off-by: Jan Fajerski <[email protected]>
@jan--f

jan--f commented Feb 11, 2022

Copy link
Copy Markdown
Contributor Author

Why would we need a decompress? Do we need decompress if we have make clean?

embed makes it complicated to compress and include the assets not in-place. So the compression step just zips and replaces each asset file. This then needs to be reverted (see also #9719 (comment)).

What do you think of this version?

@roidelapluie roidelapluie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cc @SuperQ

@juliusv

juliusv commented Mar 9, 2022

Copy link
Copy Markdown
Member

This has been sitting here in an approved state for a while now, so I'll merge it. Thanks again! 👍

@juliusv
juliusv merged commit 2c3d45c into prometheus:main Mar 9, 2022
@LeviHarrison

LeviHarrison commented Mar 9, 2022 •

Copy link
Copy Markdown
Contributor

This seems to be causing the UI build and tests to fail in main. Not sure what's going on.`

cc @Nexucis

Scratch that, seems to be #10376 not this.

@roidelapluie

Copy link
Copy Markdown
Member

Thanks @jan--f !

IzhakJakov pushed a commit to IzhakJakov/prometheus that referenced this pull request Mar 23, 2022
* remove vfsgen usages

Signed-off-by: Jan Fajerski <[email protected]>

* web: use embed package for static assets

This requires go 1.16.

Signed-off-by: Jan Fajerski <[email protected]>

* circleci: drop go generate in web/ui

Signed-off-by: Jan Fajerski <[email protected]>

* Makefile: compress web assets before build

This commit add compression before (and decompression after) prometheus
is build. This ensures that gzipped assets are embeded in the prometheus
binary, if the builtinassets build tag is passed. If the build tag is
not passed this step is still executed but has no effect.
All this is executed in a subshell so that we can run the decompress
step even if the build step fails, but retain the exit code of promu.
This cleanup could also cover interrupts, but I left that out for now.

Signed-off-by: Jan Fajerski <[email protected]>
jan--f added a commit to jan--f/syncbot that referenced this pull request Apr 28, 2022
With prometheus/prometheus#10220 and
prometheus/prometheus#10467 prometheus no longer
needs a dedicated asset generation step. This change made in into
prometheus v2.35.0.

Signed-off-by: Jan Fajerski <[email protected]>
arajkumar added a commit to arajkumar/prometheus that referenced this pull request Apr 28, 2022
This file seem to be a remaining of prometheus#10220

Signed-off-by: Arunprasad Rajkumar <[email protected]>
juliusv pushed a commit that referenced this pull request Apr 28, 2022
This file seem to be a remaining of #10220

Signed-off-by: Arunprasad Rajkumar <[email protected]>
roidelapluie pushed a commit to roidelapluie/prometheus that referenced this pull request Jun 22, 2022
This file seem to be a remaining of prometheus#10220

Signed-off-by: Arunprasad Rajkumar <[email protected]>
jan--f added a commit to jan--f/alertmanager that referenced this pull request Nov 13, 2023
This replicates work done in the prometheus repo in
prometheus/prometheus#10220 plus a few follow up
PRs. Asset compression is handled via https://github.com/prometheus/common/tree/main/assets

Signed-off-by: Jan Fajerski <[email protected]>
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.

4 participants