Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First attempt at adding a fallback option which queries graphQL should the http request fail with status 404 #915

Merged

Conversation

elliotforbes
Copy link
Contributor

@elliotforbes elliotforbes commented Apr 20, 2023

Checklist

=========

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked for similar issues and haven't found anything relevant.
  • This is not a security issue (which should be reported here: https://circleci.com/security/)
  • I have read Contribution Guidelines.

Internal Checklist

  • I am requesting a review from my own team as well as the owning team
  • I have a plan in place for the monitoring of the changes that I am making (this can include new monitors, logs to be aware of, etc...)

Changes

=======

  • Adds the legacy graphQL ConfigQuery path back to the code. Whenever the first, preferred path, fails with a 404 status code, we then default back to the graphQL resolver such that there is no need for customers to pin to a current version as it stands.

Rationale

=========

The decision to opt for pinned versions of the CLI has caused some customer impact and as such, we've opted to change tact such that the config process and validate commands run the new path first and fail back to the legacy path.

Considerations

==============

We're working through testing this now with server 3 and server 4 customers.

@elliotforbes elliotforbes requested a review from a team as a code owner April 20, 2023 12:48
@rrakin rrakin requested a review from a team April 20, 2023 13:25
@@ -98,7 +98,6 @@ func (c *Client) DoRequest(req *http.Request, resp interface{}) (statusCode int,
}{}
err = json.NewDecoder(httpResp.Body).Decode(&httpError)
if err != nil {
fmt.Printf("failed to decode body: %s", err.Error())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been deliberately removed to reduce noise when the fallback legacy path is used for config compilation and validation.

assert.Error(t, err)
assert.Contains(t, err.Error(), "this version of the CLI does not support your instance of server")
})
// commenting this out - we have a legacy_test.go unit test that covers this behaviour
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deliberately commented out for now until we opt for the pinning model.

if statusCode == 404 {
return nil, errors.New("this version of the CLI does not support your instance of server, please refer to https://github.com/CircleCI-Public/circleci-cli for version compatibility")
statusCode, originalErr := c.compileRestClient.DoRequest(req, configCompilationResp)
if statusCode == 404 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the statusCode returned from the request is 404, we want to then attempt to call the legacy GraphQL resolver path.

@elliotforbes elliotforbes force-pushed the adding-fallback-config-compilation-and-validation-option branch 3 times, most recently from d2dc832 to 13246b2 Compare April 20, 2023 15:14
…es and the CLI I've created a more in-depth version compatibility matrix
@JulesFaucherre JulesFaucherre force-pushed the adding-fallback-config-compilation-and-validation-option branch from 9bbb5f5 to d74f84e Compare April 20, 2023 15:32
config/config_test.go Show resolved Hide resolved
@elliotforbes elliotforbes force-pushed the adding-fallback-config-compilation-and-validation-option branch from d74f84e to 7d09d97 Compare April 20, 2023 16:28
@elliotforbes elliotforbes merged commit bb4b53d into develop Apr 20, 2023
@elliotforbes elliotforbes deleted the adding-fallback-config-compilation-and-validation-option branch April 20, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants