This release further parallelizes the delta creation code to do some
more complex breakup of tasks. Typically users create multiple versions
back of deltas. While each version ran massively parallel delta jobs,
each version itself ran one after another synchronously. This began to
cause problems when certain files took several minutes to complete,
because the next version could not start until the previous finished,
compounding the runtime by the number of versions back * long file.
Now, the code check if it can run a thread for each version, and then
splits up threads within those version pools so when the large file is
hit, all versions run at the same time, capping it to 1 long file run.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Run each version back for delta packs in its own thread, and divide the total
number of CPUs available and use that in each version thread. There are
cases where only a few files remain to delta, and they take multiple
minutes to finish. Each version runs synchronously with many threads, so
at the end of a version we have to wait for the long delta to finish before
running through another. version This changes it so by the end of the run -
all the large/slow files are building at the same time, capping it to just
one long file run, vs long run * number of versions back.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Fix a number of AFB bugs:
- Previous build's upstream format was being incorrectly looked up,
resulting in upstream format boundary crossing detection failing.
- PreRun check was incorrectly skipping format build commands, resulting
in "stage for mix" being run twice.
- Only the UInt32 upstream version was being modified, resulting in the
second half of 'mixer build upstream-format' being run in the wrong
container.
- The wrong format was being printed out for 'mixer versions' if
crossing an upstream format boundary.
Refactor Cobra command PreRun
Simplified the PreRun logic that happens before every command. This also
fixes an issue where format bump build commands could be run with
--native=false, when they need to be run natively.
Fix AFB mixversion and LAST_VER setting
1) Changes how the format bump builds set mixversion so that it no
longer skips a version number in some situations.
2) Updates the update/image/LAST_VER file after the +10 build back
to the +20 build value, so mixer is ready to do the next mix.
Refactor file download code
This patch refactors and consolidates the different file download code
scattered throughout helper.go and builder.go.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This patch changes the way SERVER_STATE_DIR is created if it does not
already exist, in order to facilitate mounting the directory inside the
Docker container.
By default, SERVER_STATE_DIR in 'builder.conf' is set to PWD +
"/update", a path that typically does not already exist and is created
automaticallly the first time mixer builds bundles. Historically, 'mixer
build bundles' was run as root; now it is run as root within a Docker
container. In either case, this "update" directory ends up owned by
root.
For security reasons, mixer will not mount to the container any directory
to which the caller does not have read/write permissions. This means that
on subsequent calls, mixer refuses to mount the "update" directory it just
created, as it is owned by root.
This patch resolves this for most users by creating the SERVER_STATE_DIR
with the uid/gid of its closest existant ancester. In the default case,
this is the uid/gid of the PWD. Users with existing mixes will need to
manually chown the SERVER_STATE_DIR to a uid/gid they have read/write
permission to.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
This patch includes the following changes:
Reorder which version builds first to simplify
The +20 build can be built fully at the beginning all the way though,
removing the need to swap tooling to build the +10 (just so things are
built in chronological order). The +10 build is created with the -
possibly - old tooling only after, and reduces the amount of
back-and-forth swapping of tooling.
Fix misc errors with formats and version blocks
The right format number needs to be passed into both functions, and we
*must* ignore the fact that the version and format are lower than the
previous build in the format bump case. It reduces complexity and tool
changes by building the +20 version all the way through first.
Two top level commands now exist for running format bumps:
- build upstream-format This command builds the necessary builds to
cross a mix over a format bump.
- build format-bump This command builds a bump for downstream users.
Fix docker mount path lookup
This patch fixes a bug with the way mixer determined which fields in
'builder.conf' were mountable paths.
Previously, mixer treated every field in [Builder] and [Mixer] as paths
on the filesystem (or paths to files whose parent directories needed to
be mounted). Introducing the "DOCKER_IMAGE_PATH" field broke this
approach.
This patch introduces a new "mount" tag on the config struct fields that
indicates whether a config field represents a mountable path. This has
several benefits:
1) It allows us to know definitively which fields we should look at.
2) It allows us to look at the entire 'builder.conf', not just the
[Builder] and [Mixer] sections.
3) It removes the restriction that paths in 'builder.conf' be absolute.
This absolute check was mostly a sloppy way of checking if a field was
in fact a path.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
This patch adds an access check on each directory in the config file
before mounting it to the container. This prevents the user from
accidentally (or surreptitiously) granting the container access to
directories they shouldn't.
The config parsing for directory extraction code is also refactored to
provide better results and more accurate error messages.
This patch also adds unit tests for directory access checks, directory extraction,
and mount path list reduction.
For these tests to not fail inside the Docker container on Travis, they
need to not be run as root. This patch thus also creates a non-root user
(but with wheelnopw membership), and runs as this user instead.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
This step cannot occur for every format bump build as it previously did,
as it is only valid for format bump builds for crossing an upstream
format boundary. If you are simply bumping your own mix format,
independent of upstream, this should not occur.
Moved the call to CheckFormatBumpNeeded, as this is the only place that
definitively knows this step needs to occur.
Adds an "UnstageMixFromBump" command that resets the "upstreamversion"
file back to the contents found in "upstreamversion.bump", if it exists.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
This commit temporarily sets the default value for --native to true,
making running inside a container an opt-in behavior. This will make the
testing and transition to containerized mixer easier. Eventually this
switch will be flipped back to false, making containerized the default
running mode.
To run in container, append '--native=false' to your command.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
This patch Dockerizes mixer build commands. A new '--native' flag is added
that, if passed, will run mixer on the host system the way it always has.
This defaults to false.
For build commands, if '--native' is false, mixer now pulls an image file
published by upstream that contains the core Clear Linux OS and mixer
toolchain for the version of Clear Linux defined in the upstreamversion file,
which mixer than uses to build a Docker image. Mixer then re-runs the original
mixer build command within a container of that Docker image.
This ensures that you are always using a version of the mixer toolchain
compatible with the upstream version off of which you are building. This is
required for building across format boundaries. Additionally, mixer now
checks if a build crosses format boundaries, and instructs you how to
first perform a format-bump build.
Mixer attempts to re-use already downloaded or built Docker images to
minimize the performance impact of running inside a container. This eliminates
the time spent on re-building the container image across subsequent
runs. Mixer uses the latest-released version for a given format, however,
so image content will become stale regularly.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
This adds support for detecting if a format bump is needed, and the
supplementary functions to perform one. All of the build steps are done
for the user, and just need to be called in the correct order to
generate the two builds.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This release includes fixes for mixin, notably enabling new config for all
executions instead of per cmd basis, and enables users to name the bundle
they want the package added to instead of defaulting to the repo name.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
When adding a package provide an optional --bundle flag so users can set
which bundle their package is added to instead of automatically adding
it to a bundle named after the repo the package came from.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This patch fixes a bug where new config option was not enabled when
reading the config file. Instead of enabling it for every place config
is used, new config is now always enabled when the program executed.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
This release adds bundle information files under /usr/share/clear/allbundles
to allow clients to perform future bundle-info operations. Write with 'pretty'
indented JSON so it is grep-able and human-readable in the mean-time. Users
will have to install the os-core-update-index bundle to get this functionality.
The delta pack creation code has been re-written and parallelized to
greatly improve performance. All deltas are now created in parallel
using the full manifests, and then the packs are created in parallel by
just using the pre-created deltas from the delta/ folder, instead of
doing all the processing per bundle.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Delta creation runs in parallel, so use descriptive prefixes that can be
easily queried from the log file later on since they will not all be
grouped.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Build all of the deltas first using the full manifest, and then add them
to the packs instead of finding and creating deltas synchronously on a
per-bundle-basis.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Now that more files are included in the os-core-update-index file sort
them by version instead of leaving them sorted by name. This didn't
matter before because there was only ever one file that was listed in
the manifest.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Add bundle information files under /usr/share/clear/allbundles to allow
clients to perform future bundle-info operations. Write with 'pretty'
indented JSON so it is grep-able and human-readable in the mean-time.
Users will have to install the os-core-update-index bundle to get this
functionality.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Write a tracking file for os-core-update-index so clients actually know
when they have it installed.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
The client.State struct is used to download and query manifests and
files from a specific swupd repository (and version). It does support
caching of data.
Besides the expected changes to make it is own package
- Only print "downloading" messages when Verbose is set in the struct
- Allow not passing an expected hash when verifying bundles
- Add a GetMoM function to the client.State
This is still an internal package since I think it needs more
iterations before becoming a public package. That said, the upcoming
swupd-inspector tool was implemented with almost no significant change
to the original code.
Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
List the repo title (which is not upper cased) instead of the key 'name'
in the section body. This is important because repo set-url and repo add
operates on the section title not the key name.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Download a file is a generic operation. This patch moves this
functionality from builder to helpers to allow it to be reused
by other packages.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
Instead of relying on external sources to keep track of the active
config file, store it as a private variable inside MixConfig.
This change prevents inconsistencies regarding filename and also
simplifies the code since the caller doesn't need to initialize the path
or know the filename if it was not the one that initialized that config
object.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
Throughout the code `b` is used as Builder object variable. This patch
renames its use in createDeltaPacks() to avoid confusion.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
This patch removes the hardcoded config inside mixin and uses config
package to generate the default builder.conf
It also renames the global variable `config` to `configFile` to avoid
conflic with the config package.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
This patch adds a couple new features for LoadDefaults().
First, it introduces LoadDefaultsForPath(), which allows the default
values to be set base on a given path instead of always assuming $PWD.
It also removes the restriction that only allowed defaults to be set
when --new-config set was declared. Removing this restriction ensures
that there are always sane parameters available, even if none exists
in the config file.
Lastly, it moves the check for local RPMs to LoadDefaults from
CreateDefaultConfig(). This prevents GetWd() to be called twice and also
allows LOCAL_REPO_DIR and LOCAL_RPM_DIR to be set in the same call.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
This patch moves config out of the builder package into its own package.
This change is required to reuse MixConfig inside swupd package. Builder
package includes Swupd package, so keeping config there would cause a
cyclic dependency.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
'config' is too generic of a name for a global variable and can cause
conflict with the 'config' package import.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
Updated mixin to use the internal b.AddBundles API rather than creating
the 'mixbundles' file directly in helpers.go.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
The BATS tests relied on the hack that creating an empty mixbundles list
before running 'mixer init' caused the default bundles to be skipped.
This patch uses the new '--no-default-bundles' flag to do this properly.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
Previously 'mixer init' would add four default bundles to your
mixbundles list, unless it already existed. This resulted in confusing
behavior. Some users resorted to creating an empty mixbundles list
before running 'mixer init' in order to avoid these bundles. Others had
a mixbundles list already, but expected the bundles to be added anyway.
This patch changes the behavior to *always* add the four default
bundles, even if the mixbundles list already exists, unless a new
'--no-default-bundles' flag is passed. This does not affect the behavior
of '--all-local' or '--all-upstream'.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
This release fixes the check for changed includes, and fixes 'mixin' to
support local content properly.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Instead of blindly subtracting 10 from the current version and expecting
that to be the old version... ACTUALLY USE LAST_VER!
Also correctly set the builder versions before the build.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Fixes#309
Add the local RPMs before checking if they exist via getPackageRepo. If
the .yum-mix.conf does not exist yet initialize this file so the local
repo is configured.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
When checking if the include list has changed between two versions of a
manifest, the code was using the return value of compareIncludes() to
indicate if a change was present or not. The problem is that this
function actually compares the two lists and returns true is they are
equal, which is the opposite of the desired check.
Regarding the check, when checking if the include list has changed or
not, we should only verify if the packages included are still the same,
not if their properties have changed. Using DeepEqual() will also check
for the properties of the object and will result in false positives when
checking for change.
This patch renames compareIncludes() to includesChanged() and changes
the returned value to match the expected result of this function. It
also changes the function implementation to only check the names of the
packages instead of all their properties.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
We already used it in two places, with more potential users. It is a
tar.Reader compatible type that supports autodetecting the compression
algorithm.
Since swupd does uses files that need such kind of autodetection (all
fullfiles use the same suffix), it can be considered a building block,
so justified to be in swupd package.
This release introduces a new mixer “config set” command to set properties
in the builder.conf, fixes for delta creation, mixin to read correct
upstream versions, and documentation for adding custom content from a build
root without building RPMs.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Some users are asking for instructions on how to build custom bundles
without having to go through the pain of packaging their content in an
RPM. Provide a tutorial explaining how this can be achieved.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
If the upstreamversion file exists read the current version from there.
Only read from /usr/lib/os-release if the upstreamversion file does not
exist. The os-release file is modified every time a local mix is
migrated to (version * 1000) so reading from that file every time causes
the mix version to multiply by 1000 every mix build.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
The name used in battests for config set were using the name used in the
code for the properties instead of the name found in the config file
causing the test to fail.
Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
Previously, when a "required" config value was missing, the config
object's variable name was reported, rather than the name actually used
in the builder.conf file itself.
This resulted in the following output, for example:
ERROR: Missing required field in config file: ServerStateDir
rather than
ERROR: Missing required field in config file: SERVER_STATE_DIR
This patch falls back to the variable name if a config field does not
have a "toml" name defined.
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>