Skip to content

feat!: record server origin and lead the name with the project - #261

Open
ramereth wants to merge 1 commit into
mainfrom
ramereth/default-metadata
Open

ramereth wants to merge 1 commit into
mainfrom
ramereth/default-metadata

Conversation

@ramereth

Copy link
Copy Markdown
Contributor

Description

Tag every server kitchen-openstack creates with where it came from, and start generated server names with the project. This lets whoever cleans up a shared OpenStack project tell who created a server and from which cookbook, so the right person can run kitchen destroy.

The default name was <suite-platform>-<user>-<host>-<random>. That names the person but not the project, and a suite like default exists in almost every cookbook. We hit this at the OSU Open Source Lab while cleaning up a shared test project near its RAM quota, where most servers could only be traced to a person, not to the cookbook that created them.

Servers now carry six kitchen_* metadata keys, and the generated name is <project>-<suite-platform>-<user>-<random>. The project is the basename of the Kitchen root, usually the cookbook directory. Instances created by earlier releases are unaffected, because once a server exists every action finds it through state[:server_id], never by name. The server name and metadata logic are in config.rb and server_helper.rb, and both are worth reading first.

  • Add default_metadata, on by default, which sets kitchen_instance, kitchen_suite, kitchen_platform, kitchen_project, kitchen_user and kitchen_host
  • Merge the user's metadata over those defaults so user keys win, with keys stringified because Kitchen symbolizes config keys and both spellings would otherwise be sent
  • Send user metadata values as strings, the only type Nova accepts, so keep: true in kitchen.yml no longer fails at create time
  • Raise ActionFailed when metadata is not a hash instead of crashing with NoMethodError
  • Truncate default values to Nova's 255-byte limit without splitting a multibyte character
  • Generate <project>-<suite-platform>-<user>-<random> and move the workstation hostname to kitchen_host
  • Give the project the 23 characters the hostname had, so the longest generated name is still exactly 63, and rename NAME_HOSTNAME_LENGTH to NAME_PROJECT_LENGTH
  • Leave out name components that strip to nothing instead of leaving a stray separator
  • Log the server id when create finds an existing server, instead of a newly generated name that server never had
  • Document the new option, the metadata keys and the name format in the README
  • Cover the metadata rules in server_helper_spec, the name layout in config_spec and the create message in openstack_spec

Issues Resolved

None filed.

Type of Change

feat!: because generated server names, and the guest hostnames Nova derives from them, now start with the project instead of ending with the workstation hostname. Anyone matching on the old name format will notice, so this should release as a major version. Set server_name or server_name_prefix to keep a fixed name, or default_metadata: false to skip the metadata.

Check List

References:

Cleaning up a shared OpenStack project means working out who created each
server and from which cookbook or repo, so the right person can run kitchen
destroy. The default name was <suite-platform>-<user>-<host>-<random>, which
names the person but not the project, and a suite like "default" exists in
almost every cookbook.

Servers now carry metadata saying where they came from, and the generated
name starts with the project. Instances created by earlier releases are
unaffected: once a server exists, every action finds it through
state[:server_id], never by name.

- Add default_metadata (on by default) to set kitchen_instance, kitchen_suite,
  kitchen_platform, kitchen_project, kitchen_user and kitchen_host
- Merge the user's metadata over those defaults with stringified keys, since
  Kitchen symbolizes config keys and both spellings would otherwise be sent
- Send user metadata values as strings, the only type Nova accepts, and reject
  a metadata setting that is not a hash with ActionFailed
- Truncate default values to Nova's 255-byte limit without splitting a
  multibyte character
- Generate <project>-<suite-platform>-<user>-<random>, where the project is the
  basename of kitchen_root; the hostname moves to kitchen_host
- Leave out name components that strip to nothing instead of leaving a stray
  separator
- Rename NAME_HOSTNAME_LENGTH to NAME_PROJECT_LENGTH, keeping its 23 characters
- Log the server id when create finds an existing server, instead of a newly
  generated name that server never had
- Document both in the README
- Cover the metadata rules in server_helper_spec, the name layout in
  config_spec and the create message in openstack_spec

BREAKING CHANGE: generated server names, and the guest hostnames Nova derives
from them, now start with the project instead of ending with the workstation
hostname.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lance Albertson <lance@osuosl.org>
@ramereth
ramereth requested a review from tas50 October 19, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant