@@ -21,24 +21,14 @@ import (
21
21
"fmt"
22
22
"os"
23
23
"path/filepath"
24
- "strings"
25
- "time"
26
24
27
25
"github.com/onsi/ginkgo/v2"
28
26
"github.com/onsi/gomega"
29
- appsv1 "k8s.io/api/apps/v1"
30
27
corev1 "k8s.io/api/core/v1"
31
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32
28
"k8s.io/utils/ptr"
33
- clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
34
29
"sigs.k8s.io/cluster-api/test/framework"
35
30
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
36
31
"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"
42
32
)
43
33
44
34
// CaphClusterDeploymentSpecInput is the input for CaphClusterDeploymentSpec.
@@ -53,87 +43,6 @@ type CaphClusterDeploymentSpecInput struct {
53
43
ControlPlaneMachineCount int64
54
44
}
55
45
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
-
137
46
// CaphClusterDeploymentSpec implements a test that verifies that MachineDeployment rolling updates are successful.
138
47
func CaphClusterDeploymentSpec (ctx context.Context , inputGetter func () CaphClusterDeploymentSpecInput ) {
139
48
var (
@@ -164,7 +73,6 @@ func CaphClusterDeploymentSpec(ctx context.Context, inputGetter func() CaphClust
164
73
165
74
ginkgo .It ("Should successfully create a cluster with three control planes" , func () {
166
75
ginkgo .By ("Creating a workload cluster" )
167
- go logHCloudMachineStatusContinously (ctx , input .BootstrapClusterProxy .GetClient ())
168
76
clusterctl .ApplyClusterTemplateAndWait (ctx , clusterctl.ApplyClusterTemplateAndWaitInput {
169
77
ClusterProxy : input .BootstrapClusterProxy ,
170
78
ConfigCluster : clusterctl.ConfigClusterInput {
0 commit comments