@@ -12,17 +12,18 @@ import (
1212 "k8s.io/klog/v2"
1313
1414 "github.com/openshift/insights-operator/pkg/authorizer"
15+ apierrors "k8s.io/apimachinery/pkg/api/errors"
1516)
1617
1718// Send uploads archives to Ingress service
1819func (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+ }
2024 if err != nil {
2125 return err
2226 }
23- if cv == nil {
24- return ErrWaitingForVersion
25- }
2627
2728 req , err := c .prepareRequest (ctx , http .MethodPost , endpoint , cv )
2829 if err != nil {
@@ -87,13 +88,13 @@ func (c *Client) Send(ctx context.Context, endpoint string, source Source) error
8788
8889// RecvReport performs a request to Insights Results Smart Proxy endpoint
8990func (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+ }
9195 if err != nil {
9296 return nil , err
9397 }
94- if cv == nil {
95- return nil , ErrWaitingForVersion
96- }
9798
9899 endpoint = fmt .Sprintf (endpoint , cv .Spec .ClusterID )
99100 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
169170}
170171
171172func (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+ }
173177 if err != nil {
174178 return nil , err
175179 }
176- if cv == nil {
177- return nil , ErrWaitingForVersion
178- }
179180 token , err := c .authorizer .Token ()
180181 if err != nil {
181182 return nil , err
@@ -213,13 +214,13 @@ func (c *Client) RecvGatheringRules(ctx context.Context, endpoint string) ([]byt
213214 klog .Infof (
214215 `Preparing a request to Insights Operator Gathering Conditions Service at the endpoint "%v"` , endpoint ,
215216 )
216- cv , err := c .getClusterVersion ()
217+ cv , err := c .GetClusterVersion ()
218+ if apierrors .IsNotFound (err ) {
219+ return nil , ErrWaitingForVersion
220+ }
217221 if err != nil {
218222 return nil , err
219223 }
220- if cv == nil {
221- return nil , ErrWaitingForVersion
222- }
223224
224225 req , err := c .prepareRequest (ctx , http .MethodGet , endpoint , cv )
225226 if err != nil {
@@ -251,13 +252,13 @@ func (c *Client) RecvGatheringRules(ctx context.Context, endpoint string) ([]byt
251252// It is a HTTP GET request with the `search` query parameter limiting the result
252253// only for the one cluster and only for the `accepted` cluster transfers.
253254func (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+ }
255259 if err != nil {
256260 return nil , err
257261 }
258- if cv == nil {
259- return nil , ErrWaitingForVersion
260- }
261262 token , err := c .authorizer .Token ()
262263 if err != nil {
263264 return nil , err
0 commit comments