-
Notifications
You must be signed in to change notification settings - Fork 549
[Edu Version] Add offline apt package cache in kube runtime #4222
Conversation
if not(os.path.exists(name_target_folder)): # avoid duplicate copy | ||
shutil.copytree(name_source_folder, name_target_folder) | ||
return '/bin/bash {}/runtime.d/install_group.sh '.format(PAI_WORK_DIR) + group_name | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would the below behavior would be better
def try_to_install_by_cache(group_name: string, failed_cmds: list):
# no change, copy caches
cached_cmd = '/bin/bash {}/runtime.d/install_group.sh '.format(PAI_WORK_DIR) + group_name
return '%s || {%s}' % (cached_cmd, ';'.join(failed_cmds))
and the example usage is
cmds = [
...
try_to_install_by_cache('ssh', ['apt-get update', 'apt-get install -y openssh-client openssh-server']),
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix this in a different PR
Would you please add this conversion to a README in somewhere?
|
Close this to use #4226 instead. |
To resolve: #4211
How to use:
1. Add packages you want to store cache for in the file
package_cache_info
:The first column is
group_name
. One group can contain multiple packages. The second column stands for the OS type. Currently onlyubuntu16.04
andubuntu18.04
are supported. The third column is the packages you want to add for the group. The last column is the precommands, which will be executed before gathering packages and it can be left empty.2. In
init.py
of each plugin:try_to_install_by_cache('<group_name>')
will generate a script to install all packages of a certain group name. It guarantees:apt-get
,yum
or other cmdlines to install the packages.Here is an example for the
ssh
plugin:3. Add an environmental variable
ENABLE_PACKAGE_CACHE=true
when you build the kube-runtime image:By default package cache is disabled to save build time.
Optimization (TBD)