Skip to content

Commit 305ee3b

Browse files
crenshaw-devishitasequeira
authored andcommitted
fix nil reference and key mismatch bugs; add more logs (argoproj#6)
* fix nil reference and key mismatch bugs; add more logs * remove temporary comment * addressed the lint failure and added chart to RefTargeRevisionMapping * normalize git repo (argoproj#7) * do not leak lock releases * prevent deadlock * allow spec update * move settings fetch outside loop * cache busing * return err instead of logging it * no caching in test * fix cache key marshaling Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Rebase with master Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
1 parent d1e624d commit 305ee3b

File tree

20 files changed

+857
-1049
lines changed

20 files changed

+857
-1049
lines changed

controller/state.go

+3-16
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,9 @@ func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, sources []v1alp
168168
targetObjs := make([]*unstructured.Unstructured, 0)
169169

170170
// Store the map of all sources having ref field into a map for applications with sources field
171-
refSources := make(map[string]*appv1.RefTargeRevisionMapping)
172-
if app.Spec.HasMultipleSources() {
173-
// Get Repositories for all sources before generating Manifests
174-
for _, source := range sources {
175-
if source.Ref != "" {
176-
repo, err := m.db.GetRepository(context.Background(), source.RepoURL)
177-
if err != nil {
178-
return nil, nil, err
179-
}
180-
refKey := "$" + source.Ref
181-
refSources[refKey] = &appv1.RefTargeRevisionMapping{
182-
Repo: *repo,
183-
TargetRevision: source.TargetRevision,
184-
}
185-
}
186-
}
171+
refSources, err := argo.GetRefSources(context.Background(), app.Spec, m.db)
172+
if err != nil {
173+
return nil, nil, fmt.Errorf("failed to get ref sources: %v", err)
187174
}
188175

189176
for i, source := range sources {

docs/user-guide/multiple_sources.md

+21-25
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Multiple Sources for an Application
22

3-
Argo CD has the ability to specify multiple sources to add services to the Application. Argo CD compiles all the sources and reconciles each source individually for creating the application.
3+
Argo CD has the ability to specify multiple sources to add services to the Application. Argo CD compiles all the sources
4+
and reconciles each source individually for creating the application.
45

5-
You can provide multiple sources using the `sources` field. When you specify the sources field, Argo CD will ignore the values under `source` field for generating the application.
6+
You can provide multiple sources using the `sources` field. When you specify the `sources` field, Argo CD will ignore
7+
the `source` (singular) field when generating manifests for the application.
68

7-
See below example for specifying multiple sources:
9+
See the below example for specifying multiple sources:
810

911
```yaml
1012
apiVersion: argoproj.io/v1alpha1
@@ -25,41 +27,35 @@ spec:
2527
namespace: argocd
2628
sources:
2729
- chart: elasticsearch
28-
helm:
29-
valueFiles:
30-
- values.yaml
3130
repoURL: https://helm.elastic.co
3231
targetRevision: 7.6.0
3332
- repoURL: https://github.com/argoproj/argocd-example-apps.git
3433
path: guestbook
3534
targetRevision: HEAD
3635
```
3736
38-
The above example has 2 sources specified. Argo CD will reconcile each source separately and combine the resources that are generated for generating the application.
37+
The above example has two sources specified. Argo CD will generate the manifests for each source separately and combine
38+
the resulting manifests.
3939
40-
In case application has multiple entries for the same source (repoURL), Argo CD would pick the source that is mentioned later in the list of sources. For example, consider the below list of sources:
40+
In case an application has multiple entries for the same source (repoURL), Argo CD will pick the source that is
41+
mentioned later in the list of sources. For example, consider the below list of sources:
4142
4243
```yaml
4344
sources:
44-
- chart: elasticsearch
45-
helm:
46-
valueFiles:
47-
- values.yaml
48-
repoURL: https://helm.elastic.co
49-
targetRevision: 7.6.0
50-
- repoURL: https://github.com/argoproj/argocd-example-apps.git
51-
path: guestbook
52-
targetRevision: HEAD
53-
- chart: elasticsearch
54-
helm:
55-
valueFiles:
56-
- values.yaml
57-
repoURL: https://helm.elastic.co
58-
targetRevision: 7.7.0
45+
- chart: elasticsearch
46+
repoURL: https://helm.elastic.co
47+
targetRevision: 7.6.0
48+
- repoURL: https://github.com/argoproj/argocd-example-apps.git
49+
path: guestbook
50+
targetRevision: HEAD
51+
- chart: elasticsearch
52+
repoURL: https://helm.elastic.co
53+
targetRevision: 7.7.0
5954
```
6055
61-
In the above list, the application has 2 sources referring to the same repoURL. In this case, Argo CD will generate the manifests for source with `targetRevision: 7.6.0` and then append the manifests generated for source with `targetRevision: 7.7.0`.
62-
56+
In the above list, the application has two sources referring to the same repoURL. In this case, Argo CD will generate
57+
the manifests for source with `targetRevision: 7.6.0` and then append the manifests generated for source with
58+
`targetRevision: 7.7.0`.
6359

6460
## Helm Value files from external Git repository
6561

pkg/apis/api-rules/violation_exceptions.list

+3-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/applicat
9393
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,KustomizeOptions,BinaryPath
9494
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,KustomizeOptions,BuildOptions
9595
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,PullRequestGenerator,GitLab
96-
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTargeRevisionMapping,Repo
97-
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTargeRevisionMapping,TargetRevision
96+
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTarget,Chart
97+
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTarget,Repo
98+
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTarget,TargetRevision
9899
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RepoCreds,GitHubAppEnterpriseBaseURL
99100
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RepoCreds,GithubAppId
100101
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RepoCreds,GithubAppInstallationId

pkg/apis/application/v1alpha1/applicationset_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ const (
536536
// prefix "Info" means informational condition
537537
type ApplicationSetConditionType string
538538

539-
//ErrorOccurred / ParametersGenerated / TemplateRendered / ResourcesUpToDate
539+
// ErrorOccurred / ParametersGenerated / TemplateRendered / ResourcesUpToDate
540540
const (
541541
ApplicationSetConditionErrorOccurred ApplicationSetConditionType = "ErrorOccurred"
542542
ApplicationSetConditionParametersGenerated ApplicationSetConditionType = "ParametersGenerated"

0 commit comments

Comments
 (0)