-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mohammed Boukhalfa <[email protected]>
- Loading branch information
1 parent
e948801
commit f80656f
Showing
9 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
.../e2e/data/infrastructure-metal3/cluster-template-centos-md-remediation/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resources: | ||
- ../bases/ippool | ||
- ../bases/centos-kubeadm-config | ||
|
||
- mhc.yaml | ||
patchesStrategicMerge: | ||
- md.yaml |
14 changes: 14 additions & 0 deletions
14
test/e2e/data/infrastructure-metal3/cluster-template-centos-md-remediation/md.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
apiVersion: cluster.x-k8s.io/${CAPI_VERSION} | ||
kind: MachineDeployment | ||
metadata: | ||
labels: | ||
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} | ||
nodepool: nodepool-0 | ||
name: ${CLUSTER_NAME} | ||
namespace: ${NAMESPACE} | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
"e2e.remediation.label": "" |
19 changes: 19 additions & 0 deletions
19
test/e2e/data/infrastructure-metal3/cluster-template-centos-md-remediation/mhc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
# MachineHealthCheck object with | ||
# - a selector that targets all the machines with label e2e.remediation.label="" | ||
# - unhealthyConditions triggering remediation after 10s the condition is set | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: MachineHealthCheck | ||
metadata: | ||
name: "${CLUSTER_NAME}-mhc-0" | ||
namespace: ${NAMESPACE} | ||
spec: | ||
clusterName: "${CLUSTER_NAME}" | ||
maxUnhealthy: 100% | ||
selector: | ||
matchLabels: | ||
e2e.remediation.label: "" | ||
unhealthyConditions: | ||
- type: e2e.remediation.condition | ||
status: "False" | ||
timeout: 10s |
7 changes: 7 additions & 0 deletions
7
.../e2e/data/infrastructure-metal3/cluster-template-ubuntu-md-remediation/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resources: | ||
- ../bases/ippool | ||
- ../bases/ubuntu-kubeadm-config | ||
|
||
- mhc.yaml | ||
patchesStrategicMerge: | ||
- md.yaml |
14 changes: 14 additions & 0 deletions
14
test/e2e/data/infrastructure-metal3/cluster-template-ubuntu-md-remediation/md.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
apiVersion: cluster.x-k8s.io/${CAPI_VERSION} | ||
kind: MachineDeployment | ||
metadata: | ||
labels: | ||
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} | ||
nodepool: nodepool-0 | ||
name: ${CLUSTER_NAME} | ||
namespace: ${NAMESPACE} | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
"e2e.remediation.label": "" |
19 changes: 19 additions & 0 deletions
19
test/e2e/data/infrastructure-metal3/cluster-template-ubuntu-md-remediation/mhc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
# MachineHealthCheck object with | ||
# - a selector that targets all the machines with label e2e.remediation.label="" | ||
# - unhealthyConditions triggering remediation after 10s the condition is set | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: MachineHealthCheck | ||
metadata: | ||
name: "${CLUSTER_NAME}-mhc-0" | ||
namespace: ${NAMESPACE} | ||
spec: | ||
clusterName: "${CLUSTER_NAME}" | ||
maxUnhealthy: 100% | ||
selector: | ||
matchLabels: | ||
e2e.remediation.label: "" | ||
unhealthyConditions: | ||
- type: e2e.remediation.condition | ||
status: "False" | ||
timeout: 10s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package e2e | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"k8s.io/utils/ptr" | ||
bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" | ||
capi_e2e "sigs.k8s.io/cluster-api/test/e2e" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
var _ = Describe("When testing MachineDeployment remediation [healthcheck] [remediation] [features]", Label("healthcheck", "remediation", "features"), func() { | ||
BeforeEach(func() { | ||
osType := strings.ToLower(os.Getenv("OS")) | ||
Expect(osType).ToNot(Equal("")) | ||
validateGlobals(specName) | ||
// We need to override clusterctl apply log folder to avoid getting our credentials exposed. | ||
clusterctlLogFolder = filepath.Join(os.TempDir(), "clusters", bootstrapClusterProxy.GetName()) | ||
}) | ||
capi_e2e.MachineDeploymentRemediationSpec(ctx, func() capi_e2e.MachineDeploymentRemediationSpecInput { | ||
return capi_e2e.MachineDeploymentRemediationSpecInput{ | ||
E2EConfig: e2eConfig, | ||
ClusterctlConfigPath: clusterctlConfigPath, | ||
BootstrapClusterProxy: bootstrapClusterProxy, | ||
ArtifactFolder: artifactFolder, | ||
SkipCleanup: skipCleanup, | ||
PostNamespaceCreated: postNamespaceCreated, | ||
Flavor: ptr.To(fmt.Sprintf("%s-md-remediation", osType)), | ||
} | ||
}) | ||
AfterEach(func() { | ||
// Recreate bmh that was used in capi namespace in metal3 | ||
//#nosec G204 -- We need to pass in the file name here. | ||
cmd := exec.Command("bash", "-c", "kubectl apply -f bmhosts_crs.yaml -n metal3") | ||
cmd.Dir = workDir | ||
output, err := cmd.CombinedOutput() | ||
Logf("Applying bmh to metal3 namespace : \n %v", string(output)) | ||
Expect(err).ToNot(HaveOccurred()) | ||
// wait for all bmh to become available | ||
bootstrapClient := bootstrapClusterProxy.GetClient() | ||
ListBareMetalHosts(ctx, bootstrapClient, client.InNamespace(namespace)) | ||
WaitForNumBmhInState(ctx, bmov1alpha1.StateAvailable, WaitForNumInput{ | ||
Client: bootstrapClient, | ||
Options: []client.ListOption{client.InNamespace(namespace)}, | ||
Replicas: 4, | ||
Intervals: e2eConfig.GetIntervals(specName, "wait-bmh-available"), | ||
}) | ||
ListBareMetalHosts(ctx, bootstrapClient, client.InNamespace(namespace)) | ||
}) | ||
}) |