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(application-controller): Add support for rollback multi-source applications #14124

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

JorTurFer
Copy link
Contributor

@JorTurFer JorTurFer commented Jun 19, 2023

Signed-off-by: Jorge Turrado jorge.turrado@scrm.lidl

Currently, ArgoCD support multi-source applications and that's a really nice feature, but using multi source, end users have to sacrify the option of executing fast rollbacks because the rollbacks are not supported for multi-source applications.
This PR adds the support for rollback multi-source applications (as single source applications do)

Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates? (I don't think so, does it?)
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

Please see Contribution FAQs if you have questions about your pull-request.

Fixes #12580

@JorTurFer JorTurFer changed the title enable buttons and support multiversion in details feat(application-controller): Add support for rollback multi-source applications using the UI Jun 19, 2023
@JorTurFer JorTurFer force-pushed the multi-source-history-rollback branch from fd30f30 to b2d284b Compare June 20, 2023 16:34
@JorTurFer JorTurFer marked this pull request as ready for review June 22, 2023 16:29
@JorTurFer JorTurFer marked this pull request as draft June 22, 2023 16:46
@JorTurFer JorTurFer marked this pull request as ready for review June 22, 2023 21:45
@codecov
Copy link

codecov bot commented Jun 22, 2023

Codecov Report

Attention: Patch coverage is 72.97297% with 50 lines in your changes are missing coverage. Please review.

Project coverage is 49.90%. Comparing base (f87897c) to head (a1acb31).
Report is 43 commits behind head on master.

Files Patch % Lines
server/application/application.go 62.33% 22 Missing and 7 partials ⚠️
controller/sync.go 66.66% 3 Missing and 3 partials ⚠️
pkg/apis/application/v1alpha1/types.go 0.00% 4 Missing ⚠️
util/webhook/webhook.go 0.00% 4 Missing ⚠️
util/argo/ref_sources.go 90.90% 2 Missing and 1 partial ⚠️
cmd/argocd/commands/app.go 0.00% 0 Missing and 2 partials ⚠️
server/repository/repository.go 92.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14124      +/-   ##
==========================================
+ Coverage   49.73%   49.90%   +0.17%     
==========================================
  Files         274      275       +1     
  Lines       48948    49331     +383     
==========================================
+ Hits        24343    24621     +278     
- Misses      22230    22310      +80     
- Partials     2375     2400      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JorTurFer
Copy link
Contributor Author

JorTurFer commented Jun 22, 2023

Please, put special attention reviewing the frontend because I'm not frontend developer and maybe I have done something terriblely wrong

@JorTurFer
Copy link
Contributor Author

This is how it looks in the frontend:
image

image

@JorTurFer JorTurFer changed the title feat(application-controller): Add support for rollback multi-source applications using the UI feat(application-controller): Add support for rollback multi-source applications Jun 30, 2023
@ownyrd
Copy link

ownyrd commented Jul 3, 2023

Thanks for implementing this. Hope it gets merged soon :)

@crenshaw-dev
Copy link
Collaborator

Thanks for the PR! We're past feature freeze for 2.8, so I'll queue this up for the 2.9 roadmap.

@JorTurFer
Copy link
Contributor Author

Thanks for the PR! We're past feature freeze for 2.8, so I'll queue this up for the 2.9 roadmap.

Sure 😄
Do you have any ETA for reviewing the PR? No rush at all, it's just for fixing merge conflicts when you are going to review it to not be rebasing it all the time xD

@crenshaw-dev
Copy link
Collaborator

Makes sense! At least 3 weeks out, I'm focusing on getting 2.8 ready for GA for now.

@JorTurFer
Copy link
Contributor Author

JorTurFer commented Jul 18, 2023

Makes sense! At least 3 weeks out, I'm focusing on getting 2.8 ready for GA for now.

After vacations (I'll take them the first half of August so during second half) looks as a nice moment to rebase the PR with latest changes 😄
Thanks for the info 🙇

@kewei5zhang
Copy link

Hoping to have this merged soon. 🙏

@JorTurFer
Copy link
Contributor Author

Hi @crenshaw-dev
Is it now a good moment to rebase my PR? 😄

Copy link
Collaborator

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Only had time for a quick glance, opened one can of worms. :-)

