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

More logical buildsystem #19

Merged
merged 5 commits into from
Aug 28, 2017
Merged

Conversation

praiskup
Copy link
Contributor

@praiskup praiskup commented Jul 27, 2017

Use more standardized "make" workflow

From now we don't blindly squash image if there are no changes
(aka docker build was no-op). We also remove old (unreferenced
images if those are to be replaced by new images.

`make` or `make build`
    Builds the images.

`make tag`
    Tag built images (depends on `make build`).

`make test`
    Tests the :latest image (build if necessary).  This depends on
    `make tag` because the existing test-cases out in the wild
    depend on tagged images.  The most importantly the s2i tool
    doesn't seem to work with $IMAGE_ID only.

The make tag also tags the image with :squashed or :raw suffixes,
while the :latest image points (only) to one of them.

@pkubatrh
Copy link
Member

All in all I really like the changes from the point of how everything is handled by make dependencies and I was considering to try writing something similar as this myself but unfortunately I am not a great make-magician as of yet.
+1 for build-serial! That is a really nice way to make sure we are not running in parallel by default and seems worthwhile to merge even by itself.

As for the qualms I have about this:
I think skipping the build stage when a build is already done can be omitted. It definitely is proper make work-flow but does not make much sense in the docker world since a build of an existing image is nearly instantaneous due to the docker cache. At least when the images are not squashed, which users will not do anyway if they are concerned for how much of time is spent on the build process.
Removing the build stage skip would make common.mk a bit easier to read as there would not be a reason to generate dependencies on each of the files inside the images' respective directories.
The issue then would be how to modify the makefile while making sure the work-flow (which is one of the best points about this change imo) stays the same, or at least very similar...

@pkubatrh
Copy link
Member

One additional thing - using image's ID as the content of the IMAGE_NAME variable used inside tests might break said tests for some images that rely on it being a name string that can be parsed properly (I have implemented something like this in thermostat16* tests - sclorg/thermostat-container@a2c6dc3#diff-8c6c67279d694dec8dcd75f8e276c4d9R34)

@omron93
Copy link
Contributor

omron93 commented Aug 3, 2017

One additional thing - using image's ID as the content of the IMAGE_NAME variable used inside tests might break said tests for some images that rely on it being a name string that can be parsed properly (I have implemented something like this in thermostat16* tests - sclorg/thermostat-container@a2c6dc3#diff-8c6c67279d694dec8dcd75f8e276c4d9R34)

Also it is not possible for s2i based images. s2i build works only with tags and it is not possible to use image ID !

praiskup added a commit to praiskup/container-common-scripts that referenced this pull request Aug 18, 2017
The permissions/ownership of the /dev/pts/* file (symlinked from
/dev/fd/$fd) is uncertain, so we can not rely on the fact that we
can write to this file (happened to me when I ssh as 'root' to my
RHEL7 testing box and then I 'sudo su - foo').

Since we already depend on Bash features extensively, let's rather
let the shell allocate a temporary fifo file with >(cmd) feature.

While we are on it, separate the parsing method into self-standing
method which can be easily reused, and allow parsing also standard
error output (will be needed at least in sclorg#19).
praiskup added a commit that referenced this pull request Aug 18, 2017
The permissions/ownership of the /dev/pts/* file (symlinked from
/dev/fd/$fd) is uncertain, so we can not rely on the fact that we
can write to this file (happened to me when I ssh as 'root' to my
RHEL7 testing box and then I 'sudo su - foo').

Since we already depend on Bash features extensively, let's rather
let the shell allocate a temporary fifo file with >(cmd) feature
and redirect to a shell file descriptor number by 'cat - >&$fd'.

While we are on it, separate the parsing method into self-standing
method which can be easily reused, and allow parsing also standard
error output (will be needed at least in #19).

Fixes #21.
@praiskup
Copy link
Contributor Author

Thanks a lot for the comments. So I changed the semantics a bit to take your notes into account. Now, when doing make test the images are automatically tagged (TBH I don't claim that it is ideal approach, but at least for s2i tests we need IMAGE_NAME tag so that's sort of compromise). When doing plain make, images are still only built (not tagged).

IMO this is still beneficial:

  • most importantly, we don't squash unless really necessary (aka. there's new unsquashed image)
  • we don't spread untagged images (only if you interrupt the build in the middle of the build)
  • make clean removes both squashed/non-squashed image

@praiskup praiskup force-pushed the more-logical-buildsystem branch 2 times, most recently from 9c76d50 to 5aca0b5 Compare August 23, 2017 17:42
{
local base squashed_from squashed= unsquashed=$IMAGE_ID
test "$SKIP_SQUASH" = 1 && return 0

# FIXME: We have to use the exact versions here to avoid Docker client
# compatibility issues
local squash_version=1.0.5
Copy link
Contributor

Choose a reason for hiding this comment

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

@praiskup I vote for not checking for exact docker_squash version.

Imagine a situation when we decides to change this version. We/user will have to update docker_squash on testing machine to make similar PR tests to pass.
But since other images won't use newest version of container-common-scripts its PRs will fail.

So common-scripts in images will have to updated all in once and all other PRs will fail till that time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@omron93 wrote:

I vote for not checking for exact docker_squash version.

+1. I was not brave enough to drop that ... since this hack was important enough to be fixed many, many times ... So the question is whether we really care about the version or not. Maybe there should be version >= 1.0.5, but IMO this deserves separate PR and discussion.

Imagine a situation when we decides to change this version. We/user will have to update docker_squash on testing machine to make similar PR tests to pass.

Right, but IMO it is not that huge issue, since we maintain the CI. I don't think user will be somewhat bothered by this.

But since other images won't use newest version of container-common-scripts its PRs will fail.

Agreed. IMO in such case it would be the right time to update common in the remote repos; and yes -> I don't claim that such hacks are not expensive.

So, since the version check was already merged and is not the part of this PR, what about to remove that later (and let others ack this?)?

Copy link
Contributor

Choose a reason for hiding this comment

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

So, since the version check was already merged and is not the part of this PR, what about to remove that later (and let others ack this?)?

You are right

@omron93
Copy link
Contributor

omron93 commented Aug 24, 2017

when doing make test the images are automatically tagged (TBH I don't claim that it is ideal approach, but at least for s2i tests we need IMAGE_NAME tag so that's sort of compromise)

@praiskup Or if you would like to avoid this, some "random" image name can be generated for tests only and removed after.

Overall, it looks very good. Thanks.

@praiskup
Copy link
Contributor Author

@praiskup Or if you would like to avoid this, some "random" image name can be generated for tests only and removed after.

Can be, but it brings some complexity -- and I'm not good enough with s2i testing, so I would rather delay this for after-PR time :) if any. Even as-is, the PR somewhat improves the resource management (major motivation for this PR) so I'm less motivated to solve more problems now.

common.mk Outdated
VERSIONS="$(VERSIONS)" $(script_env) $(test)
VERSIONS="$(VERSIONS)" $(script_env) $(tag)

.PHONY: test-openshift
test-openshift: script_env += TEST_OPENSHIFT_MODE=true
test-openshift: $(VERSIONS)
Copy link
Member

Choose a reason for hiding this comment

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

imo test-openshift should depend on tag as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, good catch

@pkubatrh
Copy link
Member

otherwise lgtm

From now we don't blindly squash image if there are no changes
(aka docker build was no-op).  We also remove old (unreferenced
images if those are to be replaced by new images.

`make` or `make build`
    Builds the images.

`make tag`
    Tag built images (depends on `make build`).

`make test`
    Tests the :latest image (build if necessary).  This depends on
    `make tag` because the existing test-cases out in the wild
    depend on tagged images.  The most importantly the s2i tool
    doesn't seem to work with $IMAGE_ID only.
This helps on builders where umask is e.g. 0077.
It is much more standard to use 'make check' than 'make test';
but let's keep them both (aliases) for compatibility.
@praiskup
Copy link
Contributor Author

Fixed the test-openshift target, and build-alltarget so it doesn't print not-right-now-built images. Since we have basically 2xLGTM now, I'm merging this.

@praiskup praiskup merged commit 92c8e45 into sclorg:master Aug 28, 2017
@praiskup praiskup deleted the more-logical-buildsystem branch March 28, 2018 14:06
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.

None yet

3 participants