← Back to team overview

touch-packages team mailing list archive

[Bug 1429285] Re: feature request: apt-get update --if-necessary

 

ähm, did you realize that "Expires" is the exact time of your request
(compare "Date") in your example? (See also the HTTP1.1 spec which will
tell you that 'Expires' doesn't really mean what you think it does, so
that the value it has is actually 'okay').

APT is using If-Modified-Since in its requests so (if a server supports
it… not all do, but at least most) a server can respond with just a "304
Not Modified", so at least there isn't much traffic wasted even if you
happen to request updates every few minutes (less effective for load
itself of course, apt is trying to be nice here as well by e.g. being a
proper keep-alive HTTP1.1 client, pipelining and not opening multiple
connections to the same server). A hypothetical average website loaded
by a average browser seems to be much worse from a load and traffic
point of view…

Regarding the snippets:
The puppet one just runs update if the sources.list changed. That isn't your usecase as I haven't changed my sources.list for months…
The ansible one, well, its a hack. A hack which in the worst case opts you out of security updates for 12 hours. That can be a long time, so I really don't want to define an arbitrary value for "not necessary" which is (a lot) larger than zero. And I am not very keen on suggesting by providing an option for it that there is a good value for it which I just don't want to figure out myself.

The problem is basically that you don't know at which point an update
makes sense. Your last update can be 10 seconds ago, but even if that is
close, it could still be outdated data as the repository was updated in
the meantime. What we would need is a 'soft' valid-until which specifies
the time after which the next update is/was deployed. Just that this is
pretty hard to predict (its easy to specify when the the update will
start on the master [expect for times you want to do an emergency
rollout], not so much the point it is finished and don't even try to
speculate about when this will reach your mirror…).

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to apt in Ubuntu.
https://bugs.launchpad.net/bugs/1429285

Title:
  feature request: apt-get update --if-necessary

Status in apt package in Ubuntu:
  New

Bug description:
  In many cases (juju, lxc containers .. ) we find ourselves in the
  position of not knowing if the apt-cache has been udpated recently.
  So, you either risk not doing it, or do it and it takes some time and
  generates load.

  so long story short, you always run 'apt-get update' which is quite often
  unnecessary.

  Would it be possible to add (or is there now) something like
  '--if-necessary' or '--if-necessary=5m'.  I could imagine that that would
  look at /var/lib/apt/lists and check timestamps on files for each url that
  /etc/apt/sources.list[.d/*] would hit.  If nothing was needed and
  reasonably recent, then it would not do the update.

  There exist other solutions to this like:
    https://coderwall.com/p/0xtstw/doing-an-apt-get-update-in-ansible-only-if-a-condition-is-met
    https://blog.kumina.nl/2010/11/puppet-tipstricks-running-apt-get-update-only-when-needed/

  
  It'd be nice if we had a sane way to say:
    update if you need to, otherwise don't waste time and resources

  ProblemType: Bug
  DistroRelease: Ubuntu 15.04
  Package: apt 1.0.9.3ubuntu1
  ProcVersionSignature: Ubuntu 3.19.0-7.7-generic 3.19.0
  Uname: Linux 3.19.0-7-generic x86_64
  ApportVersion: 2.16.2-0ubuntu1
  Architecture: amd64
  CurrentDesktop: Unity
  Date: Fri Mar  6 17:06:22 2015
  EcryptfsInUse: Yes
  InstallationDate: Installed on 2015-01-02 (63 days ago)
  InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Alpha amd64 (20150101)
  SourcePackage: apt
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1429285/+subscriptions


References