-
Notifications
You must be signed in to change notification settings - Fork 265
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: multisource support #636
feat: multisource support #636
Conversation
support Signed-off-by: David Vidal Villamide <[email protected]>
Signed-off-by: David Vidal Villamide <[email protected]>
Signed-off-by: David Vidal Villamide <[email protected]>
Signed-off-by: David Vidal Villamide <[email protected]>
fix: pointer management at getApplicationSource function Signed-off-by: David Vidal Villamide <[email protected]>
…files These changes intend to add support for write-back-method git on multisource applications based on Helm sources and value files as Helm does. Also we tried to keep the same coding patterns and the previous features and flows untouched. Signed-off-by: David Vidal Villamide <[email protected]>
Signed-off-by: David Vidal Villamide <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #636 +/- ##
==========================================
+ Coverage 65.35% 66.41% +1.06%
==========================================
Files 22 22
Lines 2084 2138 +54
==========================================
+ Hits 1362 1420 +58
+ Misses 588 587 -1
+ Partials 134 131 -3 ☔ View full report in Codecov by Sentry. |
Signed-off-by: David Vidal Villamide <[email protected]>
Signed-off-by: David Vidal Villamide <[email protected]>
Sorry I didn't notice that the coverage went down. I'll make the necessary changes to keep the coverage at the same rate. |
Signed-off-by: David Vidal Villamide <[email protected]>
I added some tests to raise the code coverage. Please, let me know if more changes are required in order to approve this PR. :) |
This is great stuff! Maybe @jannfis has the chance to look at it. I think many folks out there are quite desparately waiting for multi-source support. For us it would be a game-changer. |
This looks really promising ! We've been looking for this feature for months and hoping multi sources will be supported. This might not be the right place to ask but I cannot find any issue or PR concerning valuesObject support for helm source ? I tested with it a few months back but can't seem to make it work apparently with v2.8.x ArgoCD. Thank you @askhari for working on this anyway :) |
We're waiting for this PR to fix #558 too. Thank you! |
when can we expect this PR to be merged? we desperately need this for our development workflow. |
There is another issue which is worth pointing out: Image-updater will write correctly to the destination repo, however argocd will only pick up parameter files from the main repo. (In case you want to offload images to a separate repo which was our plan at first) |
Really need this for my use case! Greatly looking forward to the merge and release! Amazing work @askhari! |
…tion fix: set default values for image and tag parameters change: get application source type from Spec intead of Status values Signed-off-by: David Vidal Villamide <[email protected]>
@kvlxj , I also did not find anything related to the valuesObject. It would be helpful as well, but I don't think we should include that change in this PR. Maybe we may work on that and make a new PR. |
@atarax , when you pointed out that argocd will only pick up parameter files from the main repo, I think this only applies to the Parameters when they are written without using the "helmvalues" feature of this PR. Is that right? |
@askhari yes, and no :) it will work but it will break standard naming conventions. We only got it to work with something like:
but for most apps it's nested
|
Yup, you are more than right. We suffered ourselves that one. I used conflate library to easy the YAML and string manipulation to merge content because I'm not that good coding ^^U . I understand that it would be much better to indent in YAML. Honestly, right now I don't see a good way to solve that problem. In our case, we just assumed that the name of the parameter would be that one because it was easy to change in our environments. If it's a heavy issue for this to go on, I'll try to solve whenever I get some more time for it. In any case, thank you @atarax for pointing it out. It helps to improve :) |
@askhari sure, you're welcome! :) And btw, i think it would be way easier to solve on argocd side. I think the whole topic of multi-source application is not very well explored yet. But i could imagine maybe a property there to point argocd to the repo where it should take the parameter-files from or make it possible to have paramter-files from multiple repositories. |
@askhari - I couldn't get it to work 😞
Here's my values.yaml file that I think would relate:
the image is unable to find the
@atarax - you said you had some issues with the annotations - what finally fixed it for you? |
Yeah, I've got argocd upgraded to the latest version and changed up my Would really appreciate some suggestions. |
@devopsidiot , the error messages says that the docker image name is "test" instead of "testalias" (where it says "annotation for image test"). Usually, the name of the image is retrieved from the field "Status.Summary.Images" at the application manifest. If you use the "force-update" annotation, it also uses the image alias. Maybe this information will help you :). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Thank you so much for this awesome PR, @askhari!
Sorry for coming back so late to this one. I don't have anything to complain, this is a great quality contribution.
LGTM!
Thank you @jannfis! :) Hopefully this may help some people and I'm really happy about that. |
We have this, too。 I understand what you're saying about not finding the right image. However, the image alias is already configured in image-list. I understand that this image alias should be the base rule. Not anything else. |
for _, c := range images { | ||
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, c.ImageName) | ||
if helmAnnotationParamName == "" { | ||
return nil, fmt.Errorf("could not find an image-name annotation for image %s", c.ImageName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean's,that c.ImageName is mistake,not use image-list defined alias,may be use c.ImageAlias is right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I review more code,I found if you use like ContainerImage's normalizedSymbolicNam is good idea,If there are multiple layers of "/" in image, it is not legal to use the annotation name.There's no image list in this place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SamPeng87, afaik we could not use directly the "ImageAlias" because there are cases where it might be empty or people just do not use it.
The image list iterated in that "for" sentence is retrieved by the "GetImagesFromApplication" function, which builds a list using the name of each docker image found in the "app..Status.Summary.Images" (which is a structure that comes directly from ArgoCD) or using the "argocd-image-updater.argoproj.io/image-list" annotation.
As the "GetImagesFromApplication" was already used, I reused it to reproduce the same behavior.
Given that this happens only using the "helmvalues" method, it should not affect any other default behaviors of argocd-image-updater (at least I hope it won't affect).
I understand that we may improve this new feature to use "ImageAlias" whenever the annotations use an alias for the docker image. I'll note that and work on it later on.
Thank you very much for noticing it! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i don't set helmvalues in write-back-target then it is able to commit, it finds proper annotations and etc. But as soon as I set write-back-target and specify values.yaml it is failing with error: "Could not update application spec: could not find an image-name annotation for". Should we register a bug for that usecase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pavel-kurnosov , this is the same as @SamPeng87 noticed. I'll take a look into it when I have some more time.
If you want to open an issue I think it's ok, then we'll be able to reference it when pushing the PR to solve this.
Thank you!
Since this is merged now, any estimate on when we can expect a helm release with these changes? |
Honestly @dominicroessner, if it comes, it might be 1-6 months later. Even though this particular PR doesn't work with my use case and @askhari is going to iterate on some more stuff, I pulled this down and complied locally and pushed it to ECR and referenced that container in the helm chart. I'd suggest doing the same. |
Hi, @jannfis sorry to bother you, but can you please share the next release schedule which will include this and the other commits so far? Compiling a custom image is our best as @devopsidiot suggested? |
Any update on when this will be released? |
Same here, any update on when will it be released? |
I know multisource is still in beta but this is a really useful feature for our org. Would love to have this in the next release, any updates? |
Any update on when this will be released? please |
return v1alpha1.ApplicationSourceTypeKustomize | ||
} | ||
|
||
if app.Spec.HasMultipleSources() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces a regression. The old code would observe the app status which included computed fields for source type. The new code looks at the application spec which in our case does not have any of these fields defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if its related but we are using an ApplicationSet
where you simply pass the path, repoURL, etc: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Template/#template-fields. I'm not aware of any options to specify kustomize/helm specific things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to fix the issue for me.
// getApplicationSourceType returns the source type of the application
func getApplicationSourceType(app *v1alpha1.Application) v1alpha1.ApplicationSourceType {
if st, set := app.Annotations[common.WriteBackTargetAnnotation]; set &&
strings.HasPrefix(st, common.KustomizationPrefix) {
return v1alpha1.ApplicationSourceTypeKustomize
}
if app.Spec.HasMultipleSources() {
for _, st := range app.Status.SourceTypes {
if st == v1alpha1.ApplicationSourceTypeHelm {
return v1alpha1.ApplicationSourceTypeHelm
} else if st == v1alpha1.ApplicationSourceTypeKustomize {
return v1alpha1.ApplicationSourceTypeKustomize
} else if st == v1alpha1.ApplicationSourceTypePlugin {
return v1alpha1.ApplicationSourceTypePlugin
}
}
return v1alpha1.ApplicationSourceTypeDirectory
}
return app.Status.SourceType
}
* change: update argocd library from 2.7.9 to 2.8.4 for future multisource support Signed-off-by: David Vidal Villamide <[email protected]> * feat: added support for multisource applications. Signed-off-by: David Vidal Villamide <[email protected]> * feat: added multisource support to Git WriteBack method Signed-off-by: David Vidal Villamide <[email protected]> * changed: all Spec.Source references to enable multisource support Signed-off-by: David Vidal Villamide <[email protected]> * feat: added multisource support for write back method fix: pointer management at getApplicationSource function Signed-off-by: David Vidal Villamide <[email protected]> * feat: added write-back-target prefix to allow the use of values.yaml files These changes intend to add support for write-back-method git on multisource applications based on Helm sources and value files as Helm does. Also we tried to keep the same coding patterns and the previous features and flows untouched. Signed-off-by: David Vidal Villamide <[email protected]> * add: helmvalues word to expected dictionaries for check spelling tests Signed-off-by: David Vidal Villamide <[email protected]> * fix: readthedocs build.os parameter added and set to ubuntu-22.04 Signed-off-by: David Vidal Villamide <[email protected]> * fix: build.tools.python set to version 3.12 to create documentation Signed-off-by: David Vidal Villamide <[email protected]> * test: dded coverage for all the new code Signed-off-by: David Vidal Villamide <[email protected]> * fix: get image and tag parameter from getHelmParameterNamesFromAnnotation fix: set default values for image and tag parameters change: get application source type from Spec intead of Status values Signed-off-by: David Vidal Villamide <[email protected]> --------- Signed-off-by: David Vidal Villamide <[email protected]>
Works! I tested multi sources (0.13.0 image) argocd app updates and write back changes to git repo. Thanks @askhari and argocd image updater team! |
* change: update argocd library from 2.7.9 to 2.8.4 for future multisource support Signed-off-by: David Vidal Villamide <[email protected]> * feat: added support for multisource applications. Signed-off-by: David Vidal Villamide <[email protected]> * feat: added multisource support to Git WriteBack method Signed-off-by: David Vidal Villamide <[email protected]> * changed: all Spec.Source references to enable multisource support Signed-off-by: David Vidal Villamide <[email protected]> * feat: added multisource support for write back method fix: pointer management at getApplicationSource function Signed-off-by: David Vidal Villamide <[email protected]> * feat: added write-back-target prefix to allow the use of values.yaml files These changes intend to add support for write-back-method git on multisource applications based on Helm sources and value files as Helm does. Also we tried to keep the same coding patterns and the previous features and flows untouched. Signed-off-by: David Vidal Villamide <[email protected]> * add: helmvalues word to expected dictionaries for check spelling tests Signed-off-by: David Vidal Villamide <[email protected]> * fix: readthedocs build.os parameter added and set to ubuntu-22.04 Signed-off-by: David Vidal Villamide <[email protected]> * fix: build.tools.python set to version 3.12 to create documentation Signed-off-by: David Vidal Villamide <[email protected]> * test: dded coverage for all the new code Signed-off-by: David Vidal Villamide <[email protected]> * fix: get image and tag parameter from getHelmParameterNamesFromAnnotation fix: set default values for image and tag parameters change: get application source type from Spec intead of Status values Signed-off-by: David Vidal Villamide <[email protected]> --------- Signed-off-by: David Vidal Villamide <[email protected]>
How does Kustomize Support work? Having "kustomization" as git write-back-target does not work and putting "kustomization:/path/in/repo" does end in an crash loop of the application, as the error is not handled. |
It relates to PR #631 and includes the same changes as it's based on that code.
Also, this relates to the following issues:
This PR provides multisource support for git write back configurations on Helm application types.
Also it adds a new feature to provide a helm values file for the git write back. This makes it easier to keep value files up to date.
In order to use the Helm values feature, you'll need to provide a "helmvalues" prefix in the write-back-target header. You can take a look to the write-back-target documentation in this code to know how to configure it.
There are test for all the new code, they cover the most basic cases.
I tried to keep the same coding pattern and built the least invasive changes in the code flow.
Please give it a try and let's see if it can be merged. Any suggestions are more than welcome.