Skip to content

Commit bda0f50

Browse files
committed
Addressing feeedback
- new section around resources with different versions - called out edge cases around resource not found - removed very old todo
1 parent 9b694b1 commit bda0f50

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

contributors/devel/sig-architecture/api-conventions.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,24 @@ It is okay to have the "{field}" component indicate the resource type. For examp
906906
a secret. However, this comes with the risk of the field being a misnomer in the case that the field is expanded to
907907
reference more than one type.
908908

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+
909927
### Object References Examples
910928

911929
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, “
955973

956974
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.
957975

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+
958979
#### Generic object reference
959980

960981
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:
972993

973994
##### Controller behavior
974995

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.
976997

977998
#### Field reference
978999

@@ -992,9 +1013,12 @@ The fieldPath should point to a single value, and use [the recommended field sel
9921013

9931014
##### Controller behavior
9941015

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:
9961018

997-
TODO: Plugins, extensions, headers
1019+
```
1020+
/apis/{group}/{version}/{resource}/
1021+
```
9981022

9991023
## HTTP Status codes
10001024

0 commit comments

Comments
 (0)