reposerver/repository/repository.proto Outdated Show resolved Hide resolved
@JorTurFer JorTurFer force-pushed the multi-source-history-rollback branch from fadc943 to 99e0b80 Compare August 17, 2023 14:16
@JorTurFer
Copy link
Contributor Author

Sorry, I needed more time that I expected for rebasing the PR 🤦 (the summer break has erased my memory 100%)

@JorTurFer
Copy link
Contributor Author

I have removed the logic from here and I have moved it into the state

@Pehesi97
Copy link

Any news on this? Do you guys need an extra pair of hands?

@JorTurFer
Copy link
Contributor Author

Any news on this? Do you guys need an extra pair of hands?

It's waiting a review 😄

@crenshaw-dev
Copy link
Collaborator

@Pehesi97 we need lots of extra pairs of hands. 😆

@GuerreiroLeonardo
Copy link

Any predictions on when it will be released?

@JorTurFer
Copy link
Contributor Author

@GuerreiroLeonardo , if you could help them reviewing the code, I think this will be faster for sure 😄
I guess that we are a bit overloaded atm with the summer break and the last release

@GuerreiroLeonardo
Copy link

GuerreiroLeonardo commented Sep 6, 2023

@GuerreiroLeonardo , if you could help them reviewing the code, I think this will be faster for sure 😄 I guess that we are a bit overloaded atm with the summer break and the last release

@JorTurFer JorTurFer I wish I could, I have no knowledge on the argoCD code. I am simply a user right now hahah. I gues it would take a lot of hours until I am proficient enough to give any relevant contribution. Sorry =/
I guess maybe crenshaw-dev could help

@gioppoluca
Copy link

We also consider this PR important, do not have to capabilities to look at the code, but could test it once it gets released.

Copy link
Member

@jsoref jsoref left a comment

Choose a reason for hiding this comment

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

I'd want to see:

Note that I'm not wearing a project owner hat, this what I'd want as a drive-by reviewer / UI person / end user.

}

// GetRefSources creates a map of ref keys (from the sources' 'ref' fields) to information about the referenced source.
// This function also validates the references use allowed characters and does not define the same ref key more than
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// This function also validates the references use allowed characters and does not define the same ref key more than
// This function also validates the references use allowed characters and do not define the same ref key more than

Choose a reason for hiding this comment

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

