@@ -21,24 +21,14 @@ import (
2121 "fmt"
2222 "os"
2323 "path/filepath"
24- "strings"
25- "time"
2624
2725 "github.com/onsi/ginkgo/v2"
2826 "github.com/onsi/gomega"
29- appsv1 "k8s.io/api/apps/v1"
3027 corev1 "k8s.io/api/core/v1"
31- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3228 "k8s.io/utils/ptr"
33- clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3429 "sigs.k8s.io/cluster-api/test/framework"
3530 "sigs.k8s.io/cluster-api/test/framework/clusterctl"
3631 "sigs.k8s.io/cluster-api/util"
37- "sigs.k8s.io/cluster-api/util/conditions"
38- "sigs.k8s.io/controller-runtime/pkg/client"
39- "sigs.k8s.io/controller-runtime/pkg/log"
40-
41- infrav1 "github.com/syself/cluster-api-provider-hetzner/api/v1beta1"
4232)
4333
4434// CaphClusterDeploymentSpecInput is the input for CaphClusterDeploymentSpec.
@@ -53,87 +43,6 @@ type CaphClusterDeploymentSpecInput struct {
5343 ControlPlaneMachineCount int64
5444}
5545
56- func logHCloudMachineStatusContinously (ctx context.Context , c client.Client ) {
57- for {
58- t := time .After (30 * time .Second )
59- select {
60- case <- ctx .Done ():
61- return
62- case <- t :
63- err := logHCloudMachineStatus (ctx , c )
64- if err != nil {
65- logger := log .FromContext (ctx )
66- logger .Info ("Error logging HCloudMachine status" , "error" , err )
67- }
68- }
69- }
70- }
71-
72- func logHCloudMachineStatus (ctx context.Context , c client.Client ) error {
73- hmList := & infrav1.HCloudMachineList {}
74- err := c .List (ctx , hmList )
75- if err != nil {
76- return err
77- }
78-
79- if len (hmList .Items ) == 0 {
80- return nil
81- }
82-
83- caphDeployment := appsv1.Deployment {
84- ObjectMeta : metav1.ObjectMeta {
85- Name : "caph-controller-manager" ,
86- Namespace : "caph-system" ,
87- },
88- }
89- err = c .Get (ctx , client .ObjectKeyFromObject (& caphDeployment ), & caphDeployment )
90- if err != nil {
91- return fmt .Errorf ("failed to get caph-controller-manager deployment: %w" , err )
92- }
93-
94- ginkgo .By (fmt .Sprintf ("--------------------------------------------------- HCloudMachines %s" ,
95- caphDeployment .Spec .Template .Spec .Containers [0 ].Image ))
96-
97- for i := range hmList .Items {
98- hm := & hmList .Items [i ]
99- if hm .Status .InstanceState == nil || * hm .Status .InstanceState == "" {
100- continue
101- }
102- addresses := make ([]string , 0 )
103- for _ , a := range hm .Status .Addresses {
104- addresses = append (addresses , a .Address )
105- }
106-
107- id := ""
108- if * hm .Spec .ProviderID != "" {
109- id = * hm .Spec .ProviderID
110- }
111- ginkgo .By ("HCloudMachine: " + hm .Name + " " + id + " " + strings .Join (addresses , " " ))
112- ginkgo .By (" ProvisioningState: " + string (* hm .Status .InstanceState ))
113- l := make ([]string , 0 )
114- if hm .Status .FailureMessage != nil {
115- l = append (l , * hm .Status .FailureMessage )
116- }
117- if hm .Status .FailureMessage != nil {
118- l = append (l , * hm .Status .FailureMessage )
119- }
120- if len (l ) > 0 {
121- ginkgo .By (" Error: " + strings .Join (l , ", " ))
122- }
123- readyC := conditions .Get (hm , clusterv1 .ReadyCondition )
124- msg := ""
125- reason := ""
126- state := "?"
127- if readyC != nil {
128- msg = readyC .Message
129- reason = readyC .Reason
130- state = string (readyC .Status )
131- }
132- ginkgo .By (" Ready Condition: " + state + " " + reason + " " + msg )
133- }
134- return nil
135- }
136-
13746// CaphClusterDeploymentSpec implements a test that verifies that MachineDeployment rolling updates are successful.
13847func CaphClusterDeploymentSpec (ctx context.Context , inputGetter func () CaphClusterDeploymentSpecInput ) {
13948 var (
@@ -164,7 +73,6 @@ func CaphClusterDeploymentSpec(ctx context.Context, inputGetter func() CaphClust
16473
16574 ginkgo .It ("Should successfully create a cluster with three control planes" , func () {
16675 ginkgo .By ("Creating a workload cluster" )
167- go logHCloudMachineStatusContinously (ctx , input .BootstrapClusterProxy .GetClient ())
16876 clusterctl .ApplyClusterTemplateAndWait (ctx , clusterctl.ApplyClusterTemplateAndWaitInput {
16977 ClusterProxy : input .BootstrapClusterProxy ,
17078 ConfigCluster : clusterctl.ConfigClusterInput {
0 commit comments