Skip to content

Commit dd93c5f

Browse files
committed
Enable MS in-place rollout check in e2e test
Signed-off-by: Stefan Büringer [email protected]
1 parent 043957b commit dd93c5f

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

docs/book/src/tasks/experimental-features/runtime-sdk/implement-extensions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ created, the extension will detect the associated service and discover the assoc
304304
check the status of the ExtensionConfig. Below is an example of `ExtensionConfig` -
305305

306306
```yaml
307-
apiVersion: runtime.cluster.x-k8s.io/v1alpha1
307+
apiVersion: runtime.cluster.x-k8s.io/v1beta2
308308
kind: ExtensionConfig
309309
metadata:
310310
annotations:

docs/proposals/20220221-runtime-SDK.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ behavior is introduced by this proposal:
296296
The Cluster administrator is required to register available Runtime Extension server using the following CR:
297297

298298
```yaml
299-
apiVersion: runtime.cluster.x-k8s.io/v1alpha1
299+
apiVersion: runtime.cluster.x-k8s.io/v1beta2
300300
kind: ExtensionConfig
301301
metadata:
302302
name: "my-amazing-extensions"
@@ -326,7 +326,7 @@ The `namespaceSelector` will enable targeting of a subset of Clusters.
326326

327327
```yaml
328328
329-
apiVersion: runtime.cluster.x-k8s.io/v1alpha1
329+
apiVersion: runtime.cluster.x-k8s.io/v1beta2
330330
kind: ExtensionConfig
331331
metadata:
332332
name: "my-amazing-extensions"
@@ -367,8 +367,7 @@ dependencies among Runtime Extensions, being it modeled with something similar t
367367
[systemd unit options](https://www.freedesktop.org/software/systemd/man/systemd.unit.html) or alternative approaches.
368368

369369
The main reason behind that is that such type of feature introduces complexity and creates "pet" like relations across
370-
components making the overall system more fragile. This is also consistent with the [avoid dependencies](#avoid-dependencies)
371-
recommendation above.
370+
components making the overall system more fragile. This is also consistent with the avoid dependencies recommendation.
372371

373372
## Runtime Hooks developer guide (CAPI internals)
374373

internal/controllers/machinedeployment/machinedeployment_rollout_rollingupdate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func (p *rolloutPlanner) reconcileInPlaceUpdateIntent(ctx context.Context) error
415415
}
416416

417417
// Check if the MachineSet can update in place; if not, move to the next MachineSet.
418-
canUpdateMachineSetInPlaceFunc := func(_ *clusterv1.MachineSet) bool { return false }
418+
canUpdateMachineSetInPlaceFunc := func(_ *clusterv1.MachineSet) bool { return true }
419419
if p.overrideCanUpdateMachineSetInPlace != nil {
420420
canUpdateMachineSetInPlaceFunc = p.overrideCanUpdateMachineSetInPlace
421421
}

test/e2e/cluster_in_place_update.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ func ClusterInPlaceUpdateSpec(ctx context.Context, inputGetter func() ClusterInP
209209

210210
// Doing multiple in-place updates for additional coverage.
211211
filePath := "/tmp/test"
212-
for i, fileContent := range []string{"first in-place update", "second in-place update"} {
212+
for i, fileContent := range []string{
213+
"first in-place update",
214+
"second in-place update",
215+
"third in-place update",
216+
"fourth in-place update",
217+
"five in-place update",
218+
} {
213219
Byf("[%d] Trigger in-place update by modifying the files variable", i)
214220

215221
originalCluster := cluster.DeepCopy()
@@ -246,8 +252,7 @@ func ClusterInPlaceUpdateSpec(ctx context.Context, inputGetter func() ClusterInP
246252
// Ensure only in-place updates were executed and no Machine was re-created.
247253
machineObjectsAfterInPlaceUpdate = getMachineObjects(ctx, g, mgmtClient, cluster)
248254
g.Expect(machineNames(machineObjectsAfterInPlaceUpdate.ControlPlaneMachines)).To(Equal(machineNames(machineObjectsBeforeInPlaceUpdate.ControlPlaneMachines)))
249-
// TODO(in-place): enable once MD/MS/Machine controller PRs are merged
250-
// g.Expect(machineNames(machineObjectsAfterInPlaceUpdate.WorkerMachines)).To(Equal(machineNames(machineObjectsBeforeInPlaceUpdate.WorkerMachines)))
255+
g.Expect(machineNames(machineObjectsAfterInPlaceUpdate.WorkerMachines)).To(Equal(machineNames(machineObjectsBeforeInPlaceUpdate.WorkerMachines)))
251256
}, input.E2EConfig.GetIntervals(specName, "wait-control-plane")...).Should(Succeed())
252257

253258
// Update machineObjectsBeforeInPlaceUpdate for the next round of in-place update.

test/extension/config/tilt/extensionconfig.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: runtime.cluster.x-k8s.io/v1alpha1
1+
apiVersion: runtime.cluster.x-k8s.io/v1beta2
22
kind: ExtensionConfig
33
metadata:
44
annotations:
@@ -17,4 +17,4 @@ spec:
1717
- key: kubernetes.io/metadata.name
1818
operator: In
1919
values:
20-
- default # Note: this assumes the test extension is used by Cluster in the default namespace only
20+
- default # Note: this assumes the test extension is used by Cluster in the default namespace only

test/extension/handlers/inplaceupdate/handlers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"gomodules.xyz/jsonpatch/v2"
3333
"k8s.io/apimachinery/pkg/runtime"
3434
"k8s.io/apimachinery/pkg/runtime/serializer"
35+
"k8s.io/apimachinery/pkg/util/rand"
3536
"k8s.io/klog/v2"
3637
ctrl "sigs.k8s.io/controller-runtime"
3738
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -198,7 +199,7 @@ func (h *ExtensionHandlers) DoUpdateMachine(ctx context.Context, req *runtimehoo
198199
// Note: We are intentionally not actually applying any in-place changes we are just faking them,
199200
// which is good enough for test purposes.
200201
if firstTimeCalled, ok := h.state.Load(key); ok {
201-
if time.Since(firstTimeCalled.(time.Time)) > 20*time.Second {
202+
if time.Since(firstTimeCalled.(time.Time)) > time.Duration(20+rand.Intn(10))*time.Second {
202203
h.state.Delete(key)
203204
resp.Status = runtimehooksv1.ResponseStatusSuccess
204205
resp.Message = "In-place update is done"

0 commit comments

Comments
 (0)