Skip to content

Commit 9e126c0

Browse files
committed
apply feedback
1 parent 124d9e2 commit 9e126c0

File tree

1 file changed

+32
-13
lines changed
  • keps/sig-api-machinery/2144-clientgo-apply

1 file changed

+32
-13
lines changed

keps/sig-api-machinery/2144-clientgo-apply/README.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ deficiencies:
9898
Use the existing go structs to construct an apply configuration, serialize
9999
it to JSON, and pass it to `Patch`. This can cause zero valued required
100100
fields being accientally included in the apply configuration resulting
101-
in fields being accidentally set to incorrect values and/or fields accidentally
102-
being accidentally being clamed as owned.
101+
in fields being accidentally set to incorrect values and/or fields
102+
accidentally being clamed as owned.
103103

104104
Both sig-api-machinery and wg-api-expression agree that this enhancement is
105105
required for server side apply to be promoted to GA.
@@ -126,7 +126,8 @@ Validate this enhancement meets the needs of developers:
126126
### Non-Goals
127127

128128
Enhancements to client-go's dynamic client. The client-go dynamic client already
129-
supports Apply via Patch, which is adequate for the dynamic client.
129+
supports Apply via Patch, which is adequate for the dynamic client for GA. In
130+
the future, a nicer mechanism can be proposed separate from this KEP.
130131

131132
Protobuf support. Apply does not support protobuf, and it will not be added with
132133
this enhancement.
@@ -142,7 +143,7 @@ representation, which will need to be generated for this purpose.
142143
#### Poor adoption
143144

144145
Risk: Developers adoption is poor, either because the aesthetics/ergonomics are
145-
not to their liking or the functinality is insufficient to do what they need to
146+
not to their liking or the functionality is insufficient to do what they need to
146147
do with it. This could lead to (a) poor server side apply adoption, and/or (b)
147148
developers building alternate solutions.
148149

@@ -158,7 +159,9 @@ take an aligned approach to adding apply to clients in a typesafe way.
158159
The client-go typed clients will be extended to include Apply functions, e.g.:
159160

160161
```go
161-
func (c *deployments) Apply(ctx Context, fieldManager string, deployment *appsv1apply.Deployment, opts metav1.ApplyOptions, subresources ...string) (*Deployment, error)
162+
func (c *deployments) Apply(ctx Context, fieldManager string, deployment *appsv1apply.Deployment, opts metav1.ApplyOptions) (*Deployment, error)
163+
func (c *deployments) ApplyStatus(ctx Context, fieldManager string, deployment *appsv1apply.Deployment, opts metav1.ApplyOptions) (*Deployment, error)
164+
func (c *deployments) ApplyScale(ctx Context, fieldManager string, deployment *appsv1apply.Deployment, opts metav1.ApplyOptions) (*Deployment, error)
162165
```
163166

164167
`ApplyOptions` will be added to metav1 even though `PatchOptions` will continue
@@ -174,6 +177,30 @@ type ApplyOptions struct {
174177
func (ApplyOptions) ToPatchOptions(fieldManager string) PatchOptions
175178
```
176179

180+
<<[UNRESOLVED @jpbetz ]>>
181+
182+
Should fieldManager be a parameter of Apply or should it be optional?
183+
184+
The main reason this KEP proposes fieldmanager be a required parameter
185+
for Apply is that some controllers have multiple code paths that
186+
update the same same object, but that update different field sets. If
187+
they used apply and the same field manager, fields could be
188+
accidentally removed or disowned.
189+
190+
Create and Update methods default the fieldmanager to a user-agent
191+
based string. But unlike Apply, Updates succeed even if there are
192+
conflicts, so the fieldmanager name is almost entirely
193+
informational. For Apply, the fieldmanager name matters a lot more,
194+
and a user-agent string is almost certainly not a good default
195+
fieldmanager for Apply.
196+
197+
If we require fieldManager, an alternative to making fieldManager a
198+
required parameter of `Apply` functions would be have a constructor
199+
for Apply options like `NewApplyOptions(fieldManager, force)` that
200+
makes the required field clear.
201+
202+
<<[/UNRESOLVED]>>
203+
177204
<<[UNRESOLVED @jpbetz ]>>
178205
Should the Force field also be made a required field like fieldManager is?
179206
@lavalamp pointed out that user things typically want false but
@@ -196,14 +223,6 @@ client.Deployments().BeginApply("field-manager-name", options).Body(
196223
Apply will combine the `fieldManager` argument with `ApplyOptions` to create the
197224
`PatchOptions`.
198225

199-
Each apply call will be required to provide a fieldmanager name. We will not
200-
provide a a way for the fieldmanager name to be set for the entire
201-
clientset. The main reason for this is that if a client has multiple code paths
202-
where it makes apply requests to the same object, but with different field sets,
203-
they must use different field manager names. If they use the same field manager
204-
name they will cause fields to be accidentally removed or disowned. This is a
205-
potential foot gun we would like to avoid.
206-
207226
### Generated apply configuration types
208227

209228
All fields present in an apply configuration become owned by the applier after

0 commit comments

Comments
 (0)