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

Version cache #10613

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kalimuthu-Velappan
Copy link
Contributor

Support for package version caching

During the SONiC build, it downloads and installs packages for
multiple build components which includes debian packages, pip modules,
python packages, source code packages, git modules and docker images.
The package versioning feature provides an infrastructure to select
and freeze a particular version of a package.

The package version caching feature provides an infrastructure to cache
the package with the given version into a local storage, so that
subsequent installation will not download from web instead it will load
from local cache path.

The following variable controls the verion caching feature. By default
it is truned off.
SONIC_VERSION_CACHE_METHOD = [none/cache]
SONIC_VERSION_CACHE_SOURCE = /path/to/local/storage

Why I did it

How I did it

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@lgtm-com
Copy link

lgtm-com bot commented Apr 19, 2022

This pull request introduces 1 alert when merging 0c0f35999358becd3d1b5c60d14c83c1d7455499 into 598ab99 - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@Kalimuthu-Velappan Kalimuthu-Velappan force-pushed the VERSION_CACHE branch 2 times, most recently from 4fc95ab to 0010001 Compare April 19, 2022 17:09
@lgtm-com
Copy link

lgtm-com bot commented Apr 19, 2022

This pull request introduces 1 alert when merging 0010001239d1846beaf4e01cb25061e388ddb073 into 8b5d908 - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@lgtm-com
Copy link

lgtm-com bot commented Apr 28, 2022

This pull request introduces 1 alert when merging 5063102635fd8fe81df671c75c05005856233be0 into 1d84e0d - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@lgtm-com
Copy link

lgtm-com bot commented May 5, 2022

This pull request introduces 1 alert when merging 8a98c4ee09ad925aad87ccdb4fddb0200edc7bcd into 7c4ee43 - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@Kalimuthu-Velappan Kalimuthu-Velappan force-pushed the VERSION_CACHE branch 2 times, most recently from 604ee1f to af492ce Compare May 6, 2022 05:13
@lgtm-com
Copy link

lgtm-com bot commented May 6, 2022

This pull request introduces 1 alert when merging af492ce46684e7a0c0c802b5b4fe5b424aa104a8 into 9ae17e6 - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@Kalimuthu-Velappan
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Makefile.work Outdated
{ echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \
$(DOCKER_BASE_BUILD) ; \
scripts/collect_docker_version_files.sh $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) target ; }
@$(DOCKER_BUILD)
Copy link
Contributor

Choose a reason for hiding this comment

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

sonic-slave-base-build is different from sonic-slave-build.
Why put them together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it

Makefile.work Outdated
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \
$(DOCKER_BUILD) ; }
@$(DOCKER_BUILD)
Copy link
Contributor

Choose a reason for hiding this comment

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

Because of Calling DOCKER_BUILD twice, you get this PR checker error:

  • docker tag sonic-slave-bullseye:00952e8de3f 00952e8de3f sonicdev-microsoft.azurecr.io/sonic-slave-bullseye:latest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your guidance. Fixed it

