Method: Bosh::Director::Jobs::UpdateRelease#process_packages
- Defined in:
- lib/bosh/director/jobs/update_release.rb
#process_packages ⇒ void
This method returns an undefined value.
Finds all package definitions in the manifest and sorts them into two buckets: new and existing packages, then creates new packages and points current release version to the existing packages.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/bosh/director/jobs/update_release.rb', line 205 def process_packages logger.info("Checking for new packages in release") new_packages = [] existing_packages = [] @manifest["packages"].each do || filter = {:sha1 => ["sha1"]} if ["fingerprint"] filter[:fingerprint] = ["fingerprint"] filter = filter.sql_or end # Checking whether we might have the same bits somewhere packages = Models::Package.where(filter).all if packages.empty? new_packages << next end # Rebase is an interesting use case: we don't really care about # preserving the original package/job versions, so if we have a # checksum/fingerprint match, we can just substitute the original # package/job version with an existing one. if @rebase substitutes = packages.select do |package| package.release_id == @release_model.id && package.name == ["name"] && package.dependency_set == Set.new(["dependencies"]) end substitute = pick_best(substitutes, ["version"]) if substitute ["version"] = substitute.version ["sha1"] = substitute.sha1 existing_packages << [substitute, ] next end end # We can reuse an existing package as long as it # belongs to the same release and has the same name and version. existing_package = packages.find do |package| package.release_id == @release_model.id && package.name == ["name"] && package.version == ["version"] # NOT checking dependencies here b/c dependency change would # bump the package version anyway. end if existing_package existing_packages << [existing_package, ] else # We found a package with the same checksum but different # (release, name, version) tuple, so we need to make a copy # of the package blob and create a new db entry for it package = packages.first ["blobstore_id"] = package.blobstore_id new_packages << end end create_packages(new_packages) use_existing_packages(existing_packages) end |