@@ -127,23 +127,25 @@ func (m *MqttTunnel) Start(ctx context.Context, clientID, env string) (err error
127127 }
128128
129129 go func () {
130- m .Cache .WaitForCacheSync (ctx )
131- vkUtils .TimedTaskWithInterval (ctx , time .Minute , func (ctx context.Context ) {
132- nodeList := corev1.NodeList {}
133- envRequirement , _ := labels .NewRequirement (vkModel .LabelKeyOfEnv , selection .In , []string {m .env })
134- componentRequirement , _ := labels .NewRequirement (vkModel .LabelKeyOfComponent , selection .In , []string {vkModel .ComponentVNode })
135- m .Client .List (ctx , & nodeList , & client.ListOptions {
136- LabelSelector : labels .NewSelector ().Add (* envRequirement , * componentRequirement ),
137- })
138- for _ , node := range nodeList .Items {
139- for _ , condition := range node .Status .Conditions {
140- if condition .Type == corev1 .NodeReady && condition .Status != corev1 .ConditionTrue {
141- // base not ready, delete from api server
142- m .Client .Delete (ctx , & node )
130+ if m .Cache != nil {
131+ m .Cache .WaitForCacheSync (ctx )
132+ vkUtils .TimedTaskWithInterval (ctx , time .Minute , func (ctx context.Context ) {
133+ nodeList := corev1.NodeList {}
134+ envRequirement , _ := labels .NewRequirement (vkModel .LabelKeyOfEnv , selection .In , []string {m .env })
135+ componentRequirement , _ := labels .NewRequirement (vkModel .LabelKeyOfComponent , selection .In , []string {vkModel .ComponentVNode })
136+ m .Client .List (ctx , & nodeList , & client.ListOptions {
137+ LabelSelector : labels .NewSelector ().Add (* envRequirement , * componentRequirement ),
138+ })
139+ for _ , node := range nodeList .Items {
140+ for _ , condition := range node .Status .Conditions {
141+ if condition .Type == corev1 .NodeReady && condition .Status != corev1 .ConditionTrue {
142+ // base not ready, delete from api server
143+ m .Client .Delete (ctx , & node )
144+ }
143145 }
144146 }
145- }
146- })
147+ })
148+ }
147149 }()
148150
149151 go func () {
0 commit comments