Skip to content

Commit 22b6ce5

Browse files
authored
Merge pull request #5983 from khenidak/alloc-release-resources
Auto resource release based on api changes
2 parents 88d4fbe + 99780a6 commit 22b6ce5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Diff for: contributors/devel/sig-architecture/api-conventions.md

+24
Original file line numberDiff line numberDiff line change
@@ -1609,3 +1609,27 @@ Example: "must be greater than \`request\`".
16091609
be less than 256", "must be greater than or equal to 0". Do not use words
16101610
like "larger than", "bigger than", "more than", "higher than", etc.
16111611
* When specifying numeric ranges, use inclusive ranges when possible.
1612+
1613+
1614+
## Automatic Resource Allocation And Deallocation
1615+
1616+
API objects often are [union](#Unions) object containing the following:
1617+
1. One or more fields identifying the `Type` specific to API object (aka the `discriminator`).
1618+
2. A set of N fields, only one of which should be set at any given time - effectively a union.
1619+
1620+
Controllers operating on the API type often allocate resources based on
1621+
the `Type` and/or some additional data provided by user. A canonical example
1622+
of this is the `Service` API object where resources such as IPs and network ports
1623+
will be set in the API object based on `Type`. When the user does not specify
1624+
resources, they will be allocated, and when the user specifies exact value, they will
1625+
be reserved or rejected.
1626+
1627+
When the user chooses to change the `discriminator` value (e.g., from `Type X` to `Type Y`) without
1628+
changing any other fields then the system should clear the fields that were used to represent `Type X`
1629+
in the union along with releasing resources that were attached to `Type X`. This should automatically
1630+
happen irrespective of how these values and resources were allocated (i.e., reserved by the user or
1631+
automatically allocated by the system. A concrete example of this is again `Service` API. The system
1632+
allocates resources such as `NodePorts` and `ClusterIPs` and automatically fill in the fields that
1633+
represent them in case of the service is of type `NodePort` or `ClusterIP` (`discriminator` values).
1634+
These resources and the fields representing them are automatically cleared when the users changes
1635+
service type to `ExternalName` where these resources and field values no longer apply.

0 commit comments

Comments
 (0)