@@ -12,17 +12,18 @@ import (
12
12
"k8s.io/klog/v2"
13
13
14
14
"github.com/openshift/insights-operator/pkg/authorizer"
15
+ apierrors "k8s.io/apimachinery/pkg/api/errors"
15
16
)
16
17
17
18
// Send uploads archives to Ingress service
18
19
func (c * Client ) Send (ctx context.Context , endpoint string , source Source ) error {
19
- cv , err := c .getClusterVersion ()
20
+ cv , err := c .GetClusterVersion ()
21
+ if apierrors .IsNotFound (err ) {
22
+ return ErrWaitingForVersion
23
+ }
20
24
if err != nil {
21
25
return err
22
26
}
23
- if cv == nil {
24
- return ErrWaitingForVersion
25
- }
26
27
27
28
req , err := c .prepareRequest (ctx , http .MethodPost , endpoint , cv )
28
29
if err != nil {
@@ -87,13 +88,13 @@ func (c *Client) Send(ctx context.Context, endpoint string, source Source) error
87
88
88
89
// RecvReport performs a request to Insights Results Smart Proxy endpoint
89
90
func (c * Client ) RecvReport (ctx context.Context , endpoint string ) (* http.Response , error ) {
90
- cv , err := c .getClusterVersion ()
91
+ cv , err := c .GetClusterVersion ()
92
+ if apierrors .IsNotFound (err ) {
93
+ return nil , ErrWaitingForVersion
94
+ }
91
95
if err != nil {
92
96
return nil , err
93
97
}
94
- if cv == nil {
95
- return nil , ErrWaitingForVersion
96
- }
97
98
98
99
endpoint = fmt .Sprintf (endpoint , cv .Spec .ClusterID )
99
100
klog .Infof ("Retrieving report for cluster: %s" , cv .Spec .ClusterID )
@@ -169,13 +170,13 @@ func (c *Client) RecvReport(ctx context.Context, endpoint string) (*http.Respons
169
170
}
170
171
171
172
func (c * Client ) RecvSCACerts (_ context.Context , endpoint string ) ([]byte , error ) {
172
- cv , err := c .getClusterVersion ()
173
+ cv , err := c .GetClusterVersion ()
174
+ if apierrors .IsNotFound (err ) {
175
+ return nil , ErrWaitingForVersion
176
+ }
173
177
if err != nil {
174
178
return nil , err
175
179
}
176
- if cv == nil {
177
- return nil , ErrWaitingForVersion
178
- }
179
180
token , err := c .authorizer .Token ()
180
181
if err != nil {
181
182
return nil , err
@@ -213,13 +214,13 @@ func (c *Client) RecvGatheringRules(ctx context.Context, endpoint string) ([]byt
213
214
klog .Infof (
214
215
`Preparing a request to Insights Operator Gathering Conditions Service at the endpoint "%v"` , endpoint ,
215
216
)
216
- cv , err := c .getClusterVersion ()
217
+ cv , err := c .GetClusterVersion ()
218
+ if apierrors .IsNotFound (err ) {
219
+ return nil , ErrWaitingForVersion
220
+ }
217
221
if err != nil {
218
222
return nil , err
219
223
}
220
- if cv == nil {
221
- return nil , ErrWaitingForVersion
222
- }
223
224
224
225
req , err := c .prepareRequest (ctx , http .MethodGet , endpoint , cv )
225
226
if err != nil {
@@ -251,13 +252,13 @@ func (c *Client) RecvGatheringRules(ctx context.Context, endpoint string) ([]byt
251
252
// It is a HTTP GET request with the `search` query parameter limiting the result
252
253
// only for the one cluster and only for the `accepted` cluster transfers.
253
254
func (c * Client ) RecvClusterTransfer (endpoint string ) ([]byte , error ) {
254
- cv , err := c .getClusterVersion ()
255
+ cv , err := c .GetClusterVersion ()
256
+ if apierrors .IsNotFound (err ) {
257
+ return nil , ErrWaitingForVersion
258
+ }
255
259
if err != nil {
256
260
return nil , err
257
261
}
258
- if cv == nil {
259
- return nil , ErrWaitingForVersion
260
- }
261
262
token , err := c .authorizer .Token ()
262
263
if err != nil {
263
264
return nil , err
0 commit comments