set -x
if [[ "${FORCE_UPDATE}" == Y ]]; then
UPDATE=y
elif $(set -- /var/lib/apt/lists/*_debian_dists_${DISTRO}_InRelease; test -e "$1"); then
Copy link
Contributor

Choose a reason for hiding this comment

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

"$1" is "update"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, $1 is an update arg which is coming from 'apt-get update'. During apt-get update, it will cache the debian package release files. so that subsequent build will be loaded from cache.

SONIC_OVERRIDE_BUILD_VARS += SONIC_VERSION_CACHE_SOURCE=$(SONIC_VERSION_CACHE_SOURCE)
export SONIC_VERSION_CACHE SONIC_VERSION_CACHE_SOURCE
$(shell test -d $(SONIC_VERSION_CACHE_SOURCE) || \
mkdir -p $(SONIC_VERSION_CACHE_SOURCE) && chmod -f 777 $(SONIC_VERSION_CACHE_SOURCE) 2>/dev/null )
Copy link
Contributor

Choose a reason for hiding this comment

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

I find error log in the PR validation.
mkdir: cannot create directory '/vcache/sonic-slave-bullseye': Permission denied

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a merge issue. Fixed it.

@liushilongbuaa
Copy link
Contributor

[ FAIL LOG END ] [ target/python-wheels/buster/scapy-2.4.5-py2.py3-none-any.whl ]
make: *** [slave.mk:754: target/python-wheels/buster/scapy-2.4.5-py2.py3-none-any.whl] Error 1
make: *** Waiting for unfinished jobs....
PR validation failed. But it shows success. There must be something wrong.

Makefile.cache Outdated
@@ -71,6 +71,8 @@ SONIC_COMMON_FLAGS_LIST := $(CONFIGURED_PLATFORM) \
$(CONFIGURED_ARCH) \
$(BLDENV) \
$(SONIC_DEBUGGING_ON) \
$(SONIC_VERSION_CONTROL_COMPONENTS) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Makefile.cache runs before pip/apt-get. If source code and dependencies not changed, it will copy package from local path. This feature shouldn't change Makefile.cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it.

Makefile.work Outdated
@@ -294,26 +314,61 @@ endif

endif

DOCKER_BASE_BUILD = docker build --no-cache \
DOCKER_AUTH:=docker login -u sonicbrcm -p 4b5d1f28-6f43-41da-a794-88805ee8fc2d
Copy link
Contributor

@liushilongbuaa liushilongbuaa May 7, 2022

Choose a reason for hiding this comment

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

It's not safe to push to github.
And why we should login to dockerhub using special account?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added for the local build, accidentally it got merged into PR code. Just removed it.

@Kalimuthu-Velappan Kalimuthu-Velappan force-pushed the VERSION_CACHE branch 4 times, most recently from 89d4361 to e194e41 Compare May 9, 2022 04:03
@lgtm-com
Copy link

lgtm-com bot commented May 9, 2022

This pull request introduces 1 alert when merging e194e412f0d30751f756e6068fde0872fb6bca38 into 71a515e - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@Kalimuthu-Velappan
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Kalimuthu-Velappan
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Kalimuthu-Velappan
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Kalimuthu-Velappan
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lgtm-com
Copy link

lgtm-com bot commented May 23, 2022

This pull request introduces 1 alert when merging 900eb928251f4bf633b9d87bc4c3c6d26d616810 into b313563 - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@Kalimuthu-Velappan Kalimuthu-Velappan requested a review from a team as a code owner June 10, 2022 02:01
@zhangyanzhao
Copy link
Collaborator

build failure blocks the merge.

During the SONiC build, it downloads and installs packages for
multiple build components which includes debian packages, pip modules,
python packages, source code packages, git modules and docker images.
The package versioning feature provides an infrastructure to select
and freeze a particular version of a package.

The package version caching feature provides an infrastructure to cache
the package with the given version into a local storage, so that
subsequent installation will not download from web instead it will load
from local cache path.

The following variable controls the verion caching feature. By default
it is truned off.
	SONIC_VERSION_CACHE_METHOD = [none/cache]
    SONIC_VERSION_CACHE_SOURCE = /path/to/local/storage
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 3, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Kalimuthu-Velappan (f2da2aa)

@lgtm-com
Copy link

lgtm-com bot commented Aug 3, 2022

This pull request introduces 1 alert when merging f2da2aa into 45ded68 - view on LGTM.com

new alerts:

  • 1 for Modification of parameter with default

@liushilongbuaa
Copy link
Contributor

It is better to split this big PR into several little PRs.

  1. Setup version cache inside slave docker.
    • version cache for git
    • version cache for apt/apt-get
    • version cache for pip/pip3
    • ...
  2. Setup version cache when building slave docker.
  3. Setup version cache when building SONiC image.

@Kalimuthu-Velappan
Copy link
Contributor Author

I agree that it would be better to handle the PR for each functionality. But it is very difficult to split them into multiple PRs as it's all interdependent with each other on the caching framework. It would be easy for tracking and testing the complete framework if it is a single PR.

Do you really want to split them into multiple?

@Kalimuthu-Velappan
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liushilongbuaa
Copy link
Contributor

I agree that it would be better to handle the PR for each functionality. But it is very difficult to split them into multiple PRs as it's all interdependent with each other on the caching framework. It would be easy for tracking and testing the complete framework if it is a single PR.

Do you really want to split them into multiple?

I suggest keeping original branch and split them.
Change will be clear:
1. Change Makefile.work and slave.mk to pass config variable
2. Mount cache dir.
3. Change hooks logic:
i. if not exist; then pip download; fi; pip install locally
ii. if not exist; then apt-get download; fi; apt-get install locally

@liushilongbuaa
Copy link
Contributor

@xumia , please help review.

@Kalimuthu-Velappan
Copy link
Contributor Author

As requested, I will try to split into multiple PRs and raise a separate list of PRs.

@zhangyanzhao
Copy link
Collaborator

Is the PR splitted? Can you please update the HLD PR with the new code PRs listed? @Kalimuthu-Velappan

@Kalimuthu-Velappan
Copy link
Contributor Author

Kalimuthu-Velappan commented Dec 8, 2022 via email

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.

4 participants