fix: not gathering env info on cluster start (+ fix ipam e2e test)
This commit is contained in:
parent
67d8c8c84f
commit
2a2bee0e63
@ -51,6 +51,11 @@ func NewCmdClusterStart() *cobra.Command {
|
|||||||
l.Log().Infoln("No clusters found")
|
l.Log().Infoln("No clusters found")
|
||||||
} else {
|
} else {
|
||||||
for _, c := range clusters {
|
for _, c := range clusters {
|
||||||
|
envInfo, err := client.GatherEnvironmentInfo(cmd.Context(), runtimes.SelectedRuntime, c)
|
||||||
|
if err != nil {
|
||||||
|
l.Log().Fatalf("failed to gather info about cluster environment: %v", err)
|
||||||
|
}
|
||||||
|
startClusterOpts.EnvironmentInfo = envInfo
|
||||||
if err := client.ClusterStart(cmd.Context(), runtimes.SelectedRuntime, c, startClusterOpts); err != nil {
|
if err := client.ClusterStart(cmd.Context(), runtimes.SelectedRuntime, c, startClusterOpts); err != nil {
|
||||||
l.Log().Fatalln(err)
|
l.Log().Fatalln(err)
|
||||||
}
|
}
|
||||||
|
@ -13,35 +13,43 @@ highlight "[START] IPAM $EXTRA_TITLE"
|
|||||||
clustername="ipamtest"
|
clustername="ipamtest"
|
||||||
subnet="172.45.0.0/16"
|
subnet="172.45.0.0/16"
|
||||||
expectedIPGateway="172.45.0.1" # k3d defaults to subnet_start+1 for the Gateway IP
|
expectedIPGateway="172.45.0.1" # k3d defaults to subnet_start+1 for the Gateway IP
|
||||||
expectedIPLabelServer0="172.45.0.2"
|
expectedIPLabelServer0="172.45.0.3"
|
||||||
expectedIPServer0="$expectedIPLabelServer0/16" # k3d excludes the subnet_start (x.x.x.0) and then uses IPs in sequential order
|
expectedIPServer0="$expectedIPLabelServer0/16" # k3d excludes the subnet_start (x.x.x.0) and then uses IPs in sequential order, but .2 will be used by the tools container that gathers information at start
|
||||||
expectedIPServerLB="172.45.0.3/16"
|
expectedIPServerLB="172.45.0.4/16"
|
||||||
|
|
||||||
info "Creating cluster $clustername..."
|
info "Creating cluster $clustername..."
|
||||||
$EXE cluster create $clustername --timeout 360s --subnet $subnet || failed "could not create cluster $clustername"
|
$EXE cluster create $clustername --timeout 360s --subnet $subnet || failed "could not create cluster $clustername"
|
||||||
|
|
||||||
info "Checking we have access to the cluster..."
|
function check_cluster() {
|
||||||
check_clusters "$clustername" || failed "error checking cluster"
|
info "Checking we have access to the cluster..."
|
||||||
|
check_clusters "$clustername" || failed "error checking cluster"
|
||||||
|
|
||||||
info "Checking IP Subnet/IP values..."
|
info "Checking IP Subnet/IP values..."
|
||||||
if [[ $(docker network inspect k3d-$clustername | jq '.[0].IPAM.Config[0].Subnet') != "\"$subnet\"" ]]; then
|
if [[ $(docker network inspect k3d-$clustername | jq '.[0].IPAM.Config[0].Subnet') != "\"$subnet\"" ]]; then
|
||||||
failed "Subnet does not match expected value: $(docker network inspect k3d-$clustername | jq '.[0].IPAM.Config[0].Subnet') != \"$subnet\""
|
failed "Subnet does not match expected value: $(docker network inspect k3d-$clustername | jq '.[0].IPAM.Config[0].Subnet') != \"$subnet\""
|
||||||
fi
|
fi
|
||||||
if [[ $(docker network inspect k3d-$clustername | jq '.[0].IPAM.Config[0].Gateway') != "\"$expectedIPGateway\"" ]]; then
|
if [[ $(docker network inspect k3d-$clustername | jq '.[0].IPAM.Config[0].Gateway') != "\"$expectedIPGateway\"" ]]; then
|
||||||
failed "Gateway IP does not match expected value"
|
failed "Gateway IP does not match expected value"
|
||||||
fi
|
fi
|
||||||
if [[ $(docker network inspect k3d-$clustername | jq ".[0].Containers | .[] | select(.Name == \"k3d-$clustername-server-0\") | .IPv4Address") != "\"$expectedIPServer0\"" ]]; then
|
if [[ $(docker network inspect k3d-$clustername | jq ".[0].Containers | .[] | select(.Name == \"k3d-$clustername-server-0\") | .IPv4Address") != "\"$expectedIPServer0\"" ]]; then
|
||||||
failed "Container k3d-$clustername-server-0's IP does not match expected value"
|
failed "Container k3d-$clustername-server-0's IP does not match expected value"
|
||||||
fi
|
fi
|
||||||
if [[ $(docker network inspect k3d-$clustername | jq ".[0].Containers | .[] | select(.Name == \"k3d-$clustername-serverlb\") | .IPv4Address") != "\"$expectedIPServerLB\"" ]]; then
|
|
||||||
failed "Container k3d-$clustername-serverlb's IP does not match expected value: $(docker network inspect k3d-$clustername | jq ".[0].Containers | .[] | select(.Name == \"k3d-$clustername-serverlb\") | .IPv4Address") != \"$expectedIPServerLB\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
info "Checking Labels..."
|
info "Checking Labels..."
|
||||||
docker_assert_container_label "k3d-$clustername-server-0" "k3d.cluster.network.iprange=$subnet" || failed "missing label 'k3d.cluster.network.iprange=$subnet' on k3d-$clustername-server-0"
|
docker_assert_container_label "k3d-$clustername-server-0" "k3d.cluster.network.iprange=$subnet" || failed "missing label 'k3d.cluster.network.iprange=$subnet' on k3d-$clustername-server-0"
|
||||||
docker_assert_container_label "k3d-$clustername-server-0" "k3d.node.staticIP=$expectedIPLabelServer0" || failed "missing label 'k3d.node.staticIP=$expectedIPLabelServer0' on k3d-$clustername-server-0"
|
docker_assert_container_label "k3d-$clustername-server-0" "k3d.node.staticIP=$expectedIPLabelServer0" || failed "missing label 'k3d.node.staticIP=$expectedIPLabelServer0' on k3d-$clustername-server-0"
|
||||||
|
}
|
||||||
|
|
||||||
info "Deleting clusters..."
|
check_cluster
|
||||||
|
|
||||||
|
info "Stopping & Starting cluster $clustername..."
|
||||||
|
$EXE cluster stop $clustername || failed "error stopping cluster $clustername"
|
||||||
|
sleep 3
|
||||||
|
$EXE cluster start $clustername || failed "error starting cluster $clustername"
|
||||||
|
|
||||||
|
check_cluster
|
||||||
|
|
||||||
|
info "Deleting cluster $clustername..."
|
||||||
$EXE cluster delete $clustername || failed "could not delete the cluster $clustername"
|
$EXE cluster delete $clustername || failed "could not delete the cluster $clustername"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user