#484 Use lookaside cache for large sources too
Closed: Fixed 4 years ago by onosek. Opened 4 years ago by msuchy.

I stumbled upon SPEC file which has:

Name: kubelet
...
Source0: https://dl.k8s.io/v%{version}/bin/linux/%{ARCH}/kubelet
Source1: https://raw.githubusercontent.com/kubernetes/release/master/rpm/kubelet.service
Source2: https://dl.k8s.io/v%{version}/bin/linux/%{ARCH}/kubectl
Source3: https://dl.k8s.io/v%{version}/bin/linux/%{ARCH}/kubeadm
Source4: https://raw.githubusercontent.com/kubernetes/release/master/rpm/10-kubeadm-pre-1.8.conf
Source5: http://git.io/weave

None of these files is stored in lookaside cache. The problem is that the kubelet,kubectl... files are 60 MB big. Each of them. And if you have several branches, they are stored in git index. And the .git directory - in this case - grew to 1+GB.

Right now, rpkg decide what to upload just using extension

    UPLOADEXTS = ['tar', 'gz', 'bz2', 'lzma', 'xz', 'Z', 'zip', 'tff',
                  'bin', 'tbz', 'tbz2', 'tgz', 'tlz', 'txz', 'pdf', 'rpm',
                  'jar', 'war', 'db', 'cpio', 'jisp', 'egg', 'gem', 'spkg',
                  'oxt', 'xpi']

It would be nice if rpkg can upload to lookaside cache everything which is binary and/or big in size. Let say that one MB is nice threshold.


Hmm, I like python3-magic. You can:

>>> import magic
>>> magic.detect_from_filename('/usr/bin/bash')
FileMagic(mime_type='application/x-pie-executable', encoding='binary', name='ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8286f22591b0be26730eea306a22a0f30475590b, for GNU/Linux 3.2.0, stripped')
>>> magic.detect_from_filename('pyrpkg/__init__.py')
FileMagic(mime_type='text/x-python', encoding='us-ascii', name='Python script, ASCII text executable')

And we can upload everything which is not in whitelisted mimetype. E.g., "text/*", application/xml, application/json, application/geo+json ...
Or we can decide based on the encoding.

I can not do it as suggested. There is python3-magic library missing at epel7 and el6 distros and I still have to be backward compatible with these old versions. There is certain python-magic, but it looks it does something completely different I am afraid.
I will explore if using command "file --mime <file_path>" could work instead.

Metadata Update from @onosek:
- Issue set to the milestone: 1.60

4 years ago

Login to comment on this ticket.

Metadata
Related Pull Requests
  • #491 Merged 4 years ago
  • #490 Merged 4 years ago
  • #487 Merged 4 years ago
  • #481 Merged 4 years ago