Skip to content

Commit 0432c97

Browse files
authored
Merge pull request #6918 from killianmuldoon/runtimeSDK/e2e-more-patches
🌱 Add more patches to test extension
2 parents 0043155 + a99bcf5 commit 0432c97

File tree

16 files changed

+773
-166
lines changed

16 files changed

+773
-166
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package variables
18+
19+
const notFoundReason = "variable not found"
20+
21+
type errorWithReason interface {
22+
Reason() string
23+
}
24+
25+
// IsNotFoundError checks if the passed error is a notFoundError.
26+
func IsNotFoundError(err error) bool {
27+
if e, ok := err.(errorWithReason); ok {
28+
return e.Reason() == notFoundReason
29+
}
30+
return false
31+
}
32+
33+
// notFoundError is used when a variable is not found.
34+
type notFoundError struct {
35+
reason string
36+
message string
37+
}
38+
39+
func (e notFoundError) Error() string {
40+
return e.message
41+
}
42+
43+
// Reason returns the notFoundReason.
44+
func (e notFoundError) Reason() string {
45+
return e.reason
46+
}

internal/controllers/topology/cluster/patches/variables/value.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package variables
1818

1919
import (
20+
"fmt"
2021
"strconv"
2122
"strings"
2223

@@ -46,7 +47,7 @@ func GetVariableValue(variables map[string]apiextensionsv1.JSON, variablePath st
4647
// Get the variable.
4748
value, ok := variables[variableNameSegment.path]
4849
if !ok {
49-
return nil, errors.Errorf("variable %q does not exist", variableName)
50+
return nil, notFoundError{reason: notFoundReason, message: fmt.Sprintf("variable %q does not exist", variableName)}
5051
}
5152

5253
// Return the value, if variablePath points to a top-level variable, i.e. hos no relativePath and no
@@ -88,7 +89,7 @@ func GetVariableValue(variables map[string]apiextensionsv1.JSON, variablePath st
8889

8990
// Return if the variable does not exist.
9091
if !variable.Exists(pathSegment.path) {
91-
return nil, errors.Errorf("variable %q does not exist: failed to lookup segment %q", variablePath, pathSegment.path)
92+
return nil, notFoundError{reason: notFoundReason, message: fmt.Sprintf("variable %q does not exist: failed to lookup segment %q", variablePath, pathSegment.path)}
9293
}
9394

9495
// Get the variable from the variable object.

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func runtimeHookTestHandler(ctx context.Context, c client.Client, namespace, clu
488488
Eventually(func() bool {
489489
return blockingCondition()
490490
}, intervals...).Should(BeFalse(),
491-
fmt.Sprintf("ClusterTopology reconcile did proceed as expected when calling %s", hookName))
491+
fmt.Sprintf("ClusterTopology reconcile did not proceed as expected when calling %s", hookName))
492492
}
493493

494494
// clusterConditionShowsHookBlocking checks if the TopologyReconciled condition message contains both the hook name and hookFailedMessage.

test/e2e/data/infrastructure-docker/v1beta1/bases/cluster-with-topology.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ spec:
2727
replicas: ${WORKER_MACHINE_COUNT}
2828
failureDomain: fd4
2929
variables:
30-
- name: etcdImageTag
3130
# We set an empty value to use the default tag kubeadm init is using.
31+
- name: etcdImageTag
3232
value: ""
33-
- name: coreDNSImageTag
3433
# We set an empty value to use the default tag kubeadm init is using.
35-
value: ""
34+
- name: coreDNSImageTag
35+
value: ""

test/e2e/data/infrastructure-docker/v1beta1/cluster-template-upgrades-runtimesdk-cgroupfs/cluster-runtimesdk.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
resources:
2-
- ../cluster-template-upgrades-cgroupfs
2+
- ../cluster-template-upgrades-runtimesdk
3+
- ./mp-cgroupfs.yaml
34

45
patches:
5-
- ./cluster-runtimesdk.yaml
6+
- ./mp-default-cgroupfs.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# KubeadmConfigTemplate referenced by the MachinePool for cgroupfs
2+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
3+
kind: KubeadmConfig
4+
metadata:
5+
name: "${CLUSTER_NAME}-mp-0-config-cgroupfs"
6+
spec:
7+
joinConfiguration:
8+
nodeRegistration:
9+
kubeletExtraArgs:
10+
# We have to pin the cgroupDriver to cgroupfs as kubeadm >=1.21 defaults to systemd
11+
# kind will implement systemd support in: https://github.com/kubernetes-sigs/kind/issues/1726
12+
cgroup-driver: cgroupfs
13+
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: MachinePool
3+
metadata:
4+
name: "${CLUSTER_NAME}-mp-0"
5+
spec:
6+
template:
7+
spec:
8+
bootstrap:
9+
configRef:
10+
name: "${CLUSTER_NAME}-mp-0-config-cgroupfs"

test/e2e/data/infrastructure-docker/v1beta1/cluster-template-upgrades-runtimesdk/cluster-runtimesdk.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@ kind: Cluster
33
metadata:
44
name: '${CLUSTER_NAME}'
55
namespace: default
6+
labels:
7+
cni: "${CLUSTER_NAME}-crs-0"
68
spec:
9+
clusterNetwork:
10+
services:
11+
cidrBlocks: ['${DOCKER_SERVICE_CIDRS}']
12+
pods:
13+
cidrBlocks: ['${DOCKER_POD_CIDRS}']
14+
serviceDomain: '${DOCKER_SERVICE_DOMAIN}'
715
topology:
816
class: "quick-start-runtimesdk"
17+
version: "${KUBERNETES_VERSION}"
18+
controlPlane:
19+
metadata: {}
20+
nodeDeletionTimeout: "30s"
21+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
22+
workers:
23+
machineDeployments:
24+
- class: "default-worker"
25+
name: "md-0"
26+
nodeDeletionTimeout: "30s"
27+
replicas: ${WORKER_MACHINE_COUNT}
28+
failureDomain: fd4
29+
variables:
30+
- name: kubeadmControlPlaneMaxSurge
31+
value: "1"
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
resources:
2-
- ../cluster-template-upgrades
3-
4-
patches:
5-
- ./cluster-runtimesdk.yaml
2+
- ../bases/crs.yaml
3+
- ../bases/mp.yaml
4+
- ./cluster-runtimesdk.yaml

0 commit comments

Comments
 (0)