Skip to content

More distgen - directory generation #203

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

Merged
merged 8 commits into from
Mar 14, 2018

Conversation

dhodovsk
Copy link
Contributor

@dhodovsk dhodovsk commented Nov 2, 2017

In this PR we added ability to generate directories 9.4, 9.5 and 9.6 using distgen.

Directories are generated using ./src directory and with command make generate

@@ -51,49 +51,49 @@ Environment variables and volumes
The image recognizes the following environment variables that you can set during
initialization by passing `-e VAR=VALUE` to the Docker run command.

**`POSTGRESQL_USER`**
Copy link
Member

Choose a reason for hiding this comment

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

These trailing spaces are actually left there on purpose.

See: #185 (comment)

Copy link
Contributor

@praiskup praiskup Nov 2, 2017

Choose a reason for hiding this comment

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

Not only that, white-space changes just cause rush in pull-requests. Please consider fixing your editor to not remove trailing white-spaces automatically (submit new PR for white-space issues, when needed)

gen-dirs.sh Outdated
set -e
cd templates
FILES=$(find -follow)
VERSIONS="9.4 9.5 9.6"
Copy link
Member

Choose a reason for hiding this comment

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

VERSIONS should get passed to the script from the Makefile, so that the list can be maintained in one place.

@pkubatrh
Copy link
Member

pkubatrh commented Nov 2, 2017

Since we agreed to remove the generated files in future we should make sure that we do not lose all of the git history by moving latest into template in a separate commit in this PR.

@pkubatrh
Copy link
Member

pkubatrh commented Nov 2, 2017

(not sure if we even need latest after moving it to template)

@pkubatrh
Copy link
Member

pkubatrh commented Nov 2, 2017

moving latest into template in a separate commit in this PR

To have an idea what I mean by this please check how latest/ was introduced: #170

@dhodovsk dhodovsk force-pushed the ultimate-distgen branch 2 times, most recently from cd87eff to 117f913 Compare November 3, 2017 09:56
@dhodovsk
Copy link
Contributor Author

dhodovsk commented Nov 3, 2017

We might also want to preserve Dockerfile history therefore there are now two more commits to make that happen.

Makefile Outdated
@@ -2,6 +2,7 @@
BASE_IMAGE_NAME = postgresql
VERSIONS = 9.4 9.5 9.6
OPENSHIFT_NAMESPACES = 9.2
export VERSIONS
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit scared exporting VERSIONS might break something in the existing scripts. It would be better if you just kept the versions variable local for the gen-dirs.sh script. So something like:

VERSIONS="$(VERSIONS)" ./gen-dirs.sh

@pkubatrh
Copy link
Member

pkubatrh commented Nov 3, 2017

We might also want to preserve Dockerfile history therefore there are now two more commits to make that happen.

That is true, thanks for picking up on this!

Makefile Outdated
${DG_EXEC} --distro rhel-7-x86_64.yaml --multispec-selector version=$${version} --output $${version}/Dockerfile.rhel7; \
done
distgen:
VERSIONS="$(VERSIONS)" ./gen-dirs.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use make targets instead of this script, and please develop them in container-common-scripts project ...

Running this script takes ~12s on my box, because distgen is pretty slow TBH:

$ make distgen
real    0m11.999s
user    0m11.124s
sys     0m0.827s

(at least at this point). make should help with building it in parallel.

Copy link
Member

Choose a reason for hiding this comment

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

I agree. Adding the rules to container-common-scrtips will make the distgen change much easier to adopt in other images if the maintainers choose to do so.

gen-dirs.sh Outdated
/usr/bin/dg --max-passes 25 --template ${PWD}/../Dockerfile.template \
--multispec ../specs/multispec.yml --distro rhel-7-x86_64.yaml \
--multispec-selector version=$1 --output ../$1/Dockerfile.rhel7

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 follow right, but I think the goal is to remove the generated products from this repo, right?

I would really prefer to not list centos/rhel dockerfiles here, and anywhere else. We'll have fedora dockerfiles soon, and maybe scls+fedora? Who knows.. So it would be nice if, when generating Dockerfile, the $OS variable was respected.

gen-dirs.sh Outdated
#!/bin/bash
set -e
cd templates
FILES=$(find -follow)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I dislike this, tbh. Especially that we filter everything through the build script, while simple copy would often be enough.

Maybe we could separate the real templates into ./templates, and normal files under ./files?

Other approach could be using some "manifest file", I implemented something like this in https://github.com/devexp-db/cont-postgresql/blob/master/cl-manifest
That file declars what should be copied, what should be "instantiated" (and by what tool) and everything explicitly (not copying some accidentally occurred files). This should stay executed by postgresql "in parallel" if implemented.

gen-dirs.sh Outdated
mkdir ../${version}/$1
else
echo "Generating: ${version}/$1"
/usr/bin/dg --max-passes 1 --multispec ../specs/multispec.yml \
Copy link
Contributor

Choose a reason for hiding this comment

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

Once this is moved to Makefile (common.mk probably), please ensure that instead of /usr/bin/dg you are using $(DG) variable; to allow anybody to replace the distgen version from local installation (virtualenv).

@dhodovsk
Copy link
Contributor Author

Blocked by sclorg/container-common-scripts#38

manifest.sh Outdated
# Manifest for image directories creation
# every dest and link_name path will be prefixed by $DEST_DIR/$version

