Skip to content

Re-indexing a package

If the indexing of a package in PackageCloud fails, you will need to manually trigger the reindexing of the package in question.

Failed indexing will show stack traces in Elasticsearch and you will see the Indexing yellow label in the UI. Indexing can sometimes take a while so seeing the label in the UI doesn’t necessarily mean a package has failed indexing. Best to confirm that there are indexing errors in the logs before you go through this process.

  1. Connect to the ops-gitlab-gke k8s cluster and switch context to it

  2. Open a shell on the toolbox pod:

    Terminal window
    kubectl -n packagecloud exec -it deployments/packagecloud-toolbox -c packagecloud -- bash
  3. Open the rails console:

    Terminal window
    packagecloud-ctl console
  4. Once the rails console has loaded, copy in this helper function to help re-indexing:

    def package_reindex(username, repo, path)
    package_info = path.split('/')
    distro_version = Distribution.find_by_index_name!(package_info[0]).distro_versions.find_by(index_name: package_info[1])
    user = User.find_by(name: username)
    repository = Repository.find_by(name: repo, user_id: user.id)
    repository.find_package_by_dist_filename(
    distro_version_id: distro_version.id,
    package: package_info[2]
    ).reindex
    end
  5. You can now call the function to re-index your packages:

    package_reindex('<username>', '<repository>', '<file>')
    • First parameter is the username that the repository belongs to — e.g., gitlab
    • Second parameter is the repository name — e.g., gitlab-ce, gitlab-ee, unstable, nightly
    • Third parameter is the <distro name>/<distro version>/<file> to reindex — e.g., el/7/gitlab-ce-11.4.12-ce.0.el7.x86_64.rpm

    For example:

    package_reindex('gitlab', 'gitlab-ce', 'el/7/gitlab-ce-11.4.12-ce.0.el7.x86_64.rpm')

    You should see something like the following:

    irb(main):035:0> package_reindex('gitlab', 'gitlab-ce', 'el/7/gitlab-ce-11.4.12-ce.0.el7.x86_64.rpm')
    Reindex: 7 30
    Enqueuing Deb::IndexJob for 7 gitlab/gitlab-ce 30 7
    added {"class":"Deb::IndexJob","args":[7,30]} to queue:indexer
    => true