Is a spelling error on a comment a good reason to ask for a review on such a feature? Seems a good way to make contributors stop contributing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took the code from argo.go and I moved it as it was and i didn't notice it. I'll update it 😄

}
refKey := "$" + source.Ref
if _, ok := refKeys[refKey]; ok {
return nil, fmt.Errorf("invalid sources: multiple sources had the same `ref` key")
Copy link
Member

Choose a reason for hiding this comment

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

it'd be really nice if errors like this reported at least a pair of sources so that users have something to chase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took the code from argo.go and I moved it as it is but I could add the key to the message if you think is useful

Copy link
Member

Choose a reason for hiding this comment

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

My goal is to be able to read a message and figure out how to address it. If this error will be shown as is, I'd want to see the id of the thing (is it an application/<x>?) and two sources that had the same ref (preferably with the ref). If it's going to be pasted w/ other things, then as long as once it's pasted it has those bits, that'd make it usable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd try to improve the message 😄
I'll review the logic trying to figure out the best way to print the message

@jsoref
Copy link
Member

jsoref commented Sep 26, 2023

In:

Why do I see the same revision twice?

If I can't kick the tires, could you at please kick the tires for me?

User Story:

  1. User has a "multi-source application" (some sample content for me to look at)
  2. User deploys it (show picture of screens)
  3. User makes a change (?) (show change, picture of how things change)
  4. User needs to trigger a rollback (show path through UI that user takes to trigger it)
  5. User sees rollback complete (show how the UI looks)
  6. User wants to review to see what rollback(s) have happened (show path through UI for this).

@JorTurFer
Copy link
Contributor Author

JorTurFer commented Sep 26, 2023

design doc
user facing documentation
a ui demo (so I can kick the tires) -- the picture in #14124 (comment) should be in the description.

Hi @jsoref
I appreciate your feedback but you couldn't see those things just because the PR template doesn't require them and I'm new contributing to this project.
I followed it and I have tried to do my best, but based on the documentation I had, those things weren't required. If you point me to any doc about how can I provide the UI demo, I'd be more than happy providing it. I'd really appreciate any guide on that part because I'm totally lost in front side.

About the user documentation, the UX is the same because I haven't added any new interaction, I just enabled an already existing button.

Why do I see the same revision twice?

Because probably I used the same repository for both sources, sorry. I didn't think that it was important.

If I can't kick the tires, could you at please kick the tires for me?

Except for how the multiple sources are presented, all the other points are exactly the same as the current scenario. It's true that I added the extra sources information to the UI (using the parenthesis), but I can remove it if you think that it's wrong.

// In case of rollback, this function also updates the targetRevision to the proper revision
func GetRefSources(ctx context.Context, opts GetRefSourcesOptions) (argoappv1.RefTargetRevisionMapping, error) {
refSources := make(argoappv1.RefTargetRevisionMapping)
if len(opts.Sources) > 1 {
Copy link
Member

Choose a reason for hiding this comment

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

We can avoid the check len(opts.Sources) > 1 as the loop would not be executed if opts.Sources is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but you still can have 1 single item in sources slides, that's the reason. Originally this func received the app itself and checked if spec.HasMultipleSources() and this is the closer option.

I can remove it if you still think that it's not required

Copy link
Member

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

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

While testing the feature out, it seems, the application is not able to handle rollback from source to sources field or vice versa. To reproduce,

  1. Create a single multi-source application
  2. Update the application to be of a single source, i.e. remove spec.sources and add spec.source.
  3. Try rolling back to the previous version. It does not rollback the app to spec.sources.

@JorTurFer
Copy link
Contributor Author

While testing the feature out, it seems, the application is not able to handle rollback from source to sources field or vice versa. To reproduce,

yeah, I didn't support changing between both because I thought that it wasn't an scenario, but I can check and try to extend the PR to support it too, let me check it. Do the other changes work as expected?

JorTurFer and others added 12 commits April 14, 2024 23:07
…pplications

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Co-authored-by: Ishita Sequeira <46771830+ishitasequeira@users.noreply.github.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
@JorTurFer JorTurFer force-pushed the multi-source-history-rollback branch from 867fbcc to 6203cbf Compare April 14, 2024 21:28
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Contributor Author

@ishitasequeira , I've updated the PR supporting changes between single source and multi source. PTAL when you have some time.
I've also rebased my branch because there was a merge conflict related with a self generated file

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Contributor Author

I'm not sure why the docker image is not built well, but I'd say that it's not related with my changes due to the message:

ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install --no-install-recommends -y     openssh-server     nginx     unzip     fcgiwrap     git     git-lfs     make     wget     gcc     sudo     zip &&     apt-get clean &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*" did not complete successfully: exit code: 100

}}
details={details}
/>
<div className='row'>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm working on adding the multi-source support in what is currently the Parameters tab. For example, see PR. This is part of the proposal to support multi-source apps in the UI here, which references your PR. In order to better distinguish between the sources, I thought that showing the index within the sources field would help. So around this area, what do you think about adding a title here, something like what is depicted in my screenshots. It could be as simple as showing Source {i+1}

On a separate note, I made the current Edit card a collapsible section, and this is something 'new' to the UI. If there are many sources, and the list of parameters can get really long, it could get unwieldy and difficult to use. What you have here is fine as is, since the info is read-only. In order to get your PR merged, I think we could make these rows collapsible in a future PR (in order to align the multi-source presentation).

value: (
<Revision
repoUrl={utils.getAppDefaultSource(application).repoURL}
revision={utils.getAppDefaultSyncRevision(application) + utils.getAppDefaultSyncRevisionExtra(application)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if the extra part should be part of the revision field value, which might be included as part of the hyperlink

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to follow up on this, the link is 'broken' because the 'and (1) more' phrase is included

revisionLink

<i className='fa fa-ellipsis-h' />
</button>
)}
{onClick && <button className='application-status-panel__more-button' />}
Copy link
Contributor

Choose a reason for hiding this comment

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

There was a 'More' button here before Ishita disabled it. Is this the new intended behavior?

@@ -93,7 +93,15 @@ export const ApplicationOperationState: React.StatelessComponent<Props> = ({appl
});
}
if (operationState.syncResult) {
operationAttributes.push({title: 'REVISION', value: <Revision repoUrl={utils.getAppDefaultSource(application).repoURL} revision={operationState.syncResult.revision} />});
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously, the revision value wouldn't be displayed until the operation has finished. Seems like in this new behavior, the revision represents the most recent, successfully synced revision, and therefore will always show here, even if the operation is in progress. Is this the intended design? Is the if check on syncResult needed?

@@ -107,13 +102,14 @@ export const ApplicationStatusPanel = ({application, showDiff, showOperation, sh
<div className='application-status-panel__item-name' style={{marginBottom: '0.5em'}}>
{application.spec.syncPolicy?.automated ? 'Auto sync is enabled.' : 'Auto sync is not enabled.'}
</div>
{application.status && application.status.sync && application.status.sync.revision && !application.spec.source.chart && (
{application.status && application.status.sync && application.status.sync.revision && revision && !application.spec.source.chart && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Could application.status.sync.revision && revision be simplified to just revision?

<div className='application-status-panel__item-name' style={{marginBottom: '0.5em'}}>
{appOperationState.phase} <Timestamp date={appOperationState.finishedAt || appOperationState.startedAt} />
</div>
{(appOperationState.syncResult && appOperationState.syncResult.revision && (
{(appOperationState.syncResult && revision && (
Copy link
Contributor

Choose a reason for hiding this comment

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

See my other comment regarding the operation sync result

@ishitasequeira
Copy link
Member

I'm not sure why the docker image is not built well, but I'd say that it's not related with my changes due to the message:

ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install --no-install-recommends -y     openssh-server     nginx     unzip     fcgiwrap     git     git-lfs     make     wget     gcc     sudo     zip &&     apt-get clean &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*" did not complete successfully: exit code: 100

Thanks @JorTurFer for updating the PR with the use-case. It seems to be working now. The issue you mentioned has been fixed in master. Once you rebase your PR, the issue should get resolved.

@GuerreiroLeonardo
Copy link

GuerreiroLeonardo commented Apr 25, 2024

Hi @JorTurFer any idea when you're gonna be able to look into these issues?

@JorTurFer
Copy link
Contributor Author

JorTurFer commented Apr 28, 2024

I really appreciate the feedback @keithchong! Sadly, I don't have enough time nowadays to address it, there have been a lot of changes in the UI since I checked it time ago and I'm not frontend developer, so understand the UI requires a huge time to me. As the backend is almost ready, and it works, would be you willing to be invited to my repo and help me with those changes directly there (I've already invited you, just in case)? I feel that you have more context about how the things have to be done in front side. This offer is extensible to any other contributor who is willing to do it, I don't have problems adding them to my fork.

I see that you have pushed the UI proposal (btw, it looks nice, congrats!) and maybe you can adapt current UI to that proposal.

Other option can be just reverting all the UI changes and keep only the backend + cli support. Any other folk can continue from there on their own fork without all the (probably terrible) decisions that I took in front. @ishitasequeira ?

And sorry again, we are in the middle of a hard project and I don't think that I can solve the front issues soon 😞

@keithchong
Copy link
Contributor

Hi @JorTurFer , reverting or taking away your UI changes might be a bit extreme. I'll see if I can fix the link issue and any other 'straight-forward' issues. For the other concerns, I think we should open follow-on Issues and address them in separate PRs, hopefully for the next release. Aligning the look and feel and adding back the 'More' button should not be blocking your PR. IMO, from the issues I saw, the incorrect status for the sync operation in progress is probably higher priority, because it is misleading information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review (Due by 2023-3-20)
Development

Successfully merging this pull request may close these issues.

Support for rollback in multiple sources