design_decisions.rst 7.4 KB

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