06.Version Cache - Support for wget#14612
Conversation
670c1e4 to
a72913f
Compare
|
@xumia can you please help to review? Thanks. |
|
Could you please clarify how to test a build with version cache correctly?
For DPKG_CACHE it's obvious:
But what options should I choose to enable vcache? |
|
BTW we already have PR with number 06 for vcache: #13024 |
|
In order to use version vache(VCACHE), SONIC_VERSION_CACHE_METHOD=cache variable should be used. Here are the recommended settings: For the subsequent build to use the VCACHE, both the version variable needs to be set. DPKG cache can be independent of the version cache and it will superset of VCACHE. |
There was a problem hiding this comment.
Does it work with sonic-slave docker containers?
I mean when we build sonic-slave container we download some files (e.g. golang binaries) using wget.
According to logs it saved something.
#20 88.54 Saving into web cache URL:https://sonicstorage.blob.core.windows.net/public/fips/bullseye/0.1/amd64/golang-1.15-go_1.15.15-1~deb11u4%2Bfips_amd64.deb, DST:/sonic/target/vcache/sonic-slave-bullseye/web/golang-1.15-go_1.15.15-1~deb11u4%2Bfips_amd64.deb-b60f6db62805696b47ab422ab798fe56.tgz, SRC:golang-go.deb
#20 117.0 Saving into web cache URL:https://sonicstorage.blob.core.windows.net/public/fips/bullseye/0.1/amd64/golang-1.15-src_1.15.15-1~deb11u4%2Bfips_amd64.deb, DST:/sonic/target/vcache/sonic-slave-bullseye/web/golang-1.15-src_1.15.15-1~deb11u4%2Bfips_amd64.deb-1c920937aa49b602a1bfec3c49747131.tgz, SRC:golang-src.deb
#61 2.627 Saving into web cache URL:https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64, DST:/sonic/target/vcache/sonic-slave-bullseye/web/bazelisk-linux-amd64-d9f6a4c3197625b1835b523697eb953e.tgz, SRC:/usr/local/bin/bazel
But there are no files in vcache directory.
➜ vcache tree
.
├── sonic-slave-bullseye
└── sonic-slave-buster
2 directories, 0 files
There was a problem hiding this comment.
Yes, it works for slave containers as well
Vcache is disabled for now, it will get enabled once everything is done.
There was a problem hiding this comment.
I tried to build your branch VERSION_CACHE_WGET with SONIC_VERSION_CACHE_METHOD=cache enabled.
But I didn't find files like golang binaries from sonic-slaves in vcache directory (SONIC_VERSION_CACHE_SOURCE) after build finished.
Is it expected behaviour?
I can retest this. I'll provide build logs if this bug is duplicated.
There was a problem hiding this comment.
Seems like these files are extracted as part of cache.tgz.
So we can ignore this issue for now and retest it lately when all parts of vcache are merged.
There was a problem hiding this comment.
Why do you call get_url_version two times: line 215 and 218?
There was a problem hiding this comment.
Maybe need to add double quote around SRC_FILENAME and DST_FILENAME variables.
Filenames unlike urls can contain whitespaces.
So need to check if vcache works correctly in this case:
wget $url -o "my file"
There was a problem hiding this comment.
You can find in SONiC Makefiles something like this:
sonic-buildimage/src/lldpd/Makefile
Line 23 in a09048a
Probably this code won't be able to parse
-NO correctly.
There was a problem hiding this comment.
BTW -NO is not correct combination. I got warning WARNING: timestamping does nothing in combination with -O. See the manual for details. I don't know why this is used in Makefiles.
be60409 to
99e9fee
Compare
There was a problem hiding this comment.
Still need to fix this regex.
My test build failed with this error:
#20 30.32 dpkg: error: cannot access archive 'golang-go.deb': No such file or directory
And I decided to test the regex using simple bash script:
#!/bin/bash
[[ "$1" =~ -[^-]*o || "$1" =~ -[^-]*O.* ]] && echo true || echo false
As a result many false positive:
./1.sh -o
true
./1.sh golang.deb
false
./1.sh golang-go.deb
true
./1.sh www.test-url.com
true
99e9fee to
5499c4e
Compare
|
One question about implementation. What I mean: cache/vcache/sonic-slave-buster/web: cache/vcache/sonic-slave-bullseye/web: Probably we can save some space if we use a single directory |
There was a problem hiding this comment.
We append "$url==$real_version" to the file ${BUILD_WEB_VERSION_FILE} on the line 227 if $real_version is valid (not md5sum of empty string).
So I don't understand what we exactly do here (lines 233-236). Why do we need to save this info again.
Moreover if ${BUILD_WEB_VERSION_FILE} contains duplicated lines for ${url}==${real_version} then ${build_version} will contain multiple hashes and condition on the line 234 will failed: line 234: [: c1c557036197188a22ec285fa53149d8: binary operator expected.
Example:
1. wget www.url.com/file.tar.gz -O file
(line 227: append url==real-version to the web_version_file)
2. wget www.url.com/file.tar.gz -O file2
(line 227: append url==real-version to the web_version_file)
3. get error on line 233-234 due to duplicated strings in web_version_file
There was a problem hiding this comment.
Basically, we add the ${url}==${real_version} combination into the file ${BUILD_WEB_VERSION_FILE} if the entry does not exist already and also remove any duplicate entry in the file ${BUILD_WEB_VERSION_FILE}.
line 234: [: => error is due to different shell version, I have fixed it.
There was a problem hiding this comment.
I can clarify this.
Line 227:
[[ $real_version == "d41d8cd98f00b204e9800998ecf8427e" ]] || echo "$url==$real_version" >> ${BUILD_WEB_VERSION_FILE}
We add this entry (url==real_version) into the file unconditionally. The only condition here is comparison with a hash of empty string. If real_version is equal to the hash of empty string then probably there no reason to add this entry into the file.
You say if the entry does not exist already . But I don't understand how it's possible if the entry has a valid real_version and doesn't exist in file if we just added it at line 227. Probably we can remove all this fragment of code where you extract build_version and keep only line 236 where you remove possible duplicate entries from file.
That's my opinion. Maybe I missed something.
There was a problem hiding this comment.
Probably it's last question that should be resolved before merge this PR.
There was a problem hiding this comment.
Thanks for the clarification. I realized the empty HASH part and thanks for pointing it out.
It will add the entry only when it is not empty or valid but not exists in the version file.
Let me know if this is OK.
There was a problem hiding this comment.
Also possible:
wget www.url.com/file.tar.gz -P directorywget www.url.com/file.tar.gz -O directory/filename.tar.gz- (only for curl)
curl www.url.com/file.tar.gz > filename.tar.gz wget www.url.com/file.tar.gz -O "file name.tar.gz"- not sure, but probably need to recheck this too.curl -O www.url.com/file.tar.gzcurl -O www.url.com/file.tar.gz --output-dir test
I'm not sure should we try to fix this or not. I didn't find such a code in current SONiC codebase.
Maybe @xumia can help here and say should we fix or ignore this.
There was a problem hiding this comment.
There was a problem hiding this comment.
As we ran out of time for the current release, we can take this up on the subsequent release.
Please approve the PR if there are no further changes.
There was a problem hiding this comment.
Yes, we can ignore this for now and retest again when all parts of vcache are merged.
There was a problem hiding this comment.
Agree to ignore for now. It may be a little hard to cover all the scenarios, covering the current used scenarios should be good enough.
Yes, we need to keep the separate cache contents for each slave container build, because the docker builder doesn't use shared volume mount during the build, like So we need to export these contents inside the docker builder as a context file. So this needs to be packed as a separate tgz file. |
c6062bf to
f1a7e59
Compare
There was a problem hiding this comment.
Now we have incorrect logic:
- download new file from some url
- try to extract
build_versionfrom ${BUILD_WEB_VERSION_FILE} build_versionis empty because it was 1st download from this url- condition
[ ! -z "${build_version}" ];failed becausebuild_versionis empty, but you check if this is not empty using! -z(it means not has no value). - you never add new entry to this file
Maybe just replace this code with
echo "$url==$real_version" >> ${BUILD_WEB_VERSION_FILE}
sort ${BUILD_WEB_VERSION_FILE} -o ${BUILD_WEB_VERSION_FILE} -u
There was a problem hiding this comment.
My bad, I forgot to remove ! in the if condition. Thanks for catching this.
I modified the code as you suggested.
When a package is referenced from the web through wget command, it downloads the package for every build. This feature caches all the packages that are being downloaded from the web, so that subsequent build always loads the cache instead of from web.
f1a7e59 to
3a0bc39
Compare
When a package is referenced from the web through wget command, it downloads the package for every build. This feature caches all the packages that are being downloaded from the web, so that subsequent build always loads the cache instead of from web.
When a package is referenced from the web through wget command, it downloads the package for every build.
This feature caches all the packages that are being downloaded from the web, so that subsequent build always loads the cache instead of from web.
Why I did it
How I did it
How to verify it
Which release branch to backport (provide reason below if selected)
Description for the changelog
Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)