Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: add kops validate step to metal test #16943

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions tests/e2e/scenarios/bare-metal/run-test
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ function cleanup() {
echo "running dump-artifacts"
${REPO_ROOT}/tests/e2e/scenarios/bare-metal/dump-artifacts || true

echo "running cleanup"
${REPO_ROOT}/tests/e2e/scenarios/bare-metal/cleanup || true
if [[ -z "${SKIP_CLEANUP:-}" ]]; then
echo "running cleanup"
${REPO_ROOT}/tests/e2e/scenarios/bare-metal/cleanup || true
fi
}

if [[ -z "${SKIP_CLEANUP:-}" ]]; then
Expand Down Expand Up @@ -136,8 +138,14 @@ ssh -o StrictHostKeyChecking=accept-new -i ${REPO_ROOT}/.build/.ssh/id_ed25519 r
ssh -o StrictHostKeyChecking=accept-new -i ${REPO_ROOT}/.build/.ssh/id_ed25519 [email protected] touch /mnt/disks/metal.k8s.local--events--0/mnt/please-create-new-cluster


echo "Waiting 300 seconds for kube to start"
sleep 300
echo "Waiting for kube to start"
# Wait for kube-apiserver to be ready, timeout after 10 minutes
for i in {1..60}; do
if kubectl get nodes; then
break
fi
sleep 10
done

kubectl get nodes
kubectl get pods -A
Expand Down Expand Up @@ -215,5 +223,7 @@ sleep 30
kubectl get nodes
kubectl get pods -A

# Ensure the cluster passes validation
${KOPS} validate cluster metal.k8s.local --wait=10m

echo "Test successful"
40 changes: 39 additions & 1 deletion upup/pkg/fi/cloudup/metal/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,45 @@ func (c *Cloud) DetachInstance(instance *cloudinstances.CloudInstance) error {
// GetCloudGroups returns a map of cloud instances that back a kops cluster.
// Detached instances must be returned in the NeedUpdate slice.
func (c *Cloud) GetCloudGroups(cluster *kops.Cluster, instancegroups []*kops.InstanceGroup, warnUnmatched bool, nodes []v1.Node) (map[string]*cloudinstances.CloudInstanceGroup, error) {
return nil, fmt.Errorf("method metal.Cloud::GetCloudGroups not implemented")
groups := make(map[string]*cloudinstances.CloudInstanceGroup)
for _, ig := range instancegroups {
cloudInstanceGroup := &cloudinstances.CloudInstanceGroup{
InstanceGroup: ig,
}
groups[ig.ObjectMeta.Name] = cloudInstanceGroup
for _, node := range nodes {
isControlPlaneNode := false
for k := range node.Labels {
if k == "node-role.kubernetes.io/control-plane" {
isControlPlaneNode = true
}

}

match := true
switch ig.Spec.Role {
case kops.InstanceGroupRoleControlPlane:
if !isControlPlaneNode {
match = false
}

case kops.InstanceGroupRoleNode:
if isControlPlaneNode {
match = false
}
}

if match {
cloudInstanceGroup.Ready = append(cloudInstanceGroup.Ready, &cloudinstances.CloudInstance{
ID: node.Name,
Node: &node,
CloudInstanceGroup: cloudInstanceGroup,
})
}
}
}

return groups, nil
}

// Region returns the cloud region bound to the cloud instance.
Expand Down
Loading