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

Build the apache-tomcat containers as build_flavors #1755

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

dirkmueller
Copy link
Member

This allows to sync the -RELEASE tag between multiple flavors, which is a requirement for appcollection.

For now all the build_flavors need to be manually passed in for _multibuild and _service generation. This could be eventually replaced by more automagic later on.

dcermak pushed a commit that referenced this pull request Sep 26, 2024
dcermak pushed a commit that referenced this pull request Sep 26, 2024
Copy link

github-actions bot commented Sep 26, 2024

Created a staging project on OBS for 6: home:defolos:BCI:Staging:SLE-15-SP6:6-1755
Changes pushed to branch 6-1755 as commit 040c2f0aa902e312ed8342f190a363236c67a6a2
Build succeeded ✅

Build Results

Repository images in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for x86_64: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk21 ⛔ excluded live log

Repository images in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for aarch64: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk21 ⛔ excluded live log

Repository images in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for s390x: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk21 ⛔ excluded live log

Repository images in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for ppc64le: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk21 ⛔ excluded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for x86_64: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ✅ succeeded live log
sac-apache-tomcat-10-image:openjdk21 ✅ succeeded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for aarch64: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ✅ succeeded live log
sac-apache-tomcat-10-image:openjdk21 ✅ succeeded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for s390x: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk21 ⛔ excluded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP6:6-1755 for ppc64le: current state: published
Build results:

package name status build log
sac-apache-tomcat-10-image ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk17 ⛔ excluded live log
sac-apache-tomcat-10-image:openjdk21 ⛔ excluded live log

Build succeeded ✅

To run BCI-tests against this PR, use the following command:

OS_VERSION=15.6 TARGET=custom BASEURL=registry.opensuse.org/home/defolos/bci/staging/sle-15-sp6/6-1755/ tox -- -n auto
The following images can be pulled from the staging project:
  • registry.opensuse.org/home/defolos/bci/staging/sle-15-sp6/6-1755/containerfile/containers/apache-tomcat:10.1-openjdk17

dcermak pushed a commit that referenced this pull request Sep 26, 2024
@@ -1320,9 +1344,22 @@ async def write_file_to_dest(fname: str, contents: str | bytes) -> None:
False
), f"got an unexpected build_recipe_type: '{self.build_recipe_type}'"

