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: acr v1.1 #334

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
96 changes: 0 additions & 96 deletions acr_controller/application/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"encoding/json"
"fmt"
appclient "github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
repoapiclient "github.com/argoproj/argo-cd/v2/reposerver/apiclient"
"google.golang.org/grpc"
"io"
"net/http"
Expand All @@ -17,18 +15,6 @@ import (
//go:generate go run github.com/vektra/mockery/[email protected] --name=ApplicationClient

type ApplicationClient interface {
Get(ctx context.Context, in *appclient.ApplicationQuery, opts ...grpc.CallOption) (*v1alpha1.Application, error)

RevisionMetadata(ctx context.Context, in *appclient.RevisionMetadataQuery, opts ...grpc.CallOption) (*v1alpha1.RevisionMetadata, error)

GetManifests(ctx context.Context, in *appclient.ApplicationManifestQuery, opts ...grpc.CallOption) (*repoapiclient.ManifestResponse, error)

ResourceTree(ctx context.Context, in *appclient.ResourcesQuery, opts ...grpc.CallOption) (*v1alpha1.ApplicationTree, error)

GetResource(ctx context.Context, in *appclient.ApplicationResourceRequest, opts ...grpc.CallOption) (*appclient.ApplicationResourceResponse, error)

List(ctx context.Context, in *appclient.ApplicationQuery, opts ...grpc.CallOption) (*v1alpha1.ApplicationList, error)

GetChangeRevision(ctx context.Context, in *appclient.ChangeRevisionRequest, opts ...grpc.CallOption) (*appclient.ChangeRevisionResponse, error)
}

Expand Down Expand Up @@ -91,88 +77,6 @@ func (c *httpApplicationClient) execute(ctx context.Context, url string, result
return nil
}

func (c *httpApplicationClient) Get(ctx context.Context, in *appclient.ApplicationQuery, opts ...grpc.CallOption) (*v1alpha1.Application, error) {
params := fmt.Sprintf("?appNamespace=%s",
*in.AppNamespace)
url := fmt.Sprintf("%s/api/v1/applications/%s%s", c.baseUrl, *in.Name, params)
application := &v1alpha1.Application{}
err := c.execute(ctx, url, application)
if err != nil {
return nil, err
}
return application, nil
}

func (c *httpApplicationClient) RevisionMetadata(ctx context.Context, in *appclient.RevisionMetadataQuery, opts ...grpc.CallOption) (*v1alpha1.RevisionMetadata, error) {
params := fmt.Sprintf("?appNamespace=%s&project=%s",
*in.AppNamespace,
*in.Project)
url := fmt.Sprintf("%s/api/v1/applications/%s/revisions/%s/metadata%s", c.baseUrl, *in.Name, *in.Revision, params)
revisionMetadata := &v1alpha1.RevisionMetadata{}
err := c.execute(ctx, url, revisionMetadata)
if err != nil {
return nil, err
}
return revisionMetadata, nil
}

func (c *httpApplicationClient) GetManifests(ctx context.Context, in *appclient.ApplicationManifestQuery, opts ...grpc.CallOption) (*repoapiclient.ManifestResponse, error) {
params := fmt.Sprintf("?appNamespace=%s&project=%s",
*in.AppNamespace,
*in.Project)
url := fmt.Sprintf("%s/api/v1/applications/%s/manifests%s", c.baseUrl, *in.Name, params)

manifest := &repoapiclient.ManifestResponse{}
err := c.execute(ctx, url, manifest)
if err != nil {
return nil, err
}
return manifest, nil
}

func (c *httpApplicationClient) ResourceTree(ctx context.Context, in *appclient.ResourcesQuery, opts ...grpc.CallOption) (*v1alpha1.ApplicationTree, error) {
params := fmt.Sprintf("?appNamespace=%s&project=%s",
*in.AppNamespace,
*in.Project)
url := fmt.Sprintf("%s/api/v1/applications/%s/resource-tree%s", c.baseUrl, *in.ApplicationName, params)
tree := &v1alpha1.ApplicationTree{}
err := c.execute(ctx, url, tree)
if err != nil {
return nil, err
}
return tree, nil
}

func (c *httpApplicationClient) GetResource(ctx context.Context, in *appclient.ApplicationResourceRequest, opts ...grpc.CallOption) (*appclient.ApplicationResourceResponse, error) {
params := fmt.Sprintf("?appNamespace=%s&namespace=%s&resourceName=%s&version=%s&group=%s&kind=%s&project=%s",
*in.AppNamespace,
*in.Namespace,
*in.ResourceName,
*in.Version,
*in.Group,
*in.Kind,
*in.Project)
url := fmt.Sprintf("%s/api/v1/applications/%s/resource%s", c.baseUrl, *in.Name, params)

applicationResource := &appclient.ApplicationResourceResponse{}
err := c.execute(ctx, url, applicationResource, true)
if err != nil {
return nil, err
}
return applicationResource, nil
}

func (c *httpApplicationClient) List(ctx context.Context, in *appclient.ApplicationQuery, opts ...grpc.CallOption) (*v1alpha1.ApplicationList, error) {
url := fmt.Sprintf("%s/api/v1/applications", c.baseUrl)

apps := &v1alpha1.ApplicationList{}
err := c.execute(ctx, url, apps)
if err != nil {
return nil, err
}
return apps, nil
}

func (c *httpApplicationClient) GetChangeRevision(ctx context.Context, in *appclient.ChangeRevisionRequest, opts ...grpc.CallOption) (*appclient.ChangeRevisionResponse, error) {
params := fmt.Sprintf("?appName=%s&namespace=%s&currentRevision=%s&previousRevision=%s", in.GetAppName(), in.GetNamespace(), in.GetCurrentRevision(), in.GetPreviousRevision())

Expand Down
5 changes: 0 additions & 5 deletions acr_controller/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"strings"
"time"

"github.com/argoproj/argo-cd/v2/event_reporter/handlers"
appclientset "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned"
appinformer "github.com/argoproj/argo-cd/v2/pkg/client/informers/externalversions"
applisters "github.com/argoproj/argo-cd/v2/pkg/client/listers/application/v1alpha1"
Expand Down Expand Up @@ -141,10 +140,6 @@ func (a *ACRServer) newHTTPServer(ctx context.Context, port int) *http.Server {
}

healthz.ServeHealthCheck(mux, a.healthCheck)

rH := handlers.GetRequestHandlers(a.ApplicationServiceClient)
mux.HandleFunc("/app-distribution", rH.GetAppDistribution)

return &httpS
}

Expand Down
3 changes: 0 additions & 3 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8781,9 +8781,6 @@
"type": "object",
"title": "RevisionHistory contains history information about a previous sync",
"properties": {
"changeRevision": {
"type": "string"
},
"deployStartedAt": {
"$ref": "#/definitions/v1Time"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func NewCommand() *cobra.Command {
command.Flags().StringVar(&argocdToken, "argocd-token", env.StringFromEnv("ARGOCD_TOKEN", ""), "ArgoCD server JWT token")
command.AddCommand(cli.NewVersionCmd(cliName))
command.Flags().StringVar(&listenHost, "address", env.StringFromEnv("ACR_CONTROLLER_LISTEN_ADDRESS", common.DefaultAddressACRController), "Listen on given address")
command.Flags().IntVar(&listenPort, "port", common.DefaultPortCRCServer, "Listen on given port")
command.Flags().IntVar(&listenPort, "port", common.DefaultPortACRServer, "Listen on given port")
command.Flags().StringVar(&contentSecurityPolicy, "content-security-policy", env.StringFromEnv("ACR_CONTROLLER_CONTENT_SECURITY_POLICY", "frame-ancestors 'self';"), "Set Content-Security-Policy header in HTTP responses to `value`. To disable, set to \"\".")
command.Flags().StringSliceVar(&applicationNamespaces, "application-namespaces", env.StringsFromEnv("ARGOCD_APPLICATION_NAMESPACES", []string{}, ","), "List of additional namespaces where application resources can be managed in")
cacheSrc = servercache.AddCacheFlagsToCmd(command, cacheutil.Options{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func NewCommand() *cobra.Command {
command.Flags().IntVar(&statusProcessors, "status-processors", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_STATUS_PROCESSORS", 20, 0, math.MaxInt32), "Number of application status processors")
command.Flags().IntVar(&operationProcessors, "operation-processors", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_OPERATION_PROCESSORS", 10, 0, math.MaxInt32), "Number of application operation processors")
command.Flags().StringVar(&cmdutil.LogFormat, "logformat", env.StringFromEnv("ARGOCD_APPLICATION_CONTROLLER_LOGFORMAT", "text"), "Set the logging format. One of: text|json")
command.Flags().StringVar(&cmdutil.LogLevel, "loglevel", env.StringFromEnv("ARGOCD_APPLICATION_CONTROLLER_LOGLEVEL", "warn"), "Set the logging level. One of: debug|info|warn|error")
command.Flags().StringVar(&cmdutil.LogLevel, "loglevel", env.StringFromEnv("ARGOCD_APPLICATION_CONTROLLER_LOGLEVEL", "info"), "Set the logging level. One of: debug|info|warn|error")
command.Flags().IntVar(&glogLevel, "gloglevel", 0, "Set the glog logging level")
command.Flags().IntVar(&metricsPort, "metrics-port", common.DefaultPortArgoCDMetrics, "Start metrics server on given port")
command.Flags().DurationVar(&metricsCacheExpiration, "metrics-cache-expiration", env.ParseDurationFromEnv("ARGOCD_APPLICATION_CONTROLLER_METRICS_CACHE_EXPIRATION", 0*time.Second, 0, math.MaxInt64), "Prometheus metrics cache expiration (disabled by default. e.g. 24h0m0s)")
Expand Down
3 changes: 1 addition & 2 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const (
DefaultPortEventReporterServerMetrics = 8087
DefaultPortEventReporterServer = 8088

DefaultPortCRCServerMetrics = 8089
DefaultPortCRCServer = 8090
DefaultPortACRServer = 8090
)

// DefaultAddressAPIServer for ArgoCD components
Expand Down
10 changes: 0 additions & 10 deletions controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1502,16 +1502,6 @@ func (ctrl *ApplicationController) processAppRefreshQueueItem() (processNext boo
}
origApp = origApp.DeepCopy()

if origApp.GetName() == "guestbook" {
logCtx2 := log.WithField("application", origApp.GetName())
logCtx2.Warningf("[Monorepo] Processing app refresh, revision: %s", origApp.Status.Sync.Revision)
if origApp.Status.OperationState != nil {
if origApp.Status.OperationState.SyncResult != nil {
logCtx2.Warningf("[Monorepo] Processing app refresh, sync result: %s", origApp.Status.OperationState.SyncResult.Revision)
}
}
}

needRefresh, refreshType, comparisonLevel := ctrl.needRefreshAppStatus(origApp, ctrl.statusRefreshTimeout, ctrl.statusHardRefreshTimeout)

if !needRefresh {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ argocd-application-controller [flags]
--kubeconfig string Path to a kube config. Only required if out-of-cluster
--kubectl-parallelism-limit int Number of allowed concurrent kubectl fork/execs. Any value less than 1 means no limit. (default 20)
--logformat string Set the logging format. One of: text|json (default "text")
--loglevel string Set the logging level. One of: debug|info|warn|error (default "warn")
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
--metrics-application-labels strings List of Application labels that will be added to the argocd_application_labels metric
--metrics-cache-expiration duration Prometheus metrics cache expiration (disabled by default. e.g. 24h0m0s)
--metrics-port int Start metrics server on given port (default 8082)
Expand Down
2 changes: 0 additions & 2 deletions manifests/core-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1751,8 +1751,6 @@ spec:
description: RevisionHistory contains history information about
a previous sync
properties:
changeRevision:
type: string
deployStartedAt:
description: DeployStartedAt holds the time the sync operation
started
Expand Down
2 changes: 0 additions & 2 deletions manifests/crds/application-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,6 @@ spec:
description: RevisionHistory contains history information about
a previous sync
properties:
changeRevision:
type: string
deployStartedAt:
description: DeployStartedAt holds the time the sync operation
started
Expand Down
2 changes: 0 additions & 2 deletions manifests/ha/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1751,8 +1751,6 @@ spec:
description: RevisionHistory contains history information about
a previous sync
properties:
changeRevision:
type: string
deployStartedAt:
description: DeployStartedAt holds the time the sync operation
started
Expand Down
2 changes: 0 additions & 2 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1751,8 +1751,6 @@ spec:
description: RevisionHistory contains history information about
a previous sync
properties:
changeRevision:
type: string
deployStartedAt:
description: DeployStartedAt holds the time the sync operation
started
Expand Down
Loading
Loading