Jump to: navigation, search

Difference between revisions of "Chef/Contributing"

(Gate jobs)
(Gate jobs)
Line 222: Line 222:
 
See the TESTING.md file in each cookbook for more details on testing cookbook patches.
 
See the TESTING.md file in each cookbook for more details on testing cookbook patches.
 
   
 
   
back to GettingStarted page: https://wiki.openstack.org/wiki/Chef/GettingStarted
+
back to [https://wiki.openstack.org/wiki/Chef/GettingStarted GettingStarted page]

Revision as of 15:53, 5 May 2015

Contributing to the OpenStack Chef Cookbooks

See this blog entry for an introduction to contributing and pushing code to for the OpenStack Chef cookbooks housed on Stackforge. And look here for more details: http://docs.openstack.org/infra/manual/developers.html

How to create a new cookbook: https://wiki.openstack.org/wiki/Chef/Contributing/NewCookbook

Guidelines for Commit Messages

Please try to make commit messages useful. Read this excellent blog post, as well as the standard commit message guidelines for OpenStack projects before making your first code push.

Guidelines for Blueprints

If you ever want to change something that can or should not be changed in just one commit or affects multiple cookbooks, please go ahead and register a blueprint for 'OpenStack + Chef'. After you read this wiki page on Blueprints you can basically go ahead and follow these steps for all openstack-cookbooks.

  1. Write down the basic idea in some words.
  2. Elaborate in some sentences on how you think your idea can be integrated in the cookbooks and why it is important.
  3. Create a list of 'Work Items', including all the cookbooks your idea should be applied to and the order you think would be best.
  4. Maybe check back with the people in the irc channel #openstack-chef to refine the things mentioned above.


If you think your idea concerns all the cookbooks, please go ahead and copy this complete list of openstack-cookbooks to avoid missing one during the process:


cookbook-openstack-block-storage: TODO

cookbook-openstack-common: TODO

cookbook-openstack-compute: TODO

cookbook-openstack-dashboard: TODO

cookbook-openstack-database: TODO

cookbook-openstack-data-processing: TODO

cookbook-openstack-identity: TODO

cookbook-openstack-image: TODO

cookbook-openstack-network: TODO

cookbook-openstack-object-storage: TODO

cookbook-openstack-ops-database: TODO

cookbook-openstack-ops-messaging: TODO

cookbook-openstack-orchestration: TODO

cookbook-openstack-telemetry: TODO

cookbook-openstack-integration-test: TODO

openstack-chef-repo: TODO

Guidelines for Code Reviewers

Here are some simple rules for reviewers of code on the Gerrit Review site:

Rule #1: Never +1/+2R or +1A your own patch.

Rule #2: All patches must have a commit message that meets the standard commit message guidelines for OpenStack projects. Failure of the commit message to meet these guidelines should prevent a +1A by a core reviewer.

Rule #3: If the patch is more than just stylistic or typo fixes, it requires at least 2 core reviewers to add a +2R to the review before any core reviewer can +1A the review.

Rule #4: If the patch changes existing behavior of any cookbook in a backwards-incompatible way, a corresponding bump in the version in the cookbook's metadata.rb must be included in patch set. Failure to do so should prevent a +1A by a core reviewer.

Rule #5: If the patch adds additional functionality to a library cookbook, a corresponding bump in version number in the metadata.rb file should accompany the patch. Failure to do so should prevent a +1A by a core review.

Guidelines for Version Changes

When submitting cookbook patches, it is generally required that the version number (within metadata.rb) is incremented in a manor reflective of the level of the change. Any patch should also update the CHANGELOG.md and if appropriate the README.md should reflect the changes and any relevant how-to instructions. The CHANGELOG.md is our executive summary of changes, it should inform what the change was in a quick manner.

There are some differences between the development of patches on the Master and Stable branches. There is more restrictive and vigorous oversight given to changes on the Stable branches. The Master branch is bleeding edge and can relax the version requirement in some simple cases to allow for increased productivity.

Semantic Versioning

The cookbooks use the Semantic Versioning system (see http://semver.org) The system uses a three part version number, Major.Minor.Patch. For example: 9.2.33 The Major number shouldn't change within a development branch. It will reflect the number that is the Alphabetized Letter of the base Openstack release, see: https://wiki.openstack.org/wiki/Releases. An example would be Icehouse being the 9th letter and the 9th release all the stable cookbooks would be 9.Y.Z. When the Master branch becomes stabilized, a new Stable branch will be created from it and the Major number in the Master will be incremented by the core team.

The Minor and Patch numbers will be incremented as described in the branch specific sections below.

Stable Branch

Creating a stable branch for Openstack+Chef here are the notes.

See https://wiki.openstack.org/wiki/StableBranch#Gerrit for information about Cherry picking patches to stable branches. In most cases the Changelog and metadata.rb will also need to be updated with patch level increment. Then after the patch is merged, please consider updating the https://github.com/stackforge/openstack-chef-repo to pull in your change. The Changelog, Berksfile and lock will need to be updated.

The Stable branch cookbooks must leverage the Semantic Versioning system exclusively. All patches must update the metadata.rb and the CHANGELOG.md at a minimum. All patches should try to be backwards compatible.

Stable Branch Example Situations Level of Change
add a recipe Increment Minor
add a function or method Increment Minor
change Gemfile or Berksfile Increment Minor
backport a fix from Master branch Increment Minor
add attribute for a value in a configuration file with the same default Increment Patch
changing a resource option Increment Patch
add a test Increment Patch
fix a broken recipe Increment Patch
re-factoring recipe or test Increment Patch

The table above shows some examples of different levels of changes introduced by a patch and what part of the version number to increment for Stable branches.

Version Locking

The Stable branches are also locked down by added Berksfile.lock and Gemfile.lock to each cookbook. If any changes are made to the Gemfile, the Gemfile.lock would also have to be updated. If any changes are dependent upon other cookbook changes, then the Berkfile.lock and metadata.rb files would need to be updated accordingly.

Cookbook Dependencies

When a change requires hits to multiple cookbooks, like when adding attributes to Common, the metadata.rb file would need to be updated to reflect that required version level. The Berksfile.lock would also need to be updated with the commit id of the dependent change.

Master Branch

The master cookbook should leverage the Semantic Versioning system lightly. We consider the master branch a fast paced "Work in Progress" until we come to the Release Candidate 1 date (RC-1). This means it will be under rapid and active development where versioning isn't always required. All patches must update the the CHANGELOG.md at a minimum.


Master Branch Example Situations Level of Change
Branching for a new Stable branch Increment Major
add a recipe Increment Minor
add a function or method Increment Minor
change Gemfile or Berksfile Increment Minor
add attribute for a value in a configuration file with the same default Increment Patch**
changing a resource option Increment Patch**
add a test Increment Patch**
fix a broken recipe Increment Patch**
re-factoring recipe or test Increment Patch**

The table above shows some examples of different levels of changes introduced by a patch and what part of the version number to increment for Master branches.

** There are cases where incrementing the Patch number is not necessary and only updating the CHANGELOG.md is required. To avoid re-base collisions on Patch number changes and allow more rapid development, if the change falls within these guidelines, incrementing the Patch version would not be required.

  • When the change only effects a single cookbook
  • When the change is just a simple addition of a new attribute for a template and no other logic change is required
  • When a patch only effects the tests
  • When a patch only effect the README or other comments

Version Locking

The Master branch is NOT locked down a Berksfile.lock or Gemfile.lock. Changes to the Berksfile and Gemfile can be made directly.

Cookbook Dependencies

When a change requires hits to multiple cookbooks, like when adding attributes to Common, the metadata.rb file would need to be updated to reflect that required version level.

Gate jobs

The OpenStack Chef cookbooks use infra gate jobs to to check and verify all patches. For the master the branch, the gate used is: gate-{name}-chef-rake, where name is the name of one of the cookbooks. This rake job uses a common/shared bootstrap script which is located in the cookbook-openstack-common project In the other cookbooks, you will note that their bootstrap scripts simple load and use the common one.

The bootstrap script will setup the development test environment by installing ChefDK. All Ruby gems required for the tests come from the ChefDK package, we don't use Gemfile or Bundler anymore. The rake gate job will simply execute the Rakefile located in each of the cookbooks.

The Rakefiles will by default run three tests with chef exec rake test

  • unit - RSpec
  • lint - FoodCritic
  • style - RuboCop


See the TESTING.md file in each cookbook for more details on testing cookbook patches.

back to GettingStarted page