if self.build_flavor:
flavors: str = "\n".join(
" " * 4 + f"<package>{pkg}</package>"
Copy link
Member

Choose a reason for hiding this comment

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

This looks really odd, just to produce what this does:

Suggested change
" " * 4 + f"<package>{pkg}</package>"
f" <package>{pkg}</package>"

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess this comes down to a personal preference and DRY, don't care either way.

src/bci_build/package/__init__.py Outdated Show resolved Hide resolved
Comment on lines 79 to 80
build_flavor=f"openjdk{jre_version}",
all_build_flavors=[f"openjdk{ver}" for ver in all_jre_versions],
Copy link
Member

Choose a reason for hiding this comment

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

Taking my idea about one single item, I think something like this could be done here.

        build_flavors=[Flavor(name=f"openjdk{ver}", current=ver==jre_version) for ver in all_jre_versions],

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is way too complicated for a simple container definition, and would have to repeated for each one of them (lets think about the python containers becoming multibuild, for example).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it was just an idea, because I wasn't that happy with the solution proposed.

tests/test_service.py Show resolved Hide resolved
dcermak pushed a commit that referenced this pull request Sep 27, 2024
dcermak pushed a commit that referenced this pull request Sep 27, 2024
Copy link

github-actions bot commented Sep 27, 2024

Created a staging project on OBS for Tumbleweed: home:defolos:BCI:Staging:Tumbleweed:Tumbleweed-1755
Changes pushed to branch Tumbleweed-1755 as commit dbef112d85e69fdf43f51d39a264978031d8a4f5
Build succeeded ✅

Build Results

Repository images in home:defolos:BCI:Staging:Tumbleweed:Tumbleweed-1755 for x86_64: current state: published
Build results:

package name status build log
apache-tomcat-10-image ⛔ excluded live log
apache-tomcat-10-image:openjdk17 ⛔ excluded live log
apache-tomcat-10-image:openjdk21 ⛔ excluded live log
apache-tomcat-10-image:openjdk22 ⛔ excluded live log
apache-tomcat-9-image ⛔ excluded live log
apache-tomcat-9-image:openjdk17 ⛔ excluded live log

Repository images in home:defolos:BCI:Staging:Tumbleweed:Tumbleweed-1755 for aarch64: current state: published
Build results:

package name status build log
apache-tomcat-10-image ⛔ excluded live log
apache-tomcat-10-image:openjdk17 ⛔ excluded live log
apache-tomcat-10-image:openjdk21 ⛔ excluded live log
apache-tomcat-10-image:openjdk22 ⛔ excluded live log
apache-tomcat-9-image ⛔ excluded live log
apache-tomcat-9-image:openjdk17 ⛔ excluded live log

Repository containerfile in home:defolos:BCI:Staging:Tumbleweed:Tumbleweed-1755 for x86_64: current state: published
Build results:

package name status build log
apache-tomcat-10-image ⛔ excluded live log
apache-tomcat-10-image:openjdk17 ✅ succeeded live log
apache-tomcat-10-image:openjdk21 ✅ succeeded live log
apache-tomcat-10-image:openjdk22 ✅ succeeded live log
apache-tomcat-9-image ⛔ excluded live log
apache-tomcat-9-image:openjdk17 ✅ succeeded live log

Repository containerfile in home:defolos:BCI:Staging:Tumbleweed:Tumbleweed-1755 for aarch64: current state: published
Build results:

package name status build log
apache-tomcat-10-image ⛔ excluded live log
apache-tomcat-10-image:openjdk17 ✅ succeeded live log
apache-tomcat-10-image:openjdk21 ✅ succeeded live log
apache-tomcat-10-image:openjdk22 ✅ succeeded live log
apache-tomcat-9-image ⛔ excluded live log
apache-tomcat-9-image:openjdk17 ✅ succeeded live log

Build succeeded ✅

To run BCI-tests against this PR, use the following command:

OS_VERSION=tumbleweed TARGET=custom BASEURL=registry.opensuse.org/home/defolos/bci/staging/tumbleweed/tumbleweed-1755/ tox -- -n auto
The following images can be pulled from the staging project:
  • registry.opensuse.org/home/defolos/bci/staging/tumbleweed/tumbleweed-1755/containerfile/opensuse/apache-tomcat:latest

dcermak pushed a commit that referenced this pull request Sep 27, 2024
dcermak pushed a commit that referenced this pull request Sep 27, 2024
Comment on lines +197 to +201
{%- set all_build_flavors = [""] %}
{%- if image.crate and image.build_flavor %}
{%- set all_build_flavors = image.crate.all_build_flavors(image) %}
{%- endif %}
{%- for flavor in all_build_flavors %}
Copy link
Member

Choose a reason for hiding this comment

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

We should have a BaseContainerImage.all_build_flavors to avoid this. In theory, you have this attribute, but only if there's a crate, make it a function/property that always exists and perform this check.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I was trying to avoid storing the (essentially duplicated) information in the ContainerImage because it is only needed for this one case. Polluting yet another method into that ContainerImage seems rather messy to me.

my intention was to move the generation of _multibuild and _service into the Crate entirely, but that was a bit too much for one commit so it'll come later on.

src/bci_build/package/__init__.py Show resolved Hide resolved

def __init__(self, containers: list):
"""Assign the crate for every container."""
self._all_build_flavors: dict[tuple, set] = {}
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand why we need this dict[tuple, set]. All calls are done with a container object, that in theory is a BaseContainerImage.

If this is the case, can't we just use something like dict[BaseContainerImage, str] and use self._all_build_flavors[container] = container.build_flavor?

Not even sure if we need a dict, or if it could be just a list.

Copy link
Member Author

Choose a reason for hiding this comment

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

The crate is to unify over (os_version, container.package_name). if I understand correctly, you're unifying over all given containers (which could be many different versions, which have different build flavors depending on version and also have different package names, like in the tomcat case). However, we do not want to collect flavors that are not built for this version or not build for this package name. hence, we need to group them by this, which is not working as far as I can see in your proposal. Maybe I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

As an example, with tomcat, there are two flavors on SP6 (17, 21) and 3 on tumbleweed (17, 21, 22). the generated _multibuild file needs to be specific to the os-version. in theory it could even be specific to the package name.

dict/set are the most efficient ways to aggregate it.


def all_build_flavors(self, container):
"""Return all build flavors for this container in the crate"""
return sorted(
Copy link
Member

Choose a reason for hiding this comment

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

If you are sorting here and in multibuild, I would rather have it sorted in __init__, it would be called once and always be sorted, which might be a small tidy tiny faster each future call.

Copy link
Member Author

Choose a reason for hiding this comment

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

in __init__ it is still a set, which is unsorted. I agree we move away from storing it as a set and switch to a sorted list. I don't think you'll be able to measure any difference but I agree it is more efficient.

dcermak pushed a commit that referenced this pull request Sep 27, 2024
dcermak pushed a commit that referenced this pull request Sep 27, 2024
dcermak pushed a commit that referenced this pull request Sep 27, 2024
Copy link

github-actions bot commented Sep 27, 2024

Created a staging project on OBS for 7: home:defolos:BCI:Staging:SLE-15-SP7:7-1755
Changes pushed to branch 7-1755 as commit fd052f5d190c04dcaeb16b2dce619ae4a6d0e724
Build succeeded ✅

Build Results

Repository images in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for x86_64: current state: published
Build results:

package name status build log
dotnet-8.0 ⛔ excluded live log

Repository images in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for aarch64: current state: published
Build results:

package name status build log
dotnet-8.0 ⛔ excluded live log

Repository images in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for s390x: current state: published
Build results:

package name status build log
dotnet-8.0 ⛔ excluded live log

Repository images in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for ppc64le: current state: published
Build results:

package name status build log
dotnet-8.0 ⛔ excluded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for x86_64: current state: published
Build results:

package name status build log
dotnet-8.0 ✅ succeeded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for aarch64: current state: published
Build results:

package name status build log
dotnet-8.0 ⛔ excluded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for s390x: current state: published
Build results:

package name status build log
dotnet-8.0 ⛔ excluded live log

Repository containerfile in home:defolos:BCI:Staging:SLE-15-SP7:7-1755 for ppc64le: current state: published
Build results:

package name status build log
dotnet-8.0 ⛔ excluded live log

Build succeeded ✅

To run BCI-tests against this PR, use the following command:

OS_VERSION=15.7 TARGET=custom BASEURL=registry.opensuse.org/home/defolos/bci/staging/sle-15-sp7/7-1755/ tox -- -n auto
The following images can be pulled from the staging project:
  • registry.opensuse.org/home/defolos/bci/staging/sle-15-sp7/7-1755/containerfile/bci/dotnet-sdk:8.0
⚠️⚠️ Project and Branch have been deleted ⚠️⚠️

dcermak pushed a commit that referenced this pull request Sep 30, 2024
This allows to sync the -RELEASE tag between multiple flavors, which
is a requirement for appcollection.

For that, BaseContainerImages can be optionally grouped into a
ContainerCrate, which takes care of collecting build_flavors for
proper _multibuild and _service generation.
dcermak pushed a commit that referenced this pull request Oct 1, 2024
dcermak pushed a commit that referenced this pull request Oct 1, 2024
Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

To be frankly honest, I don't particularly like the current abstraction2 both in naming and behavior: it adds additional behind the scenes mutation and doesn't make it very obvious that we're actually combining multiple containers in one package.

I'd like to re-design the API. Merge this as is, if it is time critical though.

@dirkmueller
Copy link
Member Author

To be frankly honest, I don't particularly like the current abstraction2 both in naming and behavior: it adds additional behind the scenes mutation and doesn't make it very obvious that we're actually combining multiple containers in one package.

well, names can be changed. so "PackageContainer" then instead of Crate?

I'd like to re-design the API. Merge this as is, if it is time critical though.

I don't see how .. yeah, it is kinda urgent for the SAC prototype, but I can adjust it if there is a concrete feedback on what to improve.

@dirkmueller
Copy link
Member Author

as discussed, will be solved in a followup.

@dirkmueller dirkmueller merged commit 7e56a8c into main Oct 1, 2024
9 checks passed
@dirkmueller dirkmueller deleted the multibuild_tomcat branch October 1, 2024 15:04
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.

3 participants