Skip to content

Commit e4e9985

Browse files
committed
provide reasoning for why the condition.observedGeneration is optional and not a pointer
1 parent 45f87a4 commit e4e9985

File tree

1 file changed

+10
-0
lines changed
  • keps/sig-api-machinery/1623-standardize-conditions

1 file changed

+10
-0
lines changed

keps/sig-api-machinery/1623-standardize-conditions/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ However, it encapsulates the best of what we've learned and will allow new APIs
120120
3. `lastHeartbeatTime` is removed.
121121
This field caused excessive write loads as we scaled.
122122
If an API needs this concept, it should codify it separately and possibly using a different resource.
123+
4. `observedGeneration` does not follow the standard requirement of "all optional fields are pointers".
124+
This rule originated from the need to distinguish intent of zero value versus unset.
125+
The `.metadata.generation` is never set to zero.
126+
See the [CR strategy](https://github.com/kubernetes/apiextensions-apiserver/blob/release-1.18/pkg/registry/customresource/strategy.go#L88)
127+
and [deployment strategy](https://github.com/kubernetes/kubernetes/blob/release-1.18/pkg/registry/apps/deployment/strategy.go)
128+
as examples.
129+
Because `.metadata.generation` is never zero-value, it is not necessary to distinguish between absent and zero-value observedGeneration.
130+
Whether a client omits `observedGeneration` (because it is unaware of the new field) or explicitly sets it to 0, the
131+
meaning is the same: the condition does not correspond to a known generation.
132+
This also provides parity the `.metadata.generation` field [Generation int64 \`json:"generation,omitempty" protobuf:"varint,7,opt,name=generation"\`](https://github.com/kubernetes/apimachinery/blob/release-1.18/pkg/apis/meta/v1/types.go#L182-L185).
123133

124134
### Graduation Criteria
125135

0 commit comments

Comments
 (0)