File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -137,8 +137,14 @@ func (c *Client) Run(ctx context.Context) {
137137
138138 if err != nil {
139139 if isPermissionDenied (err ) {
140- log .Debug ().Msg ("cloud account does not have pro plan, stopping cloud client" )
141- return
140+ log .Debug ().Msg ("cloud account does not have pro plan, waiting for upgrade" )
141+ select {
142+ case <- ctx .Done ():
143+ return
144+ case <- c .startCh :
145+ }
146+ backoff = initialBackoff
147+ continue
142148 }
143149 if isUnauthenticated (err ) {
144150 log .Warn ().Err (err ).Dur ("pause" , unauthenticatedPause ).Msg ("invalid API key, pausing before retry" )
Original file line number Diff line number Diff line change @@ -150,13 +150,27 @@ func (h *handler) cloudStatus(w http.ResponseWriter, r *http.Request) {
150150 return
151151 }
152152
153- if h .config .OnCloudSetup != nil {
154- h .config .OnCloudSetup ()
153+ body , err := io .ReadAll (resp .Body )
154+ if err != nil {
155+ log .Error ().Err (err ).Msg ("Failed to read cloud status response" )
156+ writeError (w , http .StatusBadGateway , "failed to read cloud status" )
157+ return
158+ }
159+
160+ var statusResp struct {
161+ Plan struct {
162+ Name string `json:"name"`
163+ } `json:"plan"`
164+ }
165+ if json .Unmarshal (body , & statusResp ) == nil && statusResp .Plan .Name == "pro" {
166+ if h .config .OnCloudSetup != nil {
167+ h .config .OnCloudSetup ()
168+ }
155169 }
156170
157171 w .Header ().Set ("Content-Type" , "application/json" )
158172 w .WriteHeader (http .StatusOK )
159- io . Copy ( w , resp . Body )
173+ w . Write ( body )
160174}
161175
162176type cloudConfigResponse struct {
You can’t perform that action at this time.
0 commit comments