Skip to content

Commit

Permalink
fix nil reference and key mismatch bugs; add more logs (argoproj#6)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Rebase with master

Signed-off-by: ishitasequeira <[email protected]>
  • Loading branch information
crenshaw-dev authored and ishitasequeira committed Dec 9, 2022
1 parent d1e624d commit 305ee3b
Show file tree
Hide file tree
Showing 20 changed files with 857 additions and 1,049 deletions.
19 changes: 3 additions & 16 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,9 @@ func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, sources []v1alp
targetObjs := make([]*unstructured.Unstructured, 0)

// Store the map of all sources having ref field into a map for applications with sources field
refSources := make(map[string]*appv1.RefTargeRevisionMapping)
if app.Spec.HasMultipleSources() {
// Get Repositories for all sources before generating Manifests
for _, source := range sources {
if source.Ref != "" {
repo, err := m.db.GetRepository(context.Background(), source.RepoURL)
if err != nil {
return nil, nil, err
}
refKey := "$" + source.Ref
refSources[refKey] = &appv1.RefTargeRevisionMapping{
Repo: *repo,
TargetRevision: source.TargetRevision,
}
}
}
refSources, err := argo.GetRefSources(context.Background(), app.Spec, m.db)
if err != nil {
return nil, nil, fmt.Errorf("failed to get ref sources: %v", err)
}

for i, source := range sources {
Expand Down
46 changes: 21 additions & 25 deletions docs/user-guide/multiple_sources.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Multiple Sources for an Application

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.
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.

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.
You can provide multiple sources using the `sources` field. When you specify the `sources` field, Argo CD will ignore
the `source` (singular) field when generating manifests for the application.

See below example for specifying multiple sources:
See the below example for specifying multiple sources:

```yaml
apiVersion: argoproj.io/v1alpha1
Expand All @@ -25,41 +27,35 @@ spec:
namespace: argocd
sources:
- chart: elasticsearch
helm:
valueFiles:
- values.yaml
repoURL: https://helm.elastic.co
targetRevision: 7.6.0
- repoURL: https://github.com/argoproj/argocd-example-apps.git
path: guestbook
targetRevision: HEAD
```
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.
The above example has two sources specified. Argo CD will generate the manifests for each source separately and combine
the resulting manifests.
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:
In case an application has multiple entries for the same source (repoURL), Argo CD will pick the source that is
mentioned later in the list of sources. For example, consider the below list of sources:
```yaml
sources:
- chart: elasticsearch
helm:
valueFiles:
- values.yaml
repoURL: https://helm.elastic.co
targetRevision: 7.6.0
- repoURL: https://github.com/argoproj/argocd-example-apps.git
path: guestbook
targetRevision: HEAD
- chart: elasticsearch
helm:
valueFiles:
- values.yaml
repoURL: https://helm.elastic.co
targetRevision: 7.7.0
- chart: elasticsearch
repoURL: https://helm.elastic.co
targetRevision: 7.6.0
- repoURL: https://github.com/argoproj/argocd-example-apps.git
path: guestbook
targetRevision: HEAD
- chart: elasticsearch
repoURL: https://helm.elastic.co
targetRevision: 7.7.0
```
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`.

In the above list, the application has two 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`.

## Helm Value files from external Git repository

Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/api-rules/violation_exceptions.list
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/applicat
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,KustomizeOptions,BinaryPath
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,KustomizeOptions,BuildOptions
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,PullRequestGenerator,GitLab
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTargeRevisionMapping,Repo
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTargeRevisionMapping,TargetRevision
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTarget,Chart
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTarget,Repo
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RefTarget,TargetRevision
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RepoCreds,GitHubAppEnterpriseBaseURL
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RepoCreds,GithubAppId
API rule violation: names_match,github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1,RepoCreds,GithubAppInstallationId
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/application/v1alpha1/applicationset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ const (
// prefix "Info" means informational condition
type ApplicationSetConditionType string

//ErrorOccurred / ParametersGenerated / TemplateRendered / ResourcesUpToDate
// ErrorOccurred / ParametersGenerated / TemplateRendered / ResourcesUpToDate
const (
ApplicationSetConditionErrorOccurred ApplicationSetConditionType = "ErrorOccurred"
ApplicationSetConditionParametersGenerated ApplicationSetConditionType = "ParametersGenerated"
Expand Down
Loading

0 comments on commit 305ee3b

Please sign in to comment.