DEST_DIR='' # optional, defaults to $PWD
Copy link
Contributor

Choose a reason for hiding this comment

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

s/DEST_DIR/DESTDIR/ -> that's far more standard variable

manifest.sh Outdated

src=templates/root/usr/share/container-scripts/postgresql/common.sh
dest=root/usr/share/container-scripts/postgresql/common.sh
mode=0755
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't have to be executable.

manifest.sh Outdated

link_target=../test
link_name=test
"
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to create absolute symlinks on the host system during build. Such simlinks - if copied into image - will lead to non-existing paths.

manifest.sh Outdated

src=templates/root/usr/share/container-scripts/postgresql/scl_enable
dest=root/usr/share/container-scripts/postgresql/scl_enable
mode=0755;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this needs to be executable.

@praiskup
Copy link
Contributor

praiskup commented Jan 4, 2018

  • I really like the speed of the generated output
  • I love the fact that we can adjust permissions of particular files! (the current approach doesn't ensure the proper permissions, but the following point should solve it...)
  • I miss dealing with Dockerfile.rhel7 - it is not re-created if I drop it (probably we should drop everything generated from the source directory)
  • ccpp.yml is not geneerated
  • I would not use the templates/ directory, but rather source/ or src/ (not everything under that is a jinja/distgen template)

For me, I'm leaning towards +1, but not without another positive votes.

@phracek
Copy link
Member

phracek commented Jan 8, 2018

The PR looks good to me. Good job @dhodovsk .
I am fine with merging. I would prefer to ACK it and create another PR for rest issues.

WDYT?

@TomasTomecek
Copy link
Contributor

Wow, I'm really impressed how far distgen got. The manifest is some really good work (I would personally prefer json/yaml + python, but if the proposed implementation suits your needs, that's just fine).

I also agree with Pavel the time will tell. Hence I'm +1 on merging and addressing issues as they come.

@dhodovsk dhodovsk force-pushed the ultimate-distgen branch 3 times, most recently from 2352783 to b50df2c Compare January 8, 2018 16:15
@dhodovsk
Copy link
Contributor Author

dhodovsk commented Jan 9, 2018

The requested changes should be now applied.

I'd like to discuss the possibility to drop directories that can be generated. I think we should do it to prevent the case someone commits changes in generated files (and not src). But it seems like a big step and we have to make sure it is safe.

@dhodovsk
Copy link
Contributor Author

I am now rebasing and adding following changes:

Is that enough? @TomasTomecek @pkubatrh

@TomasTomecek
Copy link
Contributor

It should be. I don't know if the cccp.yaml file present in git repo overrides the one defined in cccp index git repo.

@pkubatrh
Copy link
Member

Is there a way to test things out with the current configuration before merging the changes?

@pkubatrh
Copy link
Member

pkubatrh commented Mar 13, 2018

Now that I look at it more closely. Will the prebuild script be even run if the yaml file in the container-index point to versioned directories?

If I understand this correctly cccp expects to find the cccp.yaml file over there and will not look for it in src/, or anywhere else in the matter. And then cccp wont know it should first run the hook to generate the files.

yum install distgen make -y

mkdir -p root/
make VARIANT=centos DISTRO=centos-7-x86_64 source
Copy link
Member

Choose a reason for hiding this comment

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

Probably needs to be make TARGET=centos7 generate? We also do not need the root/ directory creation.

@pkubatrh
Copy link
Member

Actually according to https://github.com/CentOS/container-index/blob/master/README.md the cccp.yml file does not seem to even accept the prebuild-script configuration option. So I guess we will have to change the config in the index.

@dhodovsk
Copy link
Contributor Author

The commit Add prebuild-script to cccp.yml is now reverted. Please, let me know if there is anything else I could do.

@pkubatrh
Copy link
Member

The commit Add prebuild-script to cccp.yml is now reverted. Please, let me know if there is anything else I could do.

I think we need at least the hook part of the commit (the actual script I commented on), since the versioned directories will still need to be generated.

Its just that the configuration option to run it will need to be added elsewhere - similarly to https://github.com/container-images/tools

@dhodovsk
Copy link
Contributor Author

I am sorry, but I have no insight in functionality and importance of changes related to cccp, so I am not able to decide the right workflow, could you please provide more info of what changes exactly are needed so the requirements are met? Or maybe provide a commit with those changes?

@pkubatrh
Copy link
Member

I have added a commit with what I believe is needed for the cccp to work once changes are made in https://github.com/CentOS/container-index

Now the question is, do we merge this in first and make the changes in index later? The other option is to merge this PR in without the removal of versioned directories so that cccp works both with the old and with new configuration option (prebuild-script).

@hhorak @praiskup @omron93 WDYT?

@omron93
Copy link
Contributor

omron93 commented Mar 13, 2018

I would merge this PR and next fix the index.

@pkubatrh
Copy link
Member

[test-openshift]

@praiskup
Copy link
Contributor

@hhorak would it be OK to have the cccp outage temporarily?

@pkubatrh
Copy link
Member

Since Honza will not be able to comment on this for a while and everyone else is in favour of merging the PR and fixing the issues (and the tests are green) let us merge this in.

@TomasTomecek
Copy link
Contributor

Woooooooooh!

omron93 pushed a commit to omron93/container-index that referenced this pull request Mar 15, 2018
@pkubatrh pkubatrh mentioned this pull request Mar 23, 2018
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.

6 participants