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

feat: add proof of concept implementation of argo image updater replacement #173

Merged
merged 29 commits into from
Aug 30, 2023

Conversation

shini4i
Copy link
Owner

@shini4i shini4i commented Aug 25, 2023

The changes in this PR introduces the following:

  • Added PoC implementation of argo image updater replacement
  • Minor code cleanup here and there

Backward compatibility is preserved.

A few points that should be covered in the further pull requests:

  • We should devise a more reasonable approach to validating tokens.
  • Add handling for potential git conflicts.
  • Increase test coverage.

I prefer to go with a multiple PR approach to simplify the review process.

It's important to note that certain portions of the code have been explicitly designed to ensure backward compatibility. Maintaining this compatibility is crucial for us, and any future modifications should consider this to avoid disruptions.

@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Merging #173 (1ffee91) into main (c4b3c99) will decrease coverage by 7.08%.
The diff coverage is 20.52%.

@@            Coverage Diff             @@
##             main     #173      +/-   ##
==========================================
- Coverage   49.53%   42.46%   -7.08%     
==========================================
  Files          15       16       +1     
  Lines         971     1227     +256     
==========================================
+ Hits          481      521      +40     
- Misses        435      647     +212     
- Partials       55       59       +4     
Files Changed Coverage Δ
cmd/argo-watcher/argo.go 73.84% <ø> (ø)
cmd/argo-watcher/config/config.go 83.33% <ø> (ø)
cmd/argo-watcher/router.go 0.00% <0.00%> (ø)
cmd/argo-watcher/server.go 15.68% <0.00%> (ø)
pkg/client/client.go 26.19% <10.00%> (-1.55%) ⬇️
pkg/updater/updater.go 13.63% <13.63%> (ø)
internal/models/argo.go 60.13% <20.28%> (-37.16%) ⬇️
cmd/argo-watcher/argo_status_updater.go 70.73% <47.50%> (-19.05%) ⬇️
cmd/argo-watcher/state/postgres_state.go 63.46% <100.00%> (ø)
internal/models/task.go 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@bozerkins bozerkins left a comment

Choose a reason for hiding this comment

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

First, thanks for doing this work. I had pleasure reading the changes, and I'm very excited about this functionality 🥳

A couple of high-level comments:

  1. I think the client should explicitly state that they want argo-watcher to search for annotations and perform git-commit deployment. Argo-watcher should explicitly fail when it tries to git-commit deploy but fails for any reason (no ssh key, no annotations, failed parsing yaml files, etc).
    This would eliminate magic that we'd want to avoid having in the deployments.
  2. I think git-commit deployment authentication should happen earlier in the process and should be a pass or fail scenario. If the user requested git-commit deployment but failed to provide authentication token - we fail the deployment.
  3. With deployments failing fast should be our go-to behavior. In case anything is wrong with the process - it should fail and provide full details as to why. This will make life easier for anyone who will be using the tool to debug why the deployment fails and fix the missing piece. There are many moving pieces in the deployment logic, so getting an explicit error in the API or argo-watcher UI is better than trying to search logs for answers.
  4. Codecov left lots of comments about missing tests. We should add those before final revision 🥼

The commit is quite big, so I haven't gone through the whole thing end to end (will take another, closer look in coming days).

cmd/argo-watcher/router.go Outdated Show resolved Hide resolved
pkg/client/client.go Outdated Show resolved Hide resolved
cmd/argo-watcher/router.go Outdated Show resolved Hide resolved
return nil, err
}

if app.IsManagedByWatcher() && task.Validated {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the token verification should happen in the router. In case the token is invalid, fail the API call. In case it's successful - continue the execution. And for git commit deployment identification in the code, I'd add a separate parameter, for example GitCommitEnabled, so that it's explicit what the client wants.

cmd/argo-watcher/argo_status_updater.go Show resolved Hide resolved
internal/models/argo.go Outdated Show resolved Hide resolved
internal/models/argo.go Show resolved Hide resolved
pkg/updater/updater.go Show resolved Hide resolved
pkg/updater/updater.go Show resolved Hide resolved
Status string `json:"status,omitempty"`
StatusReason string `json:"status_reason,omitempty"`
ProvidedToken string `json:"token,omitempty"`
Validated bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should replace this with GitCommitEnabled or some alternative, and received it from the client.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Why? We are validating whether we are proceeding with deployment on the server side.

@sonarcloud
Copy link

sonarcloud bot commented Aug 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@shini4i shini4i merged commit c121326 into main Aug 30, 2023
4 of 6 checks passed
@shini4i shini4i deleted the feat/image-updater-replacement-poc branch August 30, 2023 19:30
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.

2 participants