You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contributors/devel/sig-architecture/api-conventions.md
+27-3Lines changed: 27 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -906,6 +906,24 @@ It is okay to have the "{field}" component indicate the resource type. For examp
906
906
a secret. However, this comes with the risk of the field being a misnomer in the case that the field is expanded to
907
907
reference more than one type.
908
908
909
+
### Referencing resources with multiple versions
910
+
911
+
Most resources will have multiple versions. For example, core resources
912
+
will undergo version changes as it transitions from alpha to GA.
913
+
914
+
Controllers should assume that a version of a resource may change, and include appropriate error handling.
915
+
916
+
### Handling of resources that do not exist
917
+
918
+
There are multiple scenarios where a desired resource may not exist. Examples include:
919
+
920
+
- the desired version of the resource does not exist.
921
+
- race condition in the bootstrapping of a cluster resulting a resource not yet added.
922
+
- user error.
923
+
924
+
Controllers should be authored with the assumption that the referenced resource may not exist, and include
925
+
error handling to make the issue clear to the user.
926
+
909
927
### Object References Examples
910
928
911
929
The following sections illustrate recommended schemas for various object references scenarios.
@@ -955,6 +973,9 @@ Although not always necessary to help a controller identify a resource type, “
955
973
956
974
The operator can store a map of (group,resource) to the version of that resource it desires. From there, it can construct the full path to the resource, and retrieve the object.
957
975
976
+
It is also possible to have the controller choose a version that it finds via the discovery client. However, as schemas can vary across different versions
977
+
of a resource, the controller must also handle these differences.
978
+
958
979
#### Generic object reference
959
980
960
981
A generic object reference is used when the desire is to provide a pointer to some object to simplify discovery for the user. For example, this could be used to reference a target object for a `core.v1.Event` that occurred.
@@ -972,7 +993,7 @@ fooObjectRef:
972
993
973
994
##### Controller behavior
974
995
975
-
The operator would be expected to find the resource via the discovery client (as the version is not supplied).
996
+
The operator would be expected to find the resource via the discovery client (as the version is not supplied). As any retrievable field would be common to all objects, any version of the resource should do.
976
997
977
998
#### Field reference
978
999
@@ -992,9 +1013,12 @@ The fieldPath should point to a single value, and use [the recommended field sel
992
1013
993
1014
##### Controller behavior
994
1015
995
-
In this scenario, all required attributes are required, so the operator may query the API directly.
1016
+
In this scenario, the user will supply all of the required path elements: group, version, resource, name, and possibly namespace.
1017
+
As such, the controller can construct the API prefix and query it without the use of the discovery client:
0 commit comments