Gerrit Interview Questions & Answers

4 avg. rating (80% score) - 5879 votes

Gerrit Interview Questions and Answers

Gerrit Interview Questions

    1. Question 1. What Is The Added Value Of Software Factory ?

      Answer :

      If you are not sure about using Software Factory, here are some perks that might convince you:

      1. Software Factory is a Continuous Integration system that works out of the box, with everything ready to be used right after the first configuration run. Deploying all the services by hand and with this level of interdependency would take a lot more time.
      2. Software Factory helps enforcing the latest best practices in Continuous Integration.
      3. In Software Factory, the configuration is treated as code that can therefore be versioned, reviewed, tested or rolled back for any change.
      4. Users are automatically and consistently authenticated on each service with Single Sign-On. Again, achieving this by hand would be very time consuming.
      5. Software Factory can be fully backed up, restored, and upgraded automatically through tested processes.
      6. Software Factory can be deployed anywhere: baremetal systems, LXC, KVM or on OpenStack via Heat.
      7. Software Factory is fast to deploy (3/5 minutes on a local system, 15 minutes with Heat).
      8. Software Factory runs worker nodes on demand on an OpenStack cloud, which can reduce effective costs of testing.

    2. Question 2. Can I Disable Gerrit ?

      Answer :

      As of now, Gerrit is mandatory in Software Factory for a couple of reasons:

      1. Managesf access control policies are based on Gerrit groups.
      2. The config repository is hosted on Gerrit with an integrated CI/CD workflow.

      Gerrit will be made optional in a future release [1] of Software Factory
      Note: that it is possible to use Software Factory as a third party CI for an external Gerrit or a GitHub organization. In this case, the gerrit server is only used to host the config repository, and operators can bypass it entirely by pushing config repository changes with the “git push” command instead of “git review”.

    3. Question 3. Why Can’t I +2 A Change After Being Added To The Core Group ?

      Answer :

      This may happen because of web browser cache issues. Remove all cookies then log out and log in again to refresh your gerrit privileges.

    4. Question 4. Why Does My Build Fail With The “not_registered” Error ?

      Answer :

      This error happens when zuul can’t build a job. Most of the time it’s because:

      1. A project gate is configured with an unknown job. The job’s definition is likely missing in zuul’s layout.
      2. No worker node was ever available. Zuul will fail throwing a NOT_REGISTERED error (instead of queuing) until a worker node with the correct label is available. Only then, once Zuul knows a label really exists, will it properly queue builds.
      3. The first step to investigate that error is to verify that the job is present in the jobs dashboard. If the job is not there, check the config repository and check that the job is either expanded from a job template (using the project’s name), or that is fully defined. Otherwise add the job and update the config repository.

    5. Question 5. Why Does My Build Stay In “queued” State ?

      Answer :

      This happens when no worker nodes are available to execute a build:

      1. First verify that at least one worker node with the right label exists. You can list nodes with the sfmanager CLI.
      2. Then verify that your job definition actually uses the right worker node label.

    6. Question 6. How Can I Change My Deployment’s Hostname?

      Answer :

      You can change the hostname after the deployment by changing the fqdn parameter in /etc/software-factory/sfconfig.yaml, removing the existing SSL certificates (only required if running functional tests and using the default self-signed certificates) and running sfconfig again:

      sed -i -e 's/fqdn:.*/fqdn: mynewhostname.com/g' /etc/software-factory/sfconfig.yaml
      sfconfig

      note: that you might need to update URLs in other places as well, for example git remote urls in .gitreview and .git/config files for repositories hosted on Software Factory.

    7. Question 7. How To Setup A Mirror On Swift For External Dependencies ?

      Answer :

      The mirror service uses the mirror2swift utility to provide a local cache for external ressources. For example we use it to mirror RPM repositories, which speeds up building times of our test environments.
      To enable the mirror service, you need to configure a swift container in sfconfig.yaml and then specify the URL to mirror in the config-repo:
          Add the mirror role to /etc/software-factory/arch.yaml
          Configure the mirror role in /etc/software-factory/sfconfig.yaml
          Run sfconfig
          Edit the mirror configuration template provided in the mirrors directory of the config repository.
      When periodic_update is set, the mirror will be updated periodically through a dedicated zuul pipeline. The status of the update can be checked like any other CI build. Otherwise, to update the cache manually, this command needs to be executed:
      sudo -u mirror2swift mirror2swift /var/lib/mirror2swift/config.yaml
      sfconfig.yaml example:
      mirrors:
        periodic_update: '0 0 * * *'
        swift_mirror_url: http://swift:8080/v1/AUTH_uuid/repomirror/
        swift_mirror_tempurl_key: TEMP_URL_KEY

      The swift_mirror_url needs to be the canonical, fully qualified url of the target container. The swift_mirror_tempurl_key needs to be a tempurl key with writing rights. The periodic_update needs to be a valid zuul timer format, e.g. daily is ‘0 0 * * *’.

      The yaml files in the config repository represent the list of mirrors as documented here:

      https://github.com/cschwede/mirror2swift. For example, config/mirrors/centos.yaml:
      - name: os
        type: repodata
        url: 'http://centos.mirror.example.com/7/os/x86_64/'
        prefix: 'os/'

    8. Question 8. How To Restart A Config-update Job ?

      Answer :

      When the config-update job fails, you can manually restart the job using the command bellow. Make sure to set the ref-sha which is the last commit hash of the config repository.
      zuul enqueue-ref --trigger gerrit --tenant local --pipeline post --project config --ref master --newrev ref-sha
      The job will be running in the post pipeline of the Zuul status page.

    9. Question 9. How Can I Use The Gerrit Rest Api?

      Answer :

      The Gerrit REST API is open for queries by default on all Software Factory deployments.

      There is an extensive documentation available online:
      https://gerrit-review.googlesource.com/Documentation/rest-api.html
      The Gerrit API is available at the https://fqdn/r/ endpoint for non authenticated requests and for authenticated requests it is https://fqdn/r/a/.
      To use the authenticated endpoint you have to create an API password first. To do so, go to the User Settings page (upper right corner on the top menu) and click on the button Generate new API key.

      For example:

      getting open changed with cURL would be:
      curl "http://fqdn/r/changes/?q=status:open"
      And to access a restricted resources with cURL would be:
      curl -u username:apikey https://fqdn/r/a/accounts/self/password.http

    10. Question 10. How Can I Use Gertty?

      Answer :

      After getting a Gerrit API key (as explained in), use the basic auth-type in gertty.yaml,

      Example:
      servers:
        - name: sftests
          url: https://sftests.com/r/a/
          git-url: ssh://USER_NAME@sftests.com:29418
          auth-type: basic
          username: USER_NAME
          password: API_KEY
          git-root: ~/git/

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Gerrit Tutorial