Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b71588a
mvp
pasha-codefresh Sep 16, 2021
ccb37cf
move tracking method on settings level
pasha-codefresh Sep 16, 2021
3ac41bb
tracking method support
pasha-codefresh Sep 17, 2021
1b71888
tracking method support
pasha-codefresh Sep 18, 2021
321574e
refactor way how to work with tracking method
pasha-codefresh Sep 19, 2021
6960389
refactor way how to work with tracking method
pasha-codefresh Sep 19, 2021
32a0955
rewrite way how to set label
pasha-codefresh Sep 20, 2021
0a77229
rewrite way how to set label
pasha-codefresh Sep 20, 2021
c1a0e16
rewrite way how to set label
pasha-codefresh Sep 20, 2021
4b3e7fc
rewrite way how to set label
pasha-codefresh Sep 21, 2021
1f53827
Merge branches 'master' and 'rename-app-id' of github.com:pasha-codef…
pasha-codefresh Sep 21, 2021
e84d14f
rewrite way how to set label
pasha-codefresh Sep 21, 2021
ee7324b
remove hardcoded annotation
pasha-codefresh Sep 21, 2021
0084614
remove redundant changes
pasha-codefresh Sep 21, 2021
4c9865a
regenrate code and fix test
pasha-codefresh Sep 21, 2021
19bdf43
Merge branches 'master' and 'rename-app-id' of github.com:pasha-codef…
pasha-codefresh Sep 21, 2021
9fe770c
fix test
pasha-codefresh Sep 21, 2021
cec4e1c
Merge branches 'master' and 'rename-app-id' of github.com:pasha-codef…
pasha-codefresh Sep 22, 2021
22daead
cover kube.go with tests
pasha-codefresh Sep 22, 2021
414e97b
add unit tests
pasha-codefresh Sep 22, 2021
2e76cae
rerun unit tests
pasha-codefresh Sep 22, 2021
35f3a67
Merge branches 'master' and 'rename-app-id' of github.com:pasha-codef…
pasha-codefresh Sep 22, 2021
eeaa466
add tracking method to cli
pasha-codefresh Sep 22, 2021
a31355f
app id e2e
pasha-codefresh Sep 28, 2021
4e705a3
add doc and rename key
pasha-codefresh Sep 28, 2021
f605267
Merge branches 'rename-app-id' and 'rename-app-id-e2e' of github.com:…
pasha-codefresh Sep 28, 2021
b5ba963
tracking mode tests
pasha-codefresh Sep 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3660,6 +3660,9 @@
"statusBadgeEnabled": {
"type": "boolean"
},
"trackingMethod": {
"type": "string"
},
"uiBannerContent": {
"type": "string"
},
Expand Down
4 changes: 3 additions & 1 deletion cmd/argocd/commands/admin/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"sort"
"time"

"github.com/argoproj/argo-cd/v2/util/argo"

"github.com/ghodss/yaml"
"github.com/spf13/cobra"
apiv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -408,5 +410,5 @@ func reconcileApplications(
}

func newLiveStateCache(argoDB db.ArgoDB, appInformer kubecache.SharedIndexInformer, settingsMgr *settings.SettingsManager, server *metrics.MetricsServer) cache.LiveStateCache {
return cache.NewLiveStateCache(argoDB, appInformer, settingsMgr, kubeutil.NewKubectl(), server, func(managedByApp map[string]bool, ref apiv1.ObjectReference) {}, nil)
return cache.NewLiveStateCache(argoDB, appInformer, settingsMgr, kubeutil.NewKubectl(), server, func(managedByApp map[string]bool, ref apiv1.ObjectReference) {}, nil, argo.NewResourceTracking())
}
11 changes: 6 additions & 5 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ func liveObjects(resources []*argoappv1.ResourceDiff) ([]*unstructured.Unstructu
}

