design_decisions.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Design decisions
  2. ================
  3. This document captures outcomes and, in some cases, the through process behind
  4. some of the design decisions that took place while architecting CloudBridge.
  5. It is intended as a reference.
  6. Require zone parameter when creating a default subnet
  7. -----------------------------------------------------
  8. Placement zone is required because it is an explicit application decision,
  9. even though ideally *default* would not require input. Before requiring it,
  10. the implementations would create a subnet in each availability zone and return
  11. the first one in the list. This could potentially return different values over
  12. time. Another factor influencing the decision was the example of creating a
  13. volume followed by creating an instance with presumably the two needing to be
  14. in the same zone. By requiring the zone across the board, it is less likely to
  15. lead to a mismatch. (Related to 63_.)
  16. Resource identification, naming, and labeling
  17. ---------------------------------------------
  18. While it would be reasonable to expect that complex constructs like
  19. networking would be the most difficult to abstract away uniformly across
  20. providers, in retrospect, simple naming of objects has arguably been the most
  21. complex and convoluted to map consistently. CloudBridge has been through
  22. several iterations of naming and labeling, before finally settling on the
  23. current design. This section captures that history and design rationale.
  24. **First iteration**
  25. In the early days, when CloudBridge supported only AWS and OpenStack, there
  26. were only two concepts, `id` and `name`. The `id` was straightforward enough,
  27. as it usually mapped to a unique identifier, auto-generated by the provider.
  28. The `name` generally mapped to a tag in the case of AWS, and a `name` field
  29. in the case of OpenStack. However, even then, there were inconsistencies
  30. within individual providers. For example, while AWS generally supported tags,
  31. it had a dedicated name field for machine images called ami-name.
  32. Furthermore, this name field could only be set at image creation time, and
  33. could not be changed thereafter. Similarly, AWS does not allow VM firewall
  34. (i.e., security group) names to be changed. Nevertheless, CloudBridge
  35. continued to use id and name, with the name being changeable for some
  36. resources, and read-only in others.
  37. As CloudBridge evolved and support was added for Azure and GCE, things only
  38. became more complex. Some providers (e.g. Azure and GCE) used a user-provided
  39. value instead of an auto-generated value as an `id`, which would also be
  40. displayed in their respective dashboards as `Name`. This meant that they were
  41. treating their servers as individually named pets, instead of adopting the
  42. cattle model, should one be tempted to use that macabre `pets vs cattle`_
  43. analogy. These user-provided names could not be changed after a resource had
  44. been created. Instead, these providers seemed to be gravitating toward the
  45. use of tags (or labels) to support arbitrary naming and name changes. Yet,
  46. not all resources support tags so CloudBridge could not rely solely on tags.
  47. Further, tags do not need to be unique across multiple resources, while names
  48. do (at least for some resources, such as vmfirewalls within a private
  49. network). Overall, consistency was challenging to achieve with resource
  50. naming. Therefore, it was decided that CloudBridge would continue to support
  51. resource renaming to the best extent possible and balance between the
  52. use of the resource name property and resource tags. However, because of the
  53. inconsistency in rename functionality across providers, using the rename
  54. capabilities within CloudBridge would lead to cloud-dependent code (Related to
  55. 131_.) and therefore, the only option was to continue to stick a caveat emptor
  56. to resource renaming.
  57. **Second iteration**
  58. However, it soon became apparent that this overloaded terminology was
  59. continuing to cause confusion. The `id` property in CloudBridge mapped to the
  60. unchangeable `name` property in Azure and GCE, and the *name* property in
  61. cloudbridge sometimes mapped to a *tag* in certain providers, and a *name* in
  62. other providers and they were sometimes read-only, sometimes writable. In an
  63. attempt to disambiguate these concepts, it was then decided that perhaps
  64. three concepts were needed - `id`, `display_id`, and `label`. The `id` would
  65. continue to refer to a unique identifier for a resource and be mapped
  66. accordingly to the underlying provider. The `display_id` would be a more
  67. user-friendly version of an id, suitable for display to an end-user and be
  68. unchangeable, but on rare occasions, not unique. For example, AWS ami-name
  69. was a `display_id` while the ami-id was an `id`. Similarly, an Azure resource
  70. name mapped to the `display_id`, since it was an unchangeable, user-friendly
  71. identifier. Finally, label was a changeable, user-assignable value that would
  72. be mapped often to a tag on the resource, or the name of the resource, should
  73. the name be changeable. This clearly disambiguated between unique
  74. identifiers, user-assignable values and read-only, user-friendly values. At
  75. object creation, all services would accept a label as an optional parameter.
  76. If provided, the `display_id` would sometimes be derived from the label by
  77. appending a uuid to the label, depending on the provider. At other times, it
  78. would simply map to an id.
  79. **Third iteration**
  80. It soon became apparent that some resources like keypairs could not have a
  81. label at all, yet needed to be named during object creation. However, we
  82. could not use `display_id` for this purpose became the display_id, by
  83. definition, is unchangeable. It could not be called `label` because the label,
  84. in contrast, was changeable. Therefore, it seemed like we were back to
  85. calling it `name` instead, introducing yet a fourth term. To simplify this,
  86. it was then decided that `display_id` and `name` would be collapsed together
  87. into one term and be called `name` instead. All resources would have an `id`
  88. and a `name`, and resources that support it would have a `label`. To make
  89. things even simpler and consistent, it was also decided that label would be
  90. made mandatory for all resources during object creation, and follow the same
  91. restrictions as name, which is to have a 3 character minimum. (This was to
  92. deal with an exception in OpenStack, where the label mapped to instance name,
  93. but could not be empty. Therefore, by making all labels mandatory and adhere
  94. to minimum length restrictions, we could make the overall conventions uniform
  95. across all resources and therefore easier to remember and enforce.)
  96. **TL;DR**
  97. CloudBridge has three concepts when it comes to naming and identifying
  98. objects:
  99. - `id` is a unique identifier for an object, always
  100. auto-generated;
  101. - `name` is a read-only, user-friendly value which is
  102. suitable for display to the end-user;
  103. - `label` is a user-assignable value that can be changed.
  104. The `name` is often derived from the `label` but not
  105. always. Not all resources support `labels`. Some only accept `names`, which
  106. can be specified at object creation time (e.g. keypairs). Both `names` and
  107. `labels` adhere to the same restrictions - a minimum length of 3 which
  108. should be alphanumeric characters or dashes only. Names or labels should
  109. not begin or end with a dash, or have consecutive dashes.
  110. .. _63: https://github.com/CloudVE/cloudbridge/issues/63
  111. .. _131: https://github.com/CloudVE/cloudbridge/issues/131
  112. .. _pets vs cattle: http://cloudscaling.com/blog/cloud-computing/the-history-of-pets-vs-cattle/