Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Add detailed error message in fluxctl sync #2765

Merged

Conversation

dinosk
Copy link

@dinosk dinosk commented Jan 19, 2020

  • Extends v6.GitConfig to include Error field.

  • In case of fluxctl sync error, prints the Error field
    in the output.

Closes #2657

Signed-off-by: Dinos Kousidis dinkousidis@gmail.com

@@ -58,6 +58,7 @@ type GitConfig struct {
Remote GitRemoteConfig `json:"remote"`
PublicSSHKey ssh.PublicKey `json:"publicSSHKey"`
Status git.GitRepoStatus `json:"status"`
Error string `json:"errors"`
Copy link
Contributor

@2opremio 2opremio Jan 19, 2020

Choose a reason for hiding this comment

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

This will break backwards compatibility with clients using the v6 endpoint.

You would need to bump the API version to extend it. But, even then, I am not sure that's the best place for the error (to be fair I don't think that the status should be part of the config either, bit that's how it is).

Copy link
Author

Choose a reason for hiding this comment

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

Ah right, thank you for reviewing.
I can think of making git.GitRepoStatus a map containing the Error, or adding another endpoint for the repo status?

Copy link
Contributor

Choose a reason for hiding this comment

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

After taking a look at it, adding the error is probably OK but you should add a new version of the data structure and a new version of the endpoint (which will, in turn, require bumping the latest version of the API)

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I will update the PR

Copy link
Member

Choose a reason for hiding this comment

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

Since the Error field is optional, I don't think just adding it to the v6 API response breaks backward-compatibility. A way to reason about it is to do the matrix of old version / new version and see if mismatches will cause a problem.

In the following table, "Old" means "does not know about the Error field" and "New" means "expects to use the Error field".

Old fluxd New fluxd
Old fluxctl Operates as now Will not deserialise Error field, and thereby operate as now
New fluxctl Can act conditionally on presence of Error field Operates as desired

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I think that's fine :) , @dinosk is (rightfully) going to hate me for it though.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry @dinosk! Blame me, I'm the trouble-maker.

So: to be clear, let's go back to how you initially had it, with an Error field added to v6.GitConfig, and that field being used if present in cmd/fluxctl/sync_cmd.go.

Copy link
Author

Choose a reason for hiding this comment

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

😅 it is no problem! I see your point, I’ll revert it to the initial changes

Copy link
Author

Choose a reason for hiding this comment

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

makes backup of new api version
Ok, this is back to the initial changes

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for being so understanding!

@dinosk dinosk force-pushed the issues/2657-fluxctl-sync-error-message branch 10 times, most recently from 2efb502 to c61ec9f Compare January 26, 2020 14:24
@dinosk dinosk changed the title [WIP] Add detailed error message in fluxctl sync Add detailed error message in fluxctl sync Jan 26, 2020
@dinosk dinosk force-pushed the issues/2657-fluxctl-sync-error-message branch 2 times, most recently from f5a7e36 to 1c904e9 Compare January 26, 2020 22:07
@2opremio 2opremio requested a review from squaremo January 27, 2020 12:14
@2opremio
Copy link
Contributor

Thanks! I would like @squaremo to also have a look

In the meantime, can you fix the failing test? I thought it was a transient CI error, but it fails systematically

@dinosk dinosk force-pushed the issues/2657-fluxctl-sync-error-message branch 3 times, most recently from f628b49 to f9e7fd3 Compare January 27, 2020 19:31
@dinosk
Copy link
Author

dinosk commented Jan 28, 2020

Tests are fixed, let me know if I should add sth else!

* Extends v6.GitConfig to include `Error` field.

* In case of `fluxctl sync` error, prints the `Error` field
  in the output.

Signed-off-by: Dinos Kousidis <dinkousidis@gmail.com>
@dinosk dinosk force-pushed the issues/2657-fluxctl-sync-error-message branch from f9e7fd3 to f42ab00 Compare January 28, 2020 21:18
@2opremio 2opremio merged commit ed1f54f into fluxcd:master Jan 29, 2020
@dinosk dinosk deleted the issues/2657-fluxctl-sync-error-message branch January 29, 2020 10:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve fluxctl sync error when Flux cannot clone the git repository
3 participants