func getLocalObjects(app *argoappv1.Application, local, localRepoRoot, appLabelKey, kubeVersion string, kustomizeOptions *argoappv1.KustomizeOptions,
configManagementPlugins []*argoappv1.ConfigManagementPlugin) []*unstructured.Unstructured {
manifestStrings := getLocalObjectsString(app, local, localRepoRoot, appLabelKey, kubeVersion, kustomizeOptions, configManagementPlugins)
configManagementPlugins []*argoappv1.ConfigManagementPlugin, trackingMethod string) []*unstructured.Unstructured {
manifestStrings := getLocalObjectsString(app, local, localRepoRoot, appLabelKey, kubeVersion, kustomizeOptions, configManagementPlugins, trackingMethod)
objs := make([]*unstructured.Unstructured, len(manifestStrings))
for i := range manifestStrings {
obj := unstructured.Unstructured{}
Expand All @@ -746,7 +746,7 @@ func getLocalObjects(app *argoappv1.Application, local, localRepoRoot, appLabelK
}

func getLocalObjectsString(app *argoappv1.Application, local, localRepoRoot, appLabelKey, kubeVersion string, kustomizeOptions *argoappv1.KustomizeOptions,
configManagementPlugins []*argoappv1.ConfigManagementPlugin) []string {
configManagementPlugins []*argoappv1.ConfigManagementPlugin, trackingMethod string) []string {

res, err := repository.GenerateManifests(local, localRepoRoot, app.Spec.Source.TargetRevision, &repoapiclient.ManifestRequest{
Repo: &argoappv1.Repository{Repo: app.Spec.Source.RepoURL},
Expand All @@ -757,6 +757,7 @@ func getLocalObjectsString(app *argoappv1.Application, local, localRepoRoot, app
KustomizeOptions: kustomizeOptions,
KubeVersion: kubeVersion,
Plugins: configManagementPlugins,
TrackingMethod: trackingMethod,
}, true)
errors.CheckError(err)

Expand Down Expand Up @@ -842,7 +843,7 @@ func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
defer argoio.Close(conn)
cluster, err := clusterIf.Get(context.Background(), &clusterpkg.ClusterQuery{Name: app.Spec.Destination.Name, Server: app.Spec.Destination.Server})
errors.CheckError(err)
localObjs := groupObjsByKey(getLocalObjects(app, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, argoSettings.KustomizeOptions, argoSettings.ConfigManagementPlugins), liveObjs, app.Spec.Destination.Namespace)
localObjs := groupObjsByKey(getLocalObjects(app, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, argoSettings.KustomizeOptions, argoSettings.ConfigManagementPlugins, argoSettings.TrackingMethod), liveObjs, app.Spec.Destination.Namespace)
items = groupObjsForDiff(resources, localObjs, items, argoSettings, appName)
} else if revision != "" {
var unstructureds []*unstructured.Unstructured
Expand Down Expand Up @@ -1377,7 +1378,7 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
cluster, err := clusterIf.Get(context.Background(), &clusterpkg.ClusterQuery{Name: app.Spec.Destination.Name, Server: app.Spec.Destination.Server})
errors.CheckError(err)
argoio.Close(conn)
localObjsStrings = getLocalObjectsString(app, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, argoSettings.KustomizeOptions, argoSettings.ConfigManagementPlugins)
localObjsStrings = getLocalObjectsString(app, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, argoSettings.KustomizeOptions, argoSettings.ConfigManagementPlugins, argoSettings.TrackingMethod)
}

syncReq := applicationpkg.ApplicationSyncRequest{
Expand Down
2 changes: 1 addition & 1 deletion controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func NewApplicationController(
return nil, err
}
}
stateCache := statecache.NewLiveStateCache(db, appInformer, ctrl.settingsMgr, kubectl, ctrl.metricsServer, ctrl.handleObjectUpdated, clusterFilter)
stateCache := statecache.NewLiveStateCache(db, appInformer, ctrl.settingsMgr, kubectl, ctrl.metricsServer, ctrl.handleObjectUpdated, clusterFilter, argo.NewResourceTracking())
appStateManager := NewAppStateManager(db, applicationClientset, repoClientset, namespace, kubectl, ctrl.settingsMgr, stateCache, projInformer, ctrl.metricsServer, argoCache, ctrl.statusRefreshTimeout)
ctrl.appInformer = appInformer
ctrl.appLister = appLister
Expand Down
28 changes: 17 additions & 11 deletions controller/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ func NewLiveStateCache(
kubectl kube.Kubectl,
metricsServer *metrics.MetricsServer,
onObjectUpdated ObjectUpdatedHandler,
clusterFilter func(cluster *appv1.Cluster) bool) LiveStateCache {
clusterFilter func(cluster *appv1.Cluster) bool,
resourceTracking argo.ResourceTracking) LiveStateCache {

return &liveStateCache{
appInformer: appInformer,
Expand All @@ -116,8 +117,9 @@ func NewLiveStateCache(
settingsMgr: settingsMgr,
metricsServer: metricsServer,
// The default limit of 50 is chosen based on experiments.
listSemaphore: semaphore.NewWeighted(50),
clusterFilter: clusterFilter,
listSemaphore: semaphore.NewWeighted(50),
clusterFilter: clusterFilter,
resourceTracking: resourceTracking,
}
}

Expand All @@ -127,13 +129,14 @@ type cacheSettings struct {
}

type liveStateCache struct {
db db.ArgoDB
appInformer cache.SharedIndexInformer
onObjectUpdated ObjectUpdatedHandler
kubectl kube.Kubectl
settingsMgr *settings.SettingsManager
metricsServer *metrics.MetricsServer
clusterFilter func(cluster *appv1.Cluster) bool
db db.ArgoDB
appInformer cache.SharedIndexInformer
onObjectUpdated ObjectUpdatedHandler
kubectl kube.Kubectl
settingsMgr *settings.SettingsManager
metricsServer *metrics.MetricsServer
clusterFilter func(cluster *appv1.Cluster) bool
resourceTracking argo.ResourceTracking

// listSemaphore is used to limit the number of concurrent memory consuming operations on the
// k8s list queries results across all clusters to avoid memory spikes during cache initialization.
Expand Down Expand Up @@ -285,6 +288,8 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
return nil, fmt.Errorf("controller is configured to ignore cluster %s", cluster.Server)
}

trackingMethod := argo.GetTrackingMethod(c.settingsMgr)

clusterCache = clustercache.NewClusterCache(cluster.RESTConfig(),
clustercache.SetListSemaphore(c.listSemaphore),
clustercache.SetResyncTimeout(K8SClusterResyncDuration),
Expand All @@ -295,7 +300,8 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
res := &ResourceInfo{}
populateNodeInfo(un, res)
res.Health, _ = health.GetResourceHealth(un, cacheSettings.clusterSettings.ResourceHealthOverride)
appName := kube.GetAppInstanceLabel(un, cacheSettings.appInstanceLabelKey)

appName := c.resourceTracking.GetAppName(un, cacheSettings.appInstanceLabelKey, trackingMethod)
if isRoot && appName != "" {
res.AppName = appName
}
Expand Down
2 changes: 2 additions & 0 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, source v1alpha1
if err != nil {
return nil, nil, err
}

kustomizeOptions, err := kustomizeSettings.GetOptions(app.Spec.Source)
if err != nil {
return nil, nil, err
Expand All @@ -174,6 +175,7 @@ func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, source v1alpha1
ApiVersions: argo.APIGroupsToVersions(apiGroups),
VerifySignature: verifySignature,
HelmRepoCreds: permittedHelmCredentials,
TrackingMethod: string(argo.GetTrackingMethod(m.settingsMgr)),
})
if err != nil {
return nil, nil, err
Expand Down
Loading