diff --git a/Dockerfile-ci-builder b/Dockerfile-ci-builder index 544536fd39a78..3b93ec42f4e9d 100644 --- a/Dockerfile-ci-builder +++ b/Dockerfile-ci-builder @@ -11,7 +11,8 @@ RUN curl -O https://get.docker.com/builds/Linux/x86_64/docker-1.13.1.tgz && \ gometalinter.v2 --install # Install kubectl -RUN curl -o /usr/local/bin/kubectl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl +RUN curl -o /kubectl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \ + chmod +x /kubectl && mv /kubectl /usr/local/bin/kubectl # Install ksonnet env KSONNET_VERSION=0.10.1 diff --git a/cmd/argocd-application-controller/main.go b/cmd/argocd-application-controller/main.go index 6931e3984330d..3eed42a29986e 100644 --- a/cmd/argocd-application-controller/main.go +++ b/cmd/argocd-application-controller/main.go @@ -8,11 +8,10 @@ import ( "strconv" "time" - argocd "github.com/argoproj/argo-cd" + "github.com/argoproj/argo-cd" "github.com/argoproj/argo-cd/controller" "github.com/argoproj/argo-cd/errors" appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" - "github.com/argoproj/argo-cd/reposerver" "github.com/argoproj/argo-cd/server/cluster" apirepository "github.com/argoproj/argo-cd/server/repository" "github.com/argoproj/argo-cd/util/cli" @@ -24,6 +23,7 @@ import ( // load the gcp plugin (required to authenticate against GKE clusters). _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // load the oidc plugin (required to authenticate with OpenID Connect). + "github.com/argoproj/argo-cd/reposerver" _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" ) @@ -36,12 +36,13 @@ const ( func newCommand() *cobra.Command { var ( - clientConfig clientcmd.ClientConfig - appResyncPeriod int64 - repoServerAddress string - workers int - logLevel string - glogLevel int + clientConfig clientcmd.ClientConfig + appResyncPeriod int64 + repoServerAddress string + statusProcessors int + operationProcessors int + logLevel string + glogLevel int ) var command = cobra.Command{ Use: cliName, @@ -71,19 +72,20 @@ func newCommand() *cobra.Command { InstanceID: "", } resyncDuration := time.Duration(appResyncPeriod) * time.Second - apiRepoServer := apirepository.NewServer(namespace, kubeClient, appClient) apiClusterServer := cluster.NewServer(namespace, kubeClient, appClient) clusterService := cluster.NewServer(namespace, kubeClient, appClient) - appComparator := controller.NewKsonnetAppComparator(clusterService) + apiRepoServer := apirepository.NewServer(namespace, kubeClient, appClient) + appStateManager := controller.NewAppStateManager( + clusterService, apiRepoServer, appClient, reposerver.NewRepositoryServerClientset(repoServerAddress), namespace) + appHealthManager := controller.NewAppHealthManager(clusterService, namespace) appController := controller.NewApplicationController( namespace, kubeClient, appClient, - reposerver.NewRepositoryServerClientset(repoServerAddress), - apiRepoServer, apiClusterServer, - appComparator, + appStateManager, + appHealthManager, resyncDuration, &controllerConfig) @@ -91,7 +93,7 @@ func newCommand() *cobra.Command { defer cancel() log.Infof("Application Controller (version: %s) starting (namespace: %s)", argocd.GetVersion(), namespace) - go appController.Run(ctx, workers) + go appController.Run(ctx, statusProcessors, operationProcessors) // Wait forever select {} }, @@ -100,7 +102,8 @@ func newCommand() *cobra.Command { clientConfig = cli.AddKubectlFlagsToCmd(&command) command.Flags().Int64Var(&appResyncPeriod, "app-resync", defaultAppResyncPeriod, "Time period in seconds for application resync.") command.Flags().StringVar(&repoServerAddress, "repo-server", "localhost:8081", "Repo server address.") - command.Flags().IntVar(&workers, "workers", 1, "Number of application workers") + command.Flags().IntVar(&statusProcessors, "status-processors", 1, "Number of application status processors") + command.Flags().IntVar(&operationProcessors, "operation-processors", 1, "Number of application operation processors") command.Flags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error") command.Flags().IntVar(&glogLevel, "gloglevel", 0, "Set the glog logging level") return &command diff --git a/cmd/argocd-server/commands/root.go b/cmd/argocd-server/commands/root.go index ade7fac1313fe..250262ceb344c 100644 --- a/cmd/argocd-server/commands/root.go +++ b/cmd/argocd-server/commands/root.go @@ -1,6 +1,8 @@ package commands import ( + "context" + "github.com/argoproj/argo-cd/errors" appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" "github.com/argoproj/argo-cd/reposerver" @@ -51,7 +53,10 @@ func NewCommand() *cobra.Command { DisableAuth: disableAuth, } argocd := server.NewServer(argoCDOpts) - argocd.Run() + ctx := context.Background() + ctx, cancel := context.WithCancel(ctx) + defer cancel() + argocd.Run(ctx, 8080) }, } diff --git a/cmd/argocd/commands/app.go b/cmd/argocd/commands/app.go index e652b143fc80c..08c0b2df81508 100644 --- a/cmd/argocd/commands/app.go +++ b/cmd/argocd/commands/app.go @@ -366,8 +366,13 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co Revision: revision, Prune: prune, } - syncRes, err := appIf.Sync(context.Background(), &syncReq) + _, err := appIf.Sync(context.Background(), &syncReq) errors.CheckError(err) + + status, err := waitUntilOperationCompleted(appIf, appName) + errors.CheckError(err) + syncRes := status.SyncResult + fmt.Printf("%s %s\n", appName, syncRes.Message) w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) fmt.Fprintf(w, "NAME\tKIND\tMESSAGE\n") @@ -383,6 +388,33 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co return command } +func waitUntilOperationCompleted(appClient application.ApplicationServiceClient, appName string) (*argoappv1.OperationState, error) { + wc, err := appClient.Watch(context.Background(), &application.ApplicationQuery{ + Name: appName, + }) + if err != nil { + return nil, err + } + appEvent, err := wc.Recv() + if err != nil { + return nil, err + } + for { + if appEvent.Application.Status.OperationState != nil && appEvent.Application.Status.OperationState.Status != argoappv1.OperationStatusInProgress { + if appEvent.Application.Status.OperationState.Status == argoappv1.OperationStatusFailed { + return nil, fmt.Errorf("operation failed: %s", appEvent.Application.Status.OperationState.ErrorDetails) + } else { + return appEvent.Application.Status.OperationState, nil + } + } else { + appEvent, err = wc.Recv() + if err != nil { + return nil, err + } + } + } +} + // setParameterOverrides updates an existing or appends a new parameter override in the application func setParameterOverrides(app *argoappv1.Application, parameters []string) { if len(parameters) == 0 { @@ -489,12 +521,18 @@ func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobr if depInfo == nil { log.Fatalf("Application '%s' does not have deployment id '%d' in history\n", app.ObjectMeta.Name, depID) } - syncRes, err := appIf.Rollback(ctx, &application.ApplicationRollbackRequest{ + + _, err = appIf.Rollback(ctx, &application.ApplicationRollbackRequest{ Name: appName, ID: int64(depID), Prune: prune, }) errors.CheckError(err) + + status, err := waitUntilOperationCompleted(appIf, appName) + errors.CheckError(err) + syncRes := status.SyncResult + fmt.Printf("%s %s\n", appName, syncRes.Message) w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) fmt.Fprintf(w, "NAME\tKIND\tMESSAGE\n") diff --git a/controller/comparator.go b/controller/comparator.go deleted file mode 100644 index 1d3dcebfb7d10..0000000000000 --- a/controller/comparator.go +++ /dev/null @@ -1,253 +0,0 @@ -package controller - -import ( - "context" - "encoding/json" - "fmt" - "time" - - "github.com/argoproj/argo-cd/common" - "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" - "github.com/argoproj/argo-cd/server/cluster" - "github.com/argoproj/argo-cd/util/diff" - kubeutil "github.com/argoproj/argo-cd/util/kube" - log "github.com/sirupsen/logrus" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/client-go/discovery" - "k8s.io/client-go/dynamic" -) - -// AppComparator defines methods which allow to compare application spec and actual application state. -type AppComparator interface { - CompareAppState(server string, namespace string, targetObjs []*unstructured.Unstructured, app *v1alpha1.Application) (*v1alpha1.ComparisonResult, error) -} - -// KsonnetAppComparator allows to compare application using KSonnet CLI -type KsonnetAppComparator struct { - clusterService cluster.ClusterServiceServer -} - -// groupLiveObjects deduplicate list of kubernetes resources and choose correct version of resource: if resource has corresponding expected application resource then method pick -// kubernetes resource with matching version, otherwise chooses single kubernetes resource with any version -func (ks *KsonnetAppComparator) groupLiveObjects(liveObjs []*unstructured.Unstructured, targetObjs []*unstructured.Unstructured) map[string]*unstructured.Unstructured { - targetByFullName := make(map[string]*unstructured.Unstructured) - for _, obj := range targetObjs { - targetByFullName[getResourceFullName(obj)] = obj - } - - liveListByFullName := make(map[string][]*unstructured.Unstructured) - for _, obj := range liveObjs { - list := liveListByFullName[getResourceFullName(obj)] - if list == nil { - list = make([]*unstructured.Unstructured, 0) - } - list = append(list, obj) - liveListByFullName[getResourceFullName(obj)] = list - } - - liveByFullName := make(map[string]*unstructured.Unstructured) - - for fullName, list := range liveListByFullName { - targetObj := targetByFullName[fullName] - var liveObj *unstructured.Unstructured - if targetObj != nil { - for i := range list { - if list[i].GetAPIVersion() == targetObj.GetAPIVersion() { - liveObj = list[i] - break - } - } - } else { - liveObj = list[0] - } - if liveObj != nil { - liveByFullName[getResourceFullName(liveObj)] = liveObj - } - } - return liveByFullName -} - -// CompareAppState compares application spec and real app state using KSonnet -func (ks *KsonnetAppComparator) CompareAppState( - server string, - namespace string, - targetObjs []*unstructured.Unstructured, - app *v1alpha1.Application) (*v1alpha1.ComparisonResult, error) { - - log.Infof("Comparing app %s state in cluster %s (namespace: %s)", app.ObjectMeta.Name, server, namespace) - // Get the REST config for the cluster corresponding to the environment - clst, err := ks.clusterService.Get(context.Background(), &cluster.ClusterQuery{Server: server}) - if err != nil { - return nil, err - } - restConfig := clst.RESTConfig() - - // Retrieve the live versions of the objects - liveObjs, err := kubeutil.GetResourcesWithLabel(restConfig, namespace, common.LabelApplicationName, app.Name) - if err != nil { - return nil, err - } - - liveObjByFullName := ks.groupLiveObjects(liveObjs, targetObjs) - - controlledLiveObj := make([]*unstructured.Unstructured, len(targetObjs)) - - // Move live resources which have corresponding target object to controlledLiveObj - dynClientPool := dynamic.NewDynamicClientPool(restConfig) - disco, err := discovery.NewDiscoveryClientForConfig(restConfig) - if err != nil { - return nil, err - } - for i, targetObj := range targetObjs { - fullName := getResourceFullName(targetObj) - liveObj := liveObjByFullName[fullName] - if liveObj == nil { - // If we get here, it indicates we did not find the live resource when querying using - // our app label. However, it is possible that the resource was created/modified outside - // of ArgoCD. In order to determine that it is truly missing, we fall back to perform a - // direct lookup of the resource by name. See issue #141 - gvk := targetObj.GroupVersionKind() - dclient, err := dynClientPool.ClientForGroupVersionKind(gvk) - if err != nil { - return nil, err - } - apiResource, err := kubeutil.ServerResourceForGroupVersionKind(disco, gvk) - if err != nil { - return nil, err - } - liveObj, err = kubeutil.GetLiveResource(dclient, targetObj, apiResource, namespace) - if err != nil { - return nil, err - } - } - controlledLiveObj[i] = liveObj - delete(liveObjByFullName, fullName) - } - - // Move root level live resources to controlledLiveObj and add nil to targetObjs to indicate that target object is missing - for fullName := range liveObjByFullName { - liveObj := liveObjByFullName[fullName] - if !hasParent(liveObj) { - targetObjs = append(targetObjs, nil) - controlledLiveObj = append(controlledLiveObj, liveObj) - } - } - - // Do the actual comparison - diffResults, err := diff.DiffArray(targetObjs, controlledLiveObj) - if err != nil { - return nil, err - } - comparisonStatus := v1alpha1.ComparisonStatusSynced - - resources := make([]v1alpha1.ResourceState, len(targetObjs)) - for i := 0; i < len(targetObjs); i++ { - resState := v1alpha1.ResourceState{ - ChildLiveResources: make([]v1alpha1.ResourceNode, 0), - } - diffResult := diffResults.Diffs[i] - if diffResult.Modified { - // Set resource state to 'OutOfSync' since target and corresponding live resource are different - resState.Status = v1alpha1.ComparisonStatusOutOfSync - comparisonStatus = v1alpha1.ComparisonStatusOutOfSync - } else { - resState.Status = v1alpha1.ComparisonStatusSynced - } - - if targetObjs[i] == nil { - resState.TargetState = "null" - // Set resource state to 'OutOfSync' since target resource is missing and live resource is unexpected - resState.Status = v1alpha1.ComparisonStatusOutOfSync - comparisonStatus = v1alpha1.ComparisonStatusOutOfSync - } else { - targetObjBytes, err := json.Marshal(targetObjs[i].Object) - if err != nil { - return nil, err - } - resState.TargetState = string(targetObjBytes) - } - - if controlledLiveObj[i] == nil { - resState.LiveState = "null" - // Set resource state to 'OutOfSync' since target resource present but corresponding live resource is missing - resState.Status = v1alpha1.ComparisonStatusOutOfSync - comparisonStatus = v1alpha1.ComparisonStatusOutOfSync - } else { - liveObjBytes, err := json.Marshal(controlledLiveObj[i].Object) - if err != nil { - return nil, err - } - resState.LiveState = string(liveObjBytes) - } - - resources[i] = resState - } - - for i, resource := range resources { - liveResource := controlledLiveObj[i] - if liveResource != nil { - childResources, err := getChildren(liveResource, liveObjByFullName) - if err != nil { - return nil, err - } - resource.ChildLiveResources = childResources - resources[i] = resource - } - } - compResult := v1alpha1.ComparisonResult{ - ComparedTo: app.Spec.Source, - ComparedAt: metav1.Time{Time: time.Now().UTC()}, - Server: clst.Server, - Namespace: namespace, - Resources: resources, - Status: comparisonStatus, - } - return &compResult, nil -} - -func hasParent(obj *unstructured.Unstructured) bool { - // TODO: remove special case after Service and Endpoint get explicit relationship ( https://github.com/kubernetes/kubernetes/issues/28483 ) - return obj.GetKind() == kubeutil.EndpointsKind || metav1.GetControllerOf(obj) != nil -} - -func isControlledBy(obj *unstructured.Unstructured, parent *unstructured.Unstructured) bool { - // TODO: remove special case after Service and Endpoint get explicit relationship ( https://github.com/kubernetes/kubernetes/issues/28483 ) - if obj.GetKind() == kubeutil.EndpointsKind && parent.GetKind() == kubeutil.ServiceKind { - return obj.GetName() == parent.GetName() - } - return metav1.IsControlledBy(obj, parent) -} - -func getChildren(parent *unstructured.Unstructured, liveObjByFullName map[string]*unstructured.Unstructured) ([]v1alpha1.ResourceNode, error) { - children := make([]v1alpha1.ResourceNode, 0) - for fullName, obj := range liveObjByFullName { - if isControlledBy(obj, parent) { - delete(liveObjByFullName, fullName) - childResource := v1alpha1.ResourceNode{} - json, err := json.Marshal(obj) - if err != nil { - return nil, err - } - childResource.State = string(json) - childResourceChildren, err := getChildren(obj, liveObjByFullName) - if err != nil { - return nil, err - } - childResource.Children = childResourceChildren - children = append(children, childResource) - } - } - return children, nil -} - -func getResourceFullName(obj *unstructured.Unstructured) string { - return fmt.Sprintf("%s:%s", obj.GetKind(), obj.GetName()) -} - -// NewKsonnetAppComparator creates new instance of Ksonnet app comparator -func NewKsonnetAppComparator(clusterService cluster.ClusterServiceServer) AppComparator { - return &KsonnetAppComparator{ - clusterService: clusterService, - } -} diff --git a/controller/controller.go b/controller/controller.go index cad8a9df97e3b..6380bce57d9bd 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -11,15 +11,12 @@ import ( appv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" appinformers "github.com/argoproj/argo-cd/pkg/client/informers/externalversions" - "github.com/argoproj/argo-cd/reposerver" - "github.com/argoproj/argo-cd/reposerver/repository" "github.com/argoproj/argo-cd/server/cluster" - apireposerver "github.com/argoproj/argo-cd/server/repository" - "github.com/argoproj/argo-cd/util" "github.com/argoproj/argo-cd/util/kube" + "github.com/pkg/errors" log "github.com/sirupsen/logrus" - "k8s.io/api/apps/v1" - coreV1 "k8s.io/api/core/v1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/fields" @@ -30,26 +27,26 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" "k8s.io/client-go/util/workqueue" ) const ( - watchResourcesRetryTimeout = 10 * time.Second + watchResourcesRetryTimeout = 10 * time.Second + updateOperationStateTimeout = 1 * time.Second ) // ApplicationController is the controller for application resources. type ApplicationController struct { namespace string - repoClientset reposerver.Clientset kubeClientset kubernetes.Interface applicationClientset appclientset.Interface - appQueue workqueue.RateLimitingInterface + appRefreshQueue workqueue.RateLimitingInterface + appOperationQueue workqueue.RateLimitingInterface appInformer cache.SharedIndexInformer - appComparator AppComparator + appStateManager AppStateManager + appHealthManager AppHealthManager statusRefreshTimeout time.Duration - apiRepoService apireposerver.RepositoryServiceServer apiClusterService *cluster.Server forceRefreshApps map[string]bool forceRefreshAppsMutex *sync.Mutex @@ -65,24 +62,24 @@ func NewApplicationController( namespace string, kubeClientset kubernetes.Interface, applicationClientset appclientset.Interface, - repoClientset reposerver.Clientset, - apiRepoService apireposerver.RepositoryServiceServer, apiClusterService *cluster.Server, - appComparator AppComparator, + appStateManager AppStateManager, + appHealthManager AppHealthManager, appResyncPeriod time.Duration, config *ApplicationControllerConfig, ) *ApplicationController { - appQueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) + appRefreshQueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) + appOperationQueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) return &ApplicationController{ namespace: namespace, kubeClientset: kubeClientset, applicationClientset: applicationClientset, - repoClientset: repoClientset, - appQueue: appQueue, - apiRepoService: apiRepoService, + appRefreshQueue: appRefreshQueue, + appOperationQueue: appOperationQueue, apiClusterService: apiClusterService, - appComparator: appComparator, - appInformer: newApplicationInformer(applicationClientset, appQueue, appResyncPeriod, config), + appStateManager: appStateManager, + appHealthManager: appHealthManager, + appInformer: newApplicationInformer(applicationClientset, appRefreshQueue, appOperationQueue, appResyncPeriod, config), statusRefreshTimeout: appResyncPeriod, forceRefreshApps: make(map[string]bool), forceRefreshAppsMutex: &sync.Mutex{}, @@ -90,9 +87,9 @@ func NewApplicationController( } // Run starts the Application CRD controller. -func (ctrl *ApplicationController) Run(ctx context.Context, appWorkers int) { +func (ctrl *ApplicationController) Run(ctx context.Context, statusProcessors int, operationProcessors int) { defer runtime.HandleCrash() - defer ctrl.appQueue.ShutDown() + defer ctrl.appRefreshQueue.ShutDown() go ctrl.appInformer.Run(ctx.Done()) go ctrl.watchAppsResources() @@ -102,8 +99,18 @@ func (ctrl *ApplicationController) Run(ctx context.Context, appWorkers int) { return } - for i := 0; i < appWorkers; i++ { - go wait.Until(ctrl.runWorker, time.Second, ctx.Done()) + for i := 0; i < statusProcessors; i++ { + go wait.Until(func() { + for ctrl.processAppRefreshQueueItem() { + } + }, time.Second, ctx.Done()) + } + + for i := 0; i < operationProcessors; i++ { + go wait.Until(func() { + for ctrl.processAppOperationQueueItem() { + } + }, time.Second, ctx.Done()) } <-ctx.Done() @@ -141,7 +148,7 @@ func (ctrl *ApplicationController) watchClusterResources(ctx context.Context, it } if appName, ok := objLabels[common.LabelApplicationName]; ok { ctrl.forceAppRefresh(appName) - ctrl.appQueue.Add(ctrl.namespace + "/" + appName) + ctrl.appRefreshQueue.Add(ctrl.namespace + "/" + appName) } } return fmt.Errorf("resource updates channel has closed") @@ -197,13 +204,98 @@ func retryUntilSucceed(action func() error, desc string, ctx context.Context, ti } } -func (ctrl *ApplicationController) processNextItem() bool { - appKey, shutdown := ctrl.appQueue.Get() +func (ctrl *ApplicationController) processAppOperationQueueItem() bool { + appKey, shutdown := ctrl.appOperationQueue.Get() + if shutdown { + return false + } + + defer ctrl.appOperationQueue.Done(appKey) + + obj, exists, err := ctrl.appInformer.GetIndexer().GetByKey(appKey.(string)) + if err != nil { + log.Errorf("Failed to get application '%s' from informer index: %+v", appKey, err) + return true + } + if !exists { + // This happens after app was deleted, but the work queue still had an entry for it. + return true + } + app, ok := obj.(*appv1.Application) + if !ok { + log.Warnf("Key '%s' in index is not an application", appKey) + return true + } + + if app.Operation != nil && app.Status.OperationState == nil { + state := appv1.OperationState{Status: appv1.OperationStatusInProgress} + ctrl.setOperationState(app.Name, state, app.Operation) + var opError error + if app.Operation.Sync != nil { + syncResult, err := ctrl.appStateManager.SyncAppState(app, app.Operation.Sync.Revision, nil, app.Operation.Sync.DryRun, app.Operation.Sync.Prune) + if err == nil { + state.SyncResult = syncResult + } else { + opError = err + } + } else if app.Operation.Rollback != nil { + var deploymentInfo *appv1.DeploymentInfo + for _, info := range app.Status.RecentDeployments { + if info.ID == app.Operation.Rollback.ID { + deploymentInfo = &info + break + } + } + if deploymentInfo == nil { + opError = status.Errorf(codes.InvalidArgument, "application %s does not have deployment with id %v", app.Name, app.Operation.Rollback.ID) + } else { + rollbackResult, err := ctrl.appStateManager.SyncAppState( + app, deploymentInfo.Revision, &deploymentInfo.ComponentParameterOverrides, app.Operation.Rollback.DryRun, app.Operation.Rollback.Prune) + if err == nil { + state.RollbackResult = rollbackResult + } else { + opError = err + } + } + } else { + opError = errors.New("Invalid operation request") + } + if opError != nil { + state.ErrorDetails = opError.Error() + state.Status = appv1.OperationStatusFailed + } else { + state.Status = appv1.OperationStatusSucceeded + } + ctrl.setOperationState(app.Name, state, nil) + } + + return true +} + +func (ctrl *ApplicationController) setOperationState(appName string, state appv1.OperationState, operation *appv1.Operation) { + retryUntilSucceed(func() error { + patch, err := json.Marshal(map[string]interface{}{ + "status": map[string]interface{}{ + "operationState": state, + }, + "operation": operation, + }) + + if err == nil { + appClient := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(ctrl.namespace) + _, err = appClient.Patch(appName, types.MergePatchType, patch) + } + return err + }, "Update application operation state", context.Background(), updateOperationStateTimeout) +} + +func (ctrl *ApplicationController) processAppRefreshQueueItem() bool { + appKey, shutdown := ctrl.appRefreshQueue.Get() if shutdown { return false } - defer ctrl.appQueue.Done(appKey) + defer ctrl.appRefreshQueue.Done(appKey) obj, exists, err := ctrl.appInformer.GetIndexer().GetByKey(appKey.(string)) if err != nil { @@ -242,188 +334,23 @@ func (ctrl *ApplicationController) processNextItem() bool { } func (ctrl *ApplicationController) tryRefreshAppStatus(app *appv1.Application) (*appv1.ComparisonResult, *[]appv1.ComponentParameter, *appv1.HealthStatus, error) { - conn, client, err := ctrl.repoClientset.NewRepositoryClient() - if err != nil { - return nil, nil, nil, err - } - defer util.Close(conn) - repo, err := ctrl.apiRepoService.Get(context.Background(), &apireposerver.RepoQuery{Repo: app.Spec.Source.RepoURL}) - if err != nil { - // If we couldn't retrieve from the repo service, assume public repositories - repo = &appv1.Repository{ - Repo: app.Spec.Source.RepoURL, - Username: "", - Password: "", - } - } - overrides := make([]*appv1.ComponentParameter, len(app.Spec.Source.ComponentParameterOverrides)) - if app.Spec.Source.ComponentParameterOverrides != nil { - for i := range app.Spec.Source.ComponentParameterOverrides { - item := app.Spec.Source.ComponentParameterOverrides[i] - overrides[i] = &item - } - } - revision := app.Spec.Source.TargetRevision - manifestInfo, err := client.GenerateManifest(context.Background(), &repository.ManifestRequest{ - Repo: repo, - Revision: revision, - Path: app.Spec.Source.Path, - Environment: app.Spec.Source.Environment, - AppLabel: app.Name, - ComponentParameterOverrides: overrides, - }) - if err != nil { - log.Errorf("Failed to load application manifest %v", err) - return nil, nil, nil, err - } - targetObjs := make([]*unstructured.Unstructured, len(manifestInfo.Manifests)) - for i, manifestStr := range manifestInfo.Manifests { - var obj unstructured.Unstructured - if err := json.Unmarshal([]byte(manifestStr), &obj); err != nil { - if err != nil { - return nil, nil, nil, err - } - } - targetObjs[i] = &obj - } - - server, namespace := app.Spec.Destination.Server, app.Spec.Destination.Namespace - comparisonResult, err := ctrl.appComparator.CompareAppState(server, namespace, targetObjs, app) + comparisonResult, manifestInfo, err := ctrl.appStateManager.CompareAppState(app) if err != nil { return nil, nil, nil, err } log.Infof("App %s comparison result: prev: %s. current: %s", app.Name, app.Status.ComparisonResult.Status, comparisonResult.Status) - paramsReq := repository.EnvParamsRequest{ - Repo: repo, - Revision: revision, - Path: app.Spec.Source.Path, - Environment: app.Spec.Source.Environment, - } - params, err := client.GetEnvParams(context.Background(), ¶msReq) - if err != nil { - return nil, nil, nil, err - } - parameters := make([]appv1.ComponentParameter, len(params.Params)) - for i := range params.Params { - parameters[i] = *params.Params[i] + parameters := make([]appv1.ComponentParameter, len(manifestInfo.Params)) + for i := range manifestInfo.Params { + parameters[i] = *manifestInfo.Params[i] } - healthState, err := ctrl.getAppHealth(server, namespace, comparisonResult) + healthState, err := ctrl.appHealthManager.GetAppHealth(app.Spec.Destination.Server, app.Spec.Destination.Namespace, comparisonResult) if err != nil { return nil, nil, nil, err } return comparisonResult, ¶meters, healthState, nil } -func (ctrl *ApplicationController) getServiceHealth(config *rest.Config, namespace string, name string) (*appv1.HealthStatus, error) { - clientSet, err := kubernetes.NewForConfig(config) - if err != nil { - return nil, err - } - service, err := clientSet.CoreV1().Services(namespace).Get(name, metav1.GetOptions{}) - if err != nil { - return nil, err - } - - health := appv1.HealthStatus{Status: appv1.HealthStatusHealthy} - if service.Spec.Type == coreV1.ServiceTypeLoadBalancer { - health.Status = appv1.HealthStatusProgressing - for _, ingress := range service.Status.LoadBalancer.Ingress { - if ingress.Hostname != "" || ingress.IP != "" { - health.Status = appv1.HealthStatusHealthy - break - } - } - } - return &health, nil -} - -func (ctrl *ApplicationController) getDeploymentHealth(config *rest.Config, namespace string, name string) (*appv1.HealthStatus, error) { - clientSet, err := kubernetes.NewForConfig(config) - if err != nil { - return nil, err - } - deploy, err := clientSet.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{}) - if err != nil { - return nil, err - } - health := appv1.HealthStatus{ - Status: appv1.HealthStatusUnknown, - } - for _, condition := range deploy.Status.Conditions { - // deployment is healthy is it successfully progressed - if condition.Type == v1.DeploymentProgressing && condition.Status == "True" { - health.Status = appv1.HealthStatusHealthy - } else if condition.Type == v1.DeploymentReplicaFailure && condition.Status == "True" { - health.Status = appv1.HealthStatusDegraded - } else if condition.Type == v1.DeploymentProgressing && condition.Status == "False" { - health.Status = appv1.HealthStatusDegraded - } else if condition.Type == v1.DeploymentAvailable && condition.Status == "False" { - health.Status = appv1.HealthStatusDegraded - } - if health.Status != appv1.HealthStatusUnknown { - health.StatusDetails = fmt.Sprintf("%s:%s", condition.Reason, condition.Message) - break - } - } - return &health, nil -} - -func (ctrl *ApplicationController) getAppHealth(server string, namespace string, comparisonResult *appv1.ComparisonResult) (*appv1.HealthStatus, error) { - clst, err := ctrl.apiClusterService.Get(context.Background(), &cluster.ClusterQuery{Server: server}) - if err != nil { - return nil, err - } - restConfig := clst.RESTConfig() - - appHealth := appv1.HealthStatus{Status: appv1.HealthStatusHealthy} - for i := range comparisonResult.Resources { - resource := comparisonResult.Resources[i] - if resource.LiveState == "null" { - resource.Health = appv1.HealthStatus{Status: appv1.HealthStatusUnknown} - } else { - var obj unstructured.Unstructured - err := json.Unmarshal([]byte(resource.LiveState), &obj) - if err != nil { - return nil, err - } - switch obj.GetKind() { - case kube.DeploymentKind: - state, err := ctrl.getDeploymentHealth(restConfig, namespace, obj.GetName()) - if err != nil { - return nil, err - } - resource.Health = *state - case kube.ServiceKind: - state, err := ctrl.getServiceHealth(restConfig, namespace, obj.GetName()) - if err != nil { - return nil, err - } - resource.Health = *state - default: - resource.Health = appv1.HealthStatus{Status: appv1.HealthStatusHealthy} - } - - if resource.Health.Status == appv1.HealthStatusProgressing { - if appHealth.Status == appv1.HealthStatusHealthy { - appHealth.Status = appv1.HealthStatusProgressing - } - } else if resource.Health.Status == appv1.HealthStatusDegraded { - if appHealth.Status == appv1.HealthStatusHealthy || appHealth.Status == appv1.HealthStatusProgressing { - appHealth.Status = appv1.HealthStatusDegraded - } - } - } - comparisonResult.Resources[i] = resource - } - return &appHealth, nil -} - -func (ctrl *ApplicationController) runWorker() { - for ctrl.processNextItem() { - } -} - func (ctrl *ApplicationController) updateAppStatus( appName string, namespace string, comparisonResult *appv1.ComparisonResult, parameters *[]appv1.ComponentParameter, healthState appv1.HealthStatus) { statusPatch := make(map[string]interface{}) @@ -446,7 +373,11 @@ func (ctrl *ApplicationController) updateAppStatus( } func newApplicationInformer( - appClientset appclientset.Interface, appQueue workqueue.RateLimitingInterface, appResyncPeriod time.Duration, config *ApplicationControllerConfig) cache.SharedIndexInformer { + appClientset appclientset.Interface, + appQueue workqueue.RateLimitingInterface, + appOperationQueue workqueue.RateLimitingInterface, + appResyncPeriod time.Duration, + config *ApplicationControllerConfig) cache.SharedIndexInformer { appInformerFactory := appinformers.NewFilteredSharedInformerFactory( appClientset, @@ -476,12 +407,14 @@ func newApplicationInformer( key, err := cache.MetaNamespaceKeyFunc(obj) if err == nil { appQueue.Add(key) + appOperationQueue.Add(key) } }, UpdateFunc: func(old, new interface{}) { key, err := cache.MetaNamespaceKeyFunc(new) if err == nil { appQueue.Add(key) + appOperationQueue.Add(key) } }, DeleteFunc: func(obj interface{}) { diff --git a/controller/health.go b/controller/health.go new file mode 100644 index 0000000000000..842776178f840 --- /dev/null +++ b/controller/health.go @@ -0,0 +1,138 @@ +package controller + +import ( + "context" + "encoding/json" + "fmt" + + appv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" + "github.com/argoproj/argo-cd/server/cluster" + "github.com/argoproj/argo-cd/util/kube" + "k8s.io/api/apps/v1" + coreV1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" +) + +const ( + maxRecentDeploymentsCnt = 5 +) + +type AppHealthManager interface { + GetAppHealth(server string, namespace string, comparisonResult *appv1.ComparisonResult) (*appv1.HealthStatus, error) +} + +type kubeAppHealthManager struct { + clusterService cluster.ClusterServiceServer + namespace string +} + +func NewAppHealthManager(clusterService cluster.ClusterServiceServer, + namespace string) AppHealthManager { + return &kubeAppHealthManager{clusterService: clusterService, namespace: namespace} +} + +func (ctrl *kubeAppHealthManager) getServiceHealth(config *rest.Config, namespace string, name string) (*appv1.HealthStatus, error) { + clientSet, err := kubernetes.NewForConfig(config) + if err != nil { + return nil, err + } + service, err := clientSet.CoreV1().Services(namespace).Get(name, metav1.GetOptions{}) + if err != nil { + return nil, err + } + health := appv1.HealthStatus{Status: appv1.HealthStatusHealthy} + if service.Spec.Type == coreV1.ServiceTypeLoadBalancer { + health.Status = appv1.HealthStatusProgressing + for _, ingress := range service.Status.LoadBalancer.Ingress { + if ingress.Hostname != "" || ingress.IP != "" { + health.Status = appv1.HealthStatusHealthy + break + } + } + } + return &health, nil +} + +func (ctrl *kubeAppHealthManager) getDeploymentHealth(config *rest.Config, namespace string, name string) (*appv1.HealthStatus, error) { + clientSet, err := kubernetes.NewForConfig(config) + if err != nil { + return nil, err + } + deploy, err := clientSet.AppsV1().Deployments(namespace).Get(name, metav1.GetOptions{}) + if err != nil { + return nil, err + } + health := appv1.HealthStatus{ + Status: appv1.HealthStatusUnknown, + } + for _, condition := range deploy.Status.Conditions { + // deployment is healthy is it successfully progressed + if condition.Type == v1.DeploymentProgressing && condition.Status == "True" { + health.Status = appv1.HealthStatusHealthy + } else if condition.Type == v1.DeploymentReplicaFailure && condition.Status == "True" { + health.Status = appv1.HealthStatusDegraded + } else if condition.Type == v1.DeploymentProgressing && condition.Status == "False" { + health.Status = appv1.HealthStatusDegraded + } else if condition.Type == v1.DeploymentAvailable && condition.Status == "False" { + health.Status = appv1.HealthStatusDegraded + } + if health.Status != appv1.HealthStatusUnknown { + health.StatusDetails = fmt.Sprintf("%s:%s", condition.Reason, condition.Message) + break + } + } + return &health, nil +} + +func (ctrl *kubeAppHealthManager) GetAppHealth(server string, namespace string, comparisonResult *appv1.ComparisonResult) (*appv1.HealthStatus, error) { + clst, err := ctrl.clusterService.Get(context.Background(), &cluster.ClusterQuery{Server: server}) + if err != nil { + return nil, err + } + restConfig := clst.RESTConfig() + + appHealth := appv1.HealthStatus{Status: appv1.HealthStatusHealthy} + for i := range comparisonResult.Resources { + resource := comparisonResult.Resources[i] + if resource.LiveState == "null" { + resource.Health = appv1.HealthStatus{Status: appv1.HealthStatusUnknown} + } else { + var obj unstructured.Unstructured + err := json.Unmarshal([]byte(resource.LiveState), &obj) + if err != nil { + return nil, err + } + switch obj.GetKind() { + case kube.DeploymentKind: + state, err := ctrl.getDeploymentHealth(restConfig, namespace, obj.GetName()) + if err != nil { + return nil, err + } + resource.Health = *state + case kube.ServiceKind: + state, err := ctrl.getServiceHealth(restConfig, namespace, obj.GetName()) + if err != nil { + return nil, err + } + resource.Health = *state + default: + resource.Health = appv1.HealthStatus{Status: appv1.HealthStatusHealthy} + } + + if resource.Health.Status == appv1.HealthStatusProgressing { + if appHealth.Status == appv1.HealthStatusHealthy { + appHealth.Status = appv1.HealthStatusProgressing + } + } else if resource.Health.Status == appv1.HealthStatusDegraded { + if appHealth.Status == appv1.HealthStatusHealthy || appHealth.Status == appv1.HealthStatusProgressing { + appHealth.Status = appv1.HealthStatusDegraded + } + } + } + comparisonResult.Resources[i] = resource + } + return &appHealth, nil +} diff --git a/controller/mocks/AppComparator.go b/controller/mocks/AppComparator.go deleted file mode 100644 index 5509dbdf018ac..0000000000000 --- a/controller/mocks/AppComparator.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by mockery v1.0.0 -package mocks - -import mock "github.com/stretchr/testify/mock" -import v1alpha1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" - -// AppComparator is an autogenerated mock type for the AppComparator type -type AppComparator struct { - mock.Mock -} - -// CompareAppState provides a mock function with given fields: appRepoPath, app -func (_m *AppComparator) CompareAppState(appRepoPath string, app *v1alpha1.Application) (*v1alpha1.ComparisonResult, error) { - ret := _m.Called(appRepoPath, app) - - var r0 *v1alpha1.ComparisonResult - if rf, ok := ret.Get(0).(func(string, *v1alpha1.Application) *v1alpha1.ComparisonResult); ok { - r0 = rf(appRepoPath, app) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*v1alpha1.ComparisonResult) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, *v1alpha1.Application) error); ok { - r1 = rf(appRepoPath, app) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/controller/state.go b/controller/state.go new file mode 100644 index 0000000000000..ac05157f21734 --- /dev/null +++ b/controller/state.go @@ -0,0 +1,469 @@ +package controller + +import ( + "context" + "encoding/json" + "fmt" + "time" + + "github.com/argoproj/argo-cd/common" + "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" + appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" + "github.com/argoproj/argo-cd/reposerver" + "github.com/argoproj/argo-cd/reposerver/repository" + "github.com/argoproj/argo-cd/server/cluster" + apirepository "github.com/argoproj/argo-cd/server/repository" + "github.com/argoproj/argo-cd/util" + "github.com/argoproj/argo-cd/util/diff" + kubeutil "github.com/argoproj/argo-cd/util/kube" + log "github.com/sirupsen/logrus" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/discovery" + "k8s.io/client-go/dynamic" +) + +// AppStateManager defines methods which allow to compare application spec and actual application state. +type AppStateManager interface { + CompareAppState(app *v1alpha1.Application) (*v1alpha1.ComparisonResult, *repository.ManifestResponse, error) + SyncAppState(app *v1alpha1.Application, revision string, overrides *[]v1alpha1.ComponentParameter, dryRun bool, prune bool) (*v1alpha1.SyncOperationResult, error) +} + +// KsonnetAppStateManager allows to compare application using KSonnet CLI +type KsonnetAppStateManager struct { + clusterService cluster.ClusterServiceServer + repoService apirepository.RepositoryServiceServer + appclientset appclientset.Interface + repoClientset reposerver.Clientset + namespace string +} + +// groupLiveObjects deduplicate list of kubernetes resources and choose correct version of resource: if resource has corresponding expected application resource then method pick +// kubernetes resource with matching version, otherwise chooses single kubernetes resource with any version +func (ks *KsonnetAppStateManager) groupLiveObjects(liveObjs []*unstructured.Unstructured, targetObjs []*unstructured.Unstructured) map[string]*unstructured.Unstructured { + targetByFullName := make(map[string]*unstructured.Unstructured) + for _, obj := range targetObjs { + targetByFullName[getResourceFullName(obj)] = obj + } + + liveListByFullName := make(map[string][]*unstructured.Unstructured) + for _, obj := range liveObjs { + list := liveListByFullName[getResourceFullName(obj)] + if list == nil { + list = make([]*unstructured.Unstructured, 0) + } + list = append(list, obj) + liveListByFullName[getResourceFullName(obj)] = list + } + + liveByFullName := make(map[string]*unstructured.Unstructured) + + for fullName, list := range liveListByFullName { + targetObj := targetByFullName[fullName] + var liveObj *unstructured.Unstructured + if targetObj != nil { + for i := range list { + if list[i].GetAPIVersion() == targetObj.GetAPIVersion() { + liveObj = list[i] + break + } + } + } else { + liveObj = list[0] + } + if liveObj != nil { + liveByFullName[getResourceFullName(liveObj)] = liveObj + } + } + return liveByFullName +} + +// CompareAppState compares application spec and real app state using KSonnet +func (ks *KsonnetAppStateManager) CompareAppState(app *v1alpha1.Application) (*v1alpha1.ComparisonResult, *repository.ManifestResponse, error) { + repo := ks.getRepo(app.Spec.Source.RepoURL) + conn, repoClient, err := ks.repoClientset.NewRepositoryClient() + if err != nil { + return nil, nil, err + } + defer util.Close(conn) + overrides := make([]*v1alpha1.ComponentParameter, len(app.Spec.Source.ComponentParameterOverrides)) + if app.Spec.Source.ComponentParameterOverrides != nil { + for i := range app.Spec.Source.ComponentParameterOverrides { + item := app.Spec.Source.ComponentParameterOverrides[i] + overrides[i] = &item + } + } + + manifestInfo, err := repoClient.GenerateManifest(context.Background(), &repository.ManifestRequest{ + Repo: repo, + Environment: app.Spec.Source.Environment, + Path: app.Spec.Source.Path, + Revision: app.Spec.Source.TargetRevision, + ComponentParameterOverrides: overrides, + AppLabel: app.Name, + }) + if err != nil { + return nil, nil, err + } + + targetObjs := make([]*unstructured.Unstructured, len(manifestInfo.Manifests)) + for i, manifest := range manifestInfo.Manifests { + obj, err := v1alpha1.UnmarshalToUnstructured(manifest) + if err != nil { + return nil, nil, err + } + targetObjs[i] = obj + } + + server, namespace := app.Spec.Destination.Server, app.Spec.Destination.Namespace + + log.Infof("Comparing app %s state in cluster %s (namespace: %s)", app.ObjectMeta.Name, server, namespace) + // Get the REST config for the cluster corresponding to the environment + clst, err := ks.clusterService.Get(context.Background(), &cluster.ClusterQuery{Server: server}) + if err != nil { + return nil, nil, err + } + restConfig := clst.RESTConfig() + + // Retrieve the live versions of the objects + liveObjs, err := kubeutil.GetResourcesWithLabel(restConfig, namespace, common.LabelApplicationName, app.Name) + if err != nil { + return nil, nil, err + } + + liveObjByFullName := ks.groupLiveObjects(liveObjs, targetObjs) + + controlledLiveObj := make([]*unstructured.Unstructured, len(targetObjs)) + + // Move live resources which have corresponding target object to controlledLiveObj + dynClientPool := dynamic.NewDynamicClientPool(restConfig) + disco, err := discovery.NewDiscoveryClientForConfig(restConfig) + if err != nil { + return nil, nil, err + } + for i, targetObj := range targetObjs { + fullName := getResourceFullName(targetObj) + liveObj := liveObjByFullName[fullName] + if liveObj == nil { + // If we get here, it indicates we did not find the live resource when querying using + // our app label. However, it is possible that the resource was created/modified outside + // of ArgoCD. In order to determine that it is truly missing, we fall back to perform a + // direct lookup of the resource by name. See issue #141 + gvk := targetObj.GroupVersionKind() + dclient, err := dynClientPool.ClientForGroupVersionKind(gvk) + if err != nil { + return nil, nil, err + } + apiResource, err := kubeutil.ServerResourceForGroupVersionKind(disco, gvk) + if err != nil { + return nil, nil, err + } + liveObj, err = kubeutil.GetLiveResource(dclient, targetObj, apiResource, namespace) + if err != nil { + return nil, nil, err + } + } + controlledLiveObj[i] = liveObj + delete(liveObjByFullName, fullName) + } + + // Move root level live resources to controlledLiveObj and add nil to targetObjs to indicate that target object is missing + for fullName := range liveObjByFullName { + liveObj := liveObjByFullName[fullName] + if !hasParent(liveObj) { + targetObjs = append(targetObjs, nil) + controlledLiveObj = append(controlledLiveObj, liveObj) + } + } + + // Do the actual comparison + diffResults, err := diff.DiffArray(targetObjs, controlledLiveObj) + if err != nil { + return nil, nil, err + } + comparisonStatus := v1alpha1.ComparisonStatusSynced + + resources := make([]v1alpha1.ResourceState, len(targetObjs)) + for i := 0; i < len(targetObjs); i++ { + resState := v1alpha1.ResourceState{ + ChildLiveResources: make([]v1alpha1.ResourceNode, 0), + } + diffResult := diffResults.Diffs[i] + if diffResult.Modified { + // Set resource state to 'OutOfSync' since target and corresponding live resource are different + resState.Status = v1alpha1.ComparisonStatusOutOfSync + comparisonStatus = v1alpha1.ComparisonStatusOutOfSync + } else { + resState.Status = v1alpha1.ComparisonStatusSynced + } + + if targetObjs[i] == nil { + resState.TargetState = "null" + // Set resource state to 'OutOfSync' since target resource is missing and live resource is unexpected + resState.Status = v1alpha1.ComparisonStatusOutOfSync + comparisonStatus = v1alpha1.ComparisonStatusOutOfSync + } else { + targetObjBytes, err := json.Marshal(targetObjs[i].Object) + if err != nil { + return nil, nil, err + } + resState.TargetState = string(targetObjBytes) + } + + if controlledLiveObj[i] == nil { + resState.LiveState = "null" + // Set resource state to 'OutOfSync' since target resource present but corresponding live resource is missing + resState.Status = v1alpha1.ComparisonStatusOutOfSync + comparisonStatus = v1alpha1.ComparisonStatusOutOfSync + } else { + liveObjBytes, err := json.Marshal(controlledLiveObj[i].Object) + if err != nil { + return nil, nil, err + } + resState.LiveState = string(liveObjBytes) + } + + resources[i] = resState + } + + for i, resource := range resources { + liveResource := controlledLiveObj[i] + if liveResource != nil { + childResources, err := getChildren(liveResource, liveObjByFullName) + if err != nil { + return nil, nil, err + } + resource.ChildLiveResources = childResources + resources[i] = resource + } + } + compResult := v1alpha1.ComparisonResult{ + ComparedTo: app.Spec.Source, + ComparedAt: metav1.Time{Time: time.Now().UTC()}, + Server: clst.Server, + Namespace: namespace, + Resources: resources, + Status: comparisonStatus, + } + return &compResult, manifestInfo, nil +} + +func hasParent(obj *unstructured.Unstructured) bool { + // TODO: remove special case after Service and Endpoint get explicit relationship ( https://github.com/kubernetes/kubernetes/issues/28483 ) + return obj.GetKind() == kubeutil.EndpointsKind || metav1.GetControllerOf(obj) != nil +} + +func isControlledBy(obj *unstructured.Unstructured, parent *unstructured.Unstructured) bool { + // TODO: remove special case after Service and Endpoint get explicit relationship ( https://github.com/kubernetes/kubernetes/issues/28483 ) + if obj.GetKind() == kubeutil.EndpointsKind && parent.GetKind() == kubeutil.ServiceKind { + return obj.GetName() == parent.GetName() + } + return metav1.IsControlledBy(obj, parent) +} + +func getChildren(parent *unstructured.Unstructured, liveObjByFullName map[string]*unstructured.Unstructured) ([]v1alpha1.ResourceNode, error) { + children := make([]v1alpha1.ResourceNode, 0) + for fullName, obj := range liveObjByFullName { + if isControlledBy(obj, parent) { + delete(liveObjByFullName, fullName) + childResource := v1alpha1.ResourceNode{} + json, err := json.Marshal(obj) + if err != nil { + return nil, err + } + childResource.State = string(json) + childResourceChildren, err := getChildren(obj, liveObjByFullName) + if err != nil { + return nil, err + } + childResource.Children = childResourceChildren + children = append(children, childResource) + } + } + return children, nil +} + +func getResourceFullName(obj *unstructured.Unstructured) string { + return fmt.Sprintf("%s:%s", obj.GetKind(), obj.GetName()) +} + +func (s *KsonnetAppStateManager) SyncAppState( + app *v1alpha1.Application, revision string, overrides *[]v1alpha1.ComponentParameter, dryRun bool, prune bool) (*v1alpha1.SyncOperationResult, error) { + + if revision != "" { + app.Spec.Source.TargetRevision = revision + } + + if overrides != nil { + app.Spec.Source.ComponentParameterOverrides = *overrides + } + + res, manifest, err := s.syncAppResources(app, dryRun, prune) + if err != nil { + return nil, err + } + if !dryRun { + err = s.persistDeploymentInfo(app, manifest.Revision, manifest.Params, nil) + if err != nil { + return nil, err + } + } + return res, err +} + +func (s *KsonnetAppStateManager) getRepo(repoURL string) *v1alpha1.Repository { + repo, err := s.repoService.Get(context.Background(), &apirepository.RepoQuery{Repo: repoURL}) + if err != nil { + // If we couldn't retrieve from the repo service, assume public repositories + repo = &v1alpha1.Repository{Repo: repoURL} + } + return repo +} + +func (s *KsonnetAppStateManager) persistDeploymentInfo( + app *v1alpha1.Application, revision string, envParams []*v1alpha1.ComponentParameter, overrides *[]v1alpha1.ComponentParameter) error { + + params := make([]v1alpha1.ComponentParameter, len(envParams)) + for i := range envParams { + param := *envParams[i] + params[i] = param + } + var nextId int64 = 0 + if len(app.Status.RecentDeployments) > 0 { + nextId = app.Status.RecentDeployments[len(app.Status.RecentDeployments)-1].ID + 1 + } + recentDeployments := append(app.Status.RecentDeployments, v1alpha1.DeploymentInfo{ + ComponentParameterOverrides: app.Spec.Source.ComponentParameterOverrides, + Revision: revision, + Params: params, + DeployedAt: metav1.NewTime(time.Now()), + ID: nextId, + }) + + if len(recentDeployments) > maxRecentDeploymentsCnt { + recentDeployments = recentDeployments[1 : maxRecentDeploymentsCnt+1] + } + + patch, err := json.Marshal(map[string]map[string][]v1alpha1.DeploymentInfo{ + "status": { + "recentDeployments": recentDeployments, + }, + }) + if err != nil { + return err + } + _, err = s.appclientset.ArgoprojV1alpha1().Applications(s.namespace).Patch(app.Name, types.MergePatchType, patch) + return err +} + +func (s *KsonnetAppStateManager) syncAppResources( + app *v1alpha1.Application, + dryRun bool, + prune bool) (*v1alpha1.SyncOperationResult, *repository.ManifestResponse, error) { + + comparison, manifestInfo, err := s.CompareAppState(app) + if err != nil { + return nil, nil, err + } + + clst, err := s.clusterService.Get(context.Background(), &cluster.ClusterQuery{Server: comparison.Server}) + if err != nil { + return nil, nil, err + } + config := clst.RESTConfig() + + var syncRes v1alpha1.SyncOperationResult + syncRes.Resources = make([]*v1alpha1.ResourceDetails, 0) + for _, resourceState := range comparison.Resources { + var liveObj, targetObj *unstructured.Unstructured + + if resourceState.LiveState != "null" { + liveObj = &unstructured.Unstructured{} + err = json.Unmarshal([]byte(resourceState.LiveState), liveObj) + if err != nil { + return nil, nil, err + } + } + + if resourceState.TargetState != "null" { + targetObj = &unstructured.Unstructured{} + err = json.Unmarshal([]byte(resourceState.TargetState), targetObj) + if err != nil { + return nil, nil, err + } + } + + needsCreate := liveObj == nil + needsDelete := targetObj == nil + + obj := targetObj + if obj == nil { + obj = liveObj + } + resDetails := v1alpha1.ResourceDetails{ + Name: obj.GetName(), + Kind: obj.GetKind(), + Namespace: comparison.Namespace, + } + + if resourceState.Status == v1alpha1.ComparisonStatusSynced { + resDetails.Message = fmt.Sprintf("already synced") + } else if dryRun { + if needsCreate { + resDetails.Message = fmt.Sprintf("will create") + } else if needsDelete { + if prune { + resDetails.Message = fmt.Sprintf("will delete") + } else { + resDetails.Message = fmt.Sprintf("will be ignored (should be deleted)") + } + } else { + resDetails.Message = fmt.Sprintf("will update") + } + } else { + if needsDelete { + if prune { + err = kubeutil.DeleteResource(config, liveObj, comparison.Namespace) + if err != nil { + return nil, nil, err + } + + resDetails.Message = fmt.Sprintf("deleted") + } else { + resDetails.Message = fmt.Sprintf("ignored (should be deleted)") + } + } else { + _, err := kubeutil.ApplyResource(config, targetObj, comparison.Namespace) + if err != nil { + return nil, nil, err + } + if needsCreate { + resDetails.Message = fmt.Sprintf("created") + } else { + resDetails.Message = fmt.Sprintf("updated") + } + } + } + syncRes.Resources = append(syncRes.Resources, &resDetails) + } + syncRes.Message = "successfully synced" + return &syncRes, manifestInfo, nil +} + +// NewAppStateManager creates new instance of Ksonnet app comparator +func NewAppStateManager( + clusterService cluster.ClusterServiceServer, + repoService apirepository.RepositoryServiceServer, + appclientset appclientset.Interface, + repoClientset reposerver.Clientset, + namespace string, +) AppStateManager { + return &KsonnetAppStateManager{ + clusterService: clusterService, + repoService: repoService, + appclientset: appclientset, + repoClientset: repoClientset, + namespace: namespace, + } +} diff --git a/pkg/apis/application/v1alpha1/generated.pb.go b/pkg/apis/application/v1alpha1/generated.pb.go index e749d84b14a74..7cab2ca185e6b 100644 --- a/pkg/apis/application/v1alpha1/generated.pb.go +++ b/pkg/apis/application/v1alpha1/generated.pb.go @@ -22,10 +22,16 @@ ComponentParameter DeploymentInfo HealthStatus + Operation + OperationState Repository RepositoryList + ResourceDetails ResourceNode ResourceState + RollbackOperation + SyncOperation + SyncOperationResult TLSClientConfig */ package v1alpha1 @@ -108,25 +114,49 @@ func (m *HealthStatus) Reset() { *m = HealthStatus{} } func (*HealthStatus) ProtoMessage() {} func (*HealthStatus) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{13} } +func (m *Operation) Reset() { *m = Operation{} } +func (*Operation) ProtoMessage() {} +func (*Operation) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{14} } + +func (m *OperationState) Reset() { *m = OperationState{} } +func (*OperationState) ProtoMessage() {} +func (*OperationState) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{15} } + func (m *Repository) Reset() { *m = Repository{} } func (*Repository) ProtoMessage() {} -func (*Repository) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{14} } +func (*Repository) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{16} } func (m *RepositoryList) Reset() { *m = RepositoryList{} } func (*RepositoryList) ProtoMessage() {} -func (*RepositoryList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{15} } +func (*RepositoryList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{17} } + +func (m *ResourceDetails) Reset() { *m = ResourceDetails{} } +func (*ResourceDetails) ProtoMessage() {} +func (*ResourceDetails) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{18} } func (m *ResourceNode) Reset() { *m = ResourceNode{} } func (*ResourceNode) ProtoMessage() {} -func (*ResourceNode) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{16} } +func (*ResourceNode) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{19} } func (m *ResourceState) Reset() { *m = ResourceState{} } func (*ResourceState) ProtoMessage() {} -func (*ResourceState) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{17} } +func (*ResourceState) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{20} } + +func (m *RollbackOperation) Reset() { *m = RollbackOperation{} } +func (*RollbackOperation) ProtoMessage() {} +func (*RollbackOperation) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{21} } + +func (m *SyncOperation) Reset() { *m = SyncOperation{} } +func (*SyncOperation) ProtoMessage() {} +func (*SyncOperation) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{22} } + +func (m *SyncOperationResult) Reset() { *m = SyncOperationResult{} } +func (*SyncOperationResult) ProtoMessage() {} +func (*SyncOperationResult) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{23} } func (m *TLSClientConfig) Reset() { *m = TLSClientConfig{} } func (*TLSClientConfig) ProtoMessage() {} -func (*TLSClientConfig) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{18} } +func (*TLSClientConfig) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{24} } func init() { proto.RegisterType((*Application)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Application") @@ -143,10 +173,16 @@ func init() { proto.RegisterType((*ComponentParameter)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ComponentParameter") proto.RegisterType((*DeploymentInfo)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.DeploymentInfo") proto.RegisterType((*HealthStatus)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.HealthStatus") + proto.RegisterType((*Operation)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Operation") + proto.RegisterType((*OperationState)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.OperationState") proto.RegisterType((*Repository)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Repository") proto.RegisterType((*RepositoryList)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.RepositoryList") + proto.RegisterType((*ResourceDetails)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ResourceDetails") proto.RegisterType((*ResourceNode)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ResourceNode") proto.RegisterType((*ResourceState)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ResourceState") + proto.RegisterType((*RollbackOperation)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.RollbackOperation") + proto.RegisterType((*SyncOperation)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.SyncOperation") + proto.RegisterType((*SyncOperationResult)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.SyncOperationResult") proto.RegisterType((*TLSClientConfig)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.TLSClientConfig") } func (m *Application) Marshal() (dAtA []byte, err error) { @@ -188,6 +224,16 @@ func (m *Application) MarshalTo(dAtA []byte) (int, error) { return 0, err } i += n3 + if m.Operation != nil { + dAtA[i] = 0x22 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Operation.Size())) + n4, err := m.Operation.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n4 + } return i, nil } @@ -235,11 +281,11 @@ func (m *ApplicationList) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n4, err := m.ListMeta.MarshalTo(dAtA[i:]) + n5, err := m.ListMeta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n4 + i += n5 if len(m.Items) > 0 { for _, msg := range m.Items { dAtA[i] = 0x12 @@ -319,19 +365,19 @@ func (m *ApplicationSpec) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Source.Size())) - n5, err := m.Source.MarshalTo(dAtA[i:]) + n6, err := m.Source.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n5 + i += n6 dAtA[i] = 0x12 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Destination.Size())) - n6, err := m.Destination.MarshalTo(dAtA[i:]) + n7, err := m.Destination.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n6 + i += n7 dAtA[i] = 0x1a i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.SyncPolicy))) @@ -357,11 +403,11 @@ func (m *ApplicationStatus) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ComparisonResult.Size())) - n7, err := m.ComparisonResult.MarshalTo(dAtA[i:]) + n8, err := m.ComparisonResult.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n7 + i += n8 if len(m.RecentDeployments) > 0 { for _, msg := range m.RecentDeployments { dAtA[i] = 0x12 @@ -389,11 +435,21 @@ func (m *ApplicationStatus) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Health.Size())) - n8, err := m.Health.MarshalTo(dAtA[i:]) + n9, err := m.Health.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n8 + i += n9 + if m.OperationState != nil { + dAtA[i] = 0x2a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.OperationState.Size())) + n10, err := m.OperationState.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n10 + } return i, nil } @@ -419,11 +475,11 @@ func (m *ApplicationWatchEvent) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Application.Size())) - n9, err := m.Application.MarshalTo(dAtA[i:]) + n11, err := m.Application.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n9 + i += n11 return i, nil } @@ -453,11 +509,11 @@ func (m *Cluster) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Config.Size())) - n10, err := m.Config.MarshalTo(dAtA[i:]) + n12, err := m.Config.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n12 return i, nil } @@ -491,11 +547,11 @@ func (m *ClusterConfig) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.TLSClientConfig.Size())) - n11, err := m.TLSClientConfig.MarshalTo(dAtA[i:]) + n13, err := m.TLSClientConfig.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n13 return i, nil } @@ -517,11 +573,11 @@ func (m *ClusterList) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n12, err := m.ListMeta.MarshalTo(dAtA[i:]) + n14, err := m.ListMeta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n14 if len(m.Items) > 0 { for _, msg := range m.Items { dAtA[i] = 0x12 @@ -555,19 +611,19 @@ func (m *ComparisonResult) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ComparedAt.Size())) - n13, err := m.ComparedAt.MarshalTo(dAtA[i:]) + n15, err := m.ComparedAt.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n13 + i += n15 dAtA[i] = 0x12 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ComparedTo.Size())) - n14, err := m.ComparedTo.MarshalTo(dAtA[i:]) + n16, err := m.ComparedTo.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n16 dAtA[i] = 0x1a i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Server))) @@ -675,11 +731,11 @@ func (m *DeploymentInfo) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.DeployedAt.Size())) - n15, err := m.DeployedAt.MarshalTo(dAtA[i:]) + n17, err := m.DeployedAt.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n15 + i += n17 dAtA[i] = 0x28 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ID)) @@ -712,6 +768,90 @@ func (m *HealthStatus) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *Operation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Operation) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Sync != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Sync.Size())) + n18, err := m.Sync.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n18 + } + if m.Rollback != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Rollback.Size())) + n19, err := m.Rollback.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n19 + } + return i, nil +} + +func (m *OperationState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperationState) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Status))) + i += copy(dAtA[i:], m.Status) + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.ErrorDetails))) + i += copy(dAtA[i:], m.ErrorDetails) + if m.SyncResult != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.SyncResult.Size())) + n20, err := m.SyncResult.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n20 + } + if m.RollbackResult != nil { + dAtA[i] = 0x22 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.RollbackResult.Size())) + n21, err := m.RollbackResult.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n21 + } + return i, nil +} + func (m *Repository) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -764,11 +904,11 @@ func (m *RepositoryList) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n16, err := m.ListMeta.MarshalTo(dAtA[i:]) + n22, err := m.ListMeta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n16 + i += n22 if len(m.Items) > 0 { for _, msg := range m.Items { dAtA[i] = 0x12 @@ -784,6 +924,40 @@ func (m *RepositoryList) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ResourceDetails) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceDetails) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Kind))) + i += copy(dAtA[i:], m.Kind) + dAtA[i] = 0x1a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Namespace))) + i += copy(dAtA[i:], m.Namespace) + dAtA[i] = 0x22 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Message))) + i += copy(dAtA[i:], m.Message) + return i, nil +} + func (m *ResourceNode) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -860,11 +1034,120 @@ func (m *ResourceState) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Health.Size())) - n17, err := m.Health.MarshalTo(dAtA[i:]) + n23, err := m.Health.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n17 + i += n23 + return i, nil +} + +func (m *RollbackOperation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RollbackOperation) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0x8 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.ID)) + dAtA[i] = 0x10 + i++ + if m.Prune { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + dAtA[i] = 0x18 + i++ + if m.DryRun { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + return i, nil +} + +func (m *SyncOperation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SyncOperation) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Revision))) + i += copy(dAtA[i:], m.Revision) + dAtA[i] = 0x10 + i++ + if m.Prune { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + dAtA[i] = 0x18 + i++ + if m.DryRun { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + return i, nil +} + +func (m *SyncOperationResult) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SyncOperationResult) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Message))) + i += copy(dAtA[i:], m.Message) + if len(m.Resources) > 0 { + for _, msg := range m.Resources { + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } return i, nil } @@ -934,6 +1217,10 @@ func (m *Application) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) l = m.Status.Size() n += 1 + l + sovGenerated(uint64(l)) + if m.Operation != nil { + l = m.Operation.Size() + n += 1 + l + sovGenerated(uint64(l)) + } return n } @@ -1012,6 +1299,10 @@ func (m *ApplicationStatus) Size() (n int) { } l = m.Health.Size() n += 1 + l + sovGenerated(uint64(l)) + if m.OperationState != nil { + l = m.OperationState.Size() + n += 1 + l + sovGenerated(uint64(l)) + } return n } @@ -1134,6 +1425,38 @@ func (m *HealthStatus) Size() (n int) { return n } +func (m *Operation) Size() (n int) { + var l int + _ = l + if m.Sync != nil { + l = m.Sync.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Rollback != nil { + l = m.Rollback.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *OperationState) Size() (n int) { + var l int + _ = l + l = len(m.Status) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.ErrorDetails) + n += 1 + l + sovGenerated(uint64(l)) + if m.SyncResult != nil { + l = m.SyncResult.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.RollbackResult != nil { + l = m.RollbackResult.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + func (m *Repository) Size() (n int) { var l int _ = l @@ -1162,6 +1485,20 @@ func (m *RepositoryList) Size() (n int) { return n } +func (m *ResourceDetails) Size() (n int) { + var l int + _ = l + l = len(m.Name) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Kind) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Namespace) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Message) + n += 1 + l + sovGenerated(uint64(l)) + return n +} + func (m *ResourceNode) Size() (n int) { var l int _ = l @@ -1196,17 +1533,50 @@ func (m *ResourceState) Size() (n int) { return n } -func (m *TLSClientConfig) Size() (n int) { +func (m *RollbackOperation) Size() (n int) { var l int _ = l + n += 1 + sovGenerated(uint64(m.ID)) n += 2 - l = len(m.ServerName) - n += 1 + l + sovGenerated(uint64(l)) - if m.CertData != nil { - l = len(m.CertData) - n += 1 + l + sovGenerated(uint64(l)) - } - if m.KeyData != nil { + n += 2 + return n +} + +func (m *SyncOperation) Size() (n int) { + var l int + _ = l + l = len(m.Revision) + n += 1 + l + sovGenerated(uint64(l)) + n += 2 + n += 2 + return n +} + +func (m *SyncOperationResult) Size() (n int) { + var l int + _ = l + l = len(m.Message) + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Resources) > 0 { + for _, e := range m.Resources { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + +func (m *TLSClientConfig) Size() (n int) { + var l int + _ = l + n += 2 + l = len(m.ServerName) + n += 1 + l + sovGenerated(uint64(l)) + if m.CertData != nil { + l = len(m.CertData) + n += 1 + l + sovGenerated(uint64(l)) + } + if m.KeyData != nil { l = len(m.KeyData) n += 1 + l + sovGenerated(uint64(l)) } @@ -1238,6 +1608,7 @@ func (this *Application) String() string { `ObjectMeta:` + strings.Replace(strings.Replace(this.ObjectMeta.String(), "ObjectMeta", "k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta", 1), `&`, ``, 1) + `,`, `Spec:` + strings.Replace(strings.Replace(this.Spec.String(), "ApplicationSpec", "ApplicationSpec", 1), `&`, ``, 1) + `,`, `Status:` + strings.Replace(strings.Replace(this.Status.String(), "ApplicationStatus", "ApplicationStatus", 1), `&`, ``, 1) + `,`, + `Operation:` + strings.Replace(fmt.Sprintf("%v", this.Operation), "Operation", "Operation", 1) + `,`, `}`, }, "") return s @@ -1299,6 +1670,7 @@ func (this *ApplicationStatus) String() string { `RecentDeployments:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.RecentDeployments), "DeploymentInfo", "DeploymentInfo", 1), `&`, ``, 1) + `,`, `Parameters:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Parameters), "ComponentParameter", "ComponentParameter", 1), `&`, ``, 1) + `,`, `Health:` + strings.Replace(strings.Replace(this.Health.String(), "HealthStatus", "HealthStatus", 1), `&`, ``, 1) + `,`, + `OperationState:` + strings.Replace(fmt.Sprintf("%v", this.OperationState), "OperationState", "OperationState", 1) + `,`, `}`, }, "") return s @@ -1403,6 +1775,30 @@ func (this *HealthStatus) String() string { }, "") return s } +func (this *Operation) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Operation{`, + `Sync:` + strings.Replace(fmt.Sprintf("%v", this.Sync), "SyncOperation", "SyncOperation", 1) + `,`, + `Rollback:` + strings.Replace(fmt.Sprintf("%v", this.Rollback), "RollbackOperation", "RollbackOperation", 1) + `,`, + `}`, + }, "") + return s +} +func (this *OperationState) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&OperationState{`, + `Status:` + fmt.Sprintf("%v", this.Status) + `,`, + `ErrorDetails:` + fmt.Sprintf("%v", this.ErrorDetails) + `,`, + `SyncResult:` + strings.Replace(fmt.Sprintf("%v", this.SyncResult), "SyncOperationResult", "SyncOperationResult", 1) + `,`, + `RollbackResult:` + strings.Replace(fmt.Sprintf("%v", this.RollbackResult), "SyncOperationResult", "SyncOperationResult", 1) + `,`, + `}`, + }, "") + return s +} func (this *Repository) String() string { if this == nil { return "nil" @@ -1427,6 +1823,19 @@ func (this *RepositoryList) String() string { }, "") return s } +func (this *ResourceDetails) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ResourceDetails{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Kind:` + fmt.Sprintf("%v", this.Kind) + `,`, + `Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`, + `Message:` + fmt.Sprintf("%v", this.Message) + `,`, + `}`, + }, "") + return s +} func (this *ResourceNode) String() string { if this == nil { return "nil" @@ -1452,6 +1861,41 @@ func (this *ResourceState) String() string { }, "") return s } +func (this *RollbackOperation) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&RollbackOperation{`, + `ID:` + fmt.Sprintf("%v", this.ID) + `,`, + `Prune:` + fmt.Sprintf("%v", this.Prune) + `,`, + `DryRun:` + fmt.Sprintf("%v", this.DryRun) + `,`, + `}`, + }, "") + return s +} +func (this *SyncOperation) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&SyncOperation{`, + `Revision:` + fmt.Sprintf("%v", this.Revision) + `,`, + `Prune:` + fmt.Sprintf("%v", this.Prune) + `,`, + `DryRun:` + fmt.Sprintf("%v", this.DryRun) + `,`, + `}`, + }, "") + return s +} +func (this *SyncOperationResult) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&SyncOperationResult{`, + `Message:` + fmt.Sprintf("%v", this.Message) + `,`, + `Resources:` + strings.Replace(fmt.Sprintf("%v", this.Resources), "ResourceDetails", "ResourceDetails", 1) + `,`, + `}`, + }, "") + return s +} func (this *TLSClientConfig) String() string { if this == nil { return "nil" @@ -1593,6 +2037,39 @@ func (m *Application) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Operation == nil { + m.Operation = &Operation{} + } + if err := m.Operation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) @@ -2320,6 +2797,39 @@ func (m *ApplicationStatus) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperationState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OperationState == nil { + m.OperationState = &OperationState{} + } + if err := m.OperationState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) @@ -3558,7 +4068,7 @@ func (m *HealthStatus) Unmarshal(dAtA []byte) error { } return nil } -func (m *Repository) Unmarshal(dAtA []byte) error { +func (m *Operation) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3581,17 +4091,17 @@ func (m *Repository) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Repository: wiretype end group for non-group") + return fmt.Errorf("proto: Operation: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Repository: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Operation: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Repo", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sync", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -3601,55 +4111,30 @@ func (m *Repository) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Repo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Username", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated + if m.Sync == nil { + m.Sync = &SyncOperation{} } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF + if err := m.Sync.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.Username = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Rollback", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -3659,49 +4144,24 @@ func (m *Repository) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.Password = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SSHPrivateKey", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated + if m.Rollback == nil { + m.Rollback = &RollbackOperation{} } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF + if err := m.Rollback.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.SSHPrivateKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3724,7 +4184,7 @@ func (m *Repository) Unmarshal(dAtA []byte) error { } return nil } -func (m *RepositoryList) Unmarshal(dAtA []byte) error { +func (m *OperationState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3747,17 +4207,17 @@ func (m *RepositoryList) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RepositoryList: wiretype end group for non-group") + return fmt.Errorf("proto: OperationState: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RepositoryList: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: OperationState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -3767,27 +4227,26 @@ func (m *RepositoryList) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Status = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ErrorDetails", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -3797,22 +4256,86 @@ func (m *RepositoryList) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex > l { return io.ErrUnexpectedEOF } - m.Items = append(m.Items, Repository{}) - if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ErrorDetails = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SyncResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SyncResult == nil { + m.SyncResult = &SyncOperationResult{} + } + if err := m.SyncResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RollbackResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RollbackResult == nil { + m.RollbackResult = &SyncOperationResult{} + } + if err := m.RollbackResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -3835,7 +4358,7 @@ func (m *RepositoryList) Unmarshal(dAtA []byte) error { } return nil } -func (m *ResourceNode) Unmarshal(dAtA []byte) error { +func (m *Repository) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3858,15 +4381,15 @@ func (m *ResourceNode) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ResourceNode: wiretype end group for non-group") + return fmt.Errorf("proto: Repository: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceNode: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Repository: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Repo", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3891,13 +4414,13 @@ func (m *ResourceNode) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.State = string(dAtA[iNdEx:postIndex]) + m.Repo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Children", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Username", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -3907,22 +4430,78 @@ func (m *ResourceNode) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex > l { return io.ErrUnexpectedEOF } - m.Children = append(m.Children, ResourceNode{}) - if err := m.Children[len(m.Children)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Username = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Password = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SSHPrivateKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF } + m.SSHPrivateKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3945,7 +4524,7 @@ func (m *ResourceNode) Unmarshal(dAtA []byte) error { } return nil } -func (m *ResourceState) Unmarshal(dAtA []byte) error { +func (m *RepositoryList) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3968,17 +4547,17 @@ func (m *ResourceState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ResourceState: wiretype end group for non-group") + return fmt.Errorf("proto: RepositoryList: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RepositoryList: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TargetState", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -3988,26 +4567,27 @@ func (m *ResourceState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.TargetState = string(dAtA[iNdEx:postIndex]) + if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiveState", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -4017,24 +4597,76 @@ func (m *ResourceState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.LiveState = string(dAtA[iNdEx:postIndex]) + m.Items = append(m.Items, Repository{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ResourceDetails) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceDetails: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceDetails: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4059,13 +4691,13 @@ func (m *ResourceState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Status = ComparisonStatus(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChildLiveResources", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -4075,28 +4707,26 @@ func (m *ResourceState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex > l { return io.ErrUnexpectedEOF } - m.ChildLiveResources = append(m.ChildLiveResources, ResourceNode{}) - if err := m.ChildLiveResources[len(m.ChildLiveResources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Kind = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Health", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -4106,19 +4736,693 @@ func (m *ResourceState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthGenerated + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Namespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ResourceNode) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceNode: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceNode: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.State = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Children", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Children = append(m.Children, ResourceNode{}) + if err := m.Children[len(m.Children)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ResourceState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetState", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TargetState = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiveState", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiveState = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Status = ComparisonStatus(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChildLiveResources", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChildLiveResources = append(m.ChildLiveResources, ResourceNode{}) + if err := m.ChildLiveResources[len(m.ChildLiveResources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Health", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Health.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RollbackOperation) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RollbackOperation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RollbackOperation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Prune", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Prune = bool(v != 0) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DryRun", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.DryRun = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SyncOperation) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SyncOperation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SyncOperation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Revision = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Prune", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Prune = bool(v != 0) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DryRun", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.DryRun = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SyncOperationResult) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SyncOperationResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SyncOperationResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resources", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated } postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Health.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Resources = append(m.Resources, &ResourceDetails{}) + if err := m.Resources[len(m.Resources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4445,108 +5749,128 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 1638 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcd, 0x6f, 0x1b, 0x45, - 0x1b, 0xcf, 0xfa, 0x2b, 0xc9, 0xe3, 0x7c, 0x75, 0x5e, 0xb5, 0xaf, 0xdf, 0x54, 0x72, 0xa2, 0xad, - 0x5e, 0x28, 0x88, 0xae, 0x69, 0xf8, 0x06, 0x09, 0xa9, 0x76, 0x42, 0x1b, 0x92, 0xb6, 0x61, 0xe2, - 0x82, 0x84, 0x10, 0xb0, 0x59, 0x4f, 0xed, 0x6d, 0xec, 0xdd, 0x65, 0x66, 0xec, 0xca, 0x07, 0xa4, - 0x72, 0xe3, 0x00, 0xa8, 0x88, 0xff, 0x82, 0x0b, 0x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xed, 0x60, 0x66, 0xfc, 0x4f, 0x6e, 0x99, - 0x3f, 0x67, 0x52, 0xf9, 0xb6, 0x1d, 0x15, 0x9b, 0xbc, 0x18, 0x95, 0x6d, 0xe3, 0x2a, 0x36, 0x69, - 0x53, 0x2b, 0x15, 0xf9, 0x8c, 0x15, 0x17, 0xfa, 0xdc, 0x80, 0x62, 0x23, 0x29, 0x31, 0xd5, 0x58, - 0xde, 0x19, 0x0f, 0xb7, 0x56, 0xbb, 0x49, 0x2e, 0x68, 0x42, 0xac, 0x53, 0xa3, 0x15, 0x00, 0xd6, - 0xf7, 0x9c, 0x2d, 0xbf, 0xed, 0x3a, 0x7d, 0x95, 0x41, 0x71, 0x37, 0xdc, 0x8e, 0x35, 0x58, 0x43, - 0x99, 0xdf, 0xe5, 0xd2, 0x99, 0x2d, 0x3b, 0x08, 0xfa, 0xda, 0x80, 0x05, 0x11, 0x7e, 0x9b, 0xba, - 0xcc, 0xf7, 0x30, 0x61, 0xdd, 0x36, 0x57, 0x51, 0xdd, 0x18, 0x31, 0x15, 0x74, 0x93, 0xd5, 0x92, - 0xf2, 0x6e, 0x61, 0x50, 0x83, 0x87, 0xe8, 0xd1, 0x4d, 0x03, 0x16, 0x28, 0x71, 0x88, 0xc7, 0x57, - 0x49, 0xd0, 0xf6, 0xfb, 0xb2, 0x4c, 0xc2, 0xe2, 0x5f, 0x1f, 0xc1, 0xa7, 0xc4, 0xd8, 0xba, 0x77, - 0xd5, 0xaf, 0xfe, 0x4f, 0x79, 0x74, 0x0c, 0x0f, 0x50, 0x31, 0x3c, 0xc4, 0x8e, 0x3e, 0x33, 0x00, - 0x82, 0x28, 0x39, 0x45, 0x8f, 0x7f, 0x0c, 0xb5, 0x12, 0x5f, 0x60, 0x2c, 0x62, 0x58, 0x23, 0x45, - 0x3e, 0x14, 0x5a, 0xc4, 0x6e, 0xf3, 0x96, 0x2c, 0xfc, 0xe2, 0xca, 0xf9, 0x11, 0xe8, 0x2f, 0x48, - 0x43, 0x83, 0xd3, 0x25, 0x94, 0x62, 0x45, 0x63, 0xde, 0x33, 0xe0, 0xb8, 0x96, 0x31, 0xef, 0xd9, - 0xdc, 0x69, 0xad, 0xf5, 0x44, 0x38, 0x36, 0x20, 0xc7, 0xfb, 0x01, 0x51, 0xcd, 0xf0, 0x95, 0xa8, - 0xc9, 0xd5, 0xfb, 0x01, 0x79, 0xb0, 0xb7, 0xf4, 0xf4, 0x41, 0x0b, 0xc2, 0x75, 0x61, 0xc1, 0x92, - 0x26, 0x04, 0x14, 0x4b, 0x23, 0xe8, 0x53, 0x28, 0x6a, 0x3e, 0xaa, 0xb2, 0x1a, 0x57, 0x97, 0x8f, - 0x6b, 0x49, 0x13, 0x62, 0x9d, 0xcf, 0xfc, 0xc9, 0x80, 0xc9, 0x5a, 0xbb, 0xcb, 0x38, 0xa1, 0x47, - 0x9e, 0x9a, 0xcb, 0x90, 0x13, 0x13, 0x71, 0xb0, 0xc9, 0x8b, 0x81, 0x89, 0xa5, 0x06, 0x05, 0x50, - 0x70, 0x7c, 0xef, 0xaa, 0xdb, 0x54, 0xfb, 0xc0, 0x85, 0x51, 0x72, 0x25, 0xf4, 0xae, 0x26, 0xed, - 0x25, 0x3e, 0x85, 0xcf, 0x58, 0xf1, 0x98, 0xdf, 0x67, 0x60, 0x36, 0x85, 0x44, 0xcf, 0xc1, 0x54, - 0x97, 0x11, 0x2a, 0x3d, 0x0d, 0xdf, 0x27, 0x1e, 0xb3, 0x57, 0x94, 0x1c, 0xc7, 0x08, 0x81, 0x0e, - 0x6c, 0xc6, 0xae, 0xfb, 0xb4, 0xa1, 0xde, 0x2b, 0x46, 0x6f, 0x29, 0x39, 0x8e, 0x11, 0x62, 0x88, - 0xed, 0x10, 0x9b, 0x12, 0x5a, 0xf7, 0x77, 0x89, 0x37, 0x38, 0xc4, 0xaa, 0x89, 0x0a, 0xeb, 0x38, - 0xf4, 0xa5, 0x01, 0xf3, 0xbc, 0xcd, 0x6a, 0x6d, 0x97, 0x78, 0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x94, 0xaf, 0x8a, 0x4a, - 0x15, 0x57, 0x37, 0x53, 0x9d, 0x91, 0xc9, 0xa5, 0x64, 0x38, 0xd6, 0xa2, 0xff, 0xc3, 0xe4, 0x2e, - 0xe9, 0x4b, 0x60, 0x4e, 0x02, 0x8b, 0xfb, 0x7b, 0x4b, 0x93, 0x1b, 0xa1, 0x08, 0x47, 0x3a, 0x64, - 0x42, 0xc1, 0xb1, 0x25, 0x2a, 0x2f, 0x51, 0x20, 0xbf, 0x11, 0xce, 0x49, 0x90, 0xd2, 0x54, 0xad, - 0x5b, 0x77, 0xcb, 0x13, 0xb7, 0xef, 0x96, 0x27, 0xee, 0xdc, 0x2d, 0x4f, 0xdc, 0xd8, 0x2f, 0x1b, - 0xb7, 0xf6, 0xcb, 0xc6, 0xed, 0xfd, 0xb2, 0x71, 0x67, 0xbf, 0x6c, 0xfc, 0xb9, 0x5f, 0x36, 0x6e, - 0xde, 0x2b, 0x4f, 0xbc, 0x3f, 0x15, 0xc5, 0xef, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x60, - 0x5d, 0xea, 0x3f, 0x17, 0x00, 0x00, + // 1968 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x59, 0xdd, 0x6f, 0x23, 0x57, + 0x15, 0xcf, 0xf5, 0x47, 0x62, 0x1f, 0xe7, 0x63, 0xf7, 0x96, 0x16, 0x93, 0x4a, 0xde, 0x68, 0x2a, + 0x60, 0x8b, 0xa8, 0xcd, 0x2e, 0x5f, 0x05, 0x24, 0xa4, 0xb5, 0x13, 0xba, 0x69, 0xb2, 0xbb, 0xe1, + 0x26, 0x05, 0x09, 0x21, 0x60, 0x32, 0xbe, 0x6b, 0xcf, 0x66, 0x3c, 0x33, 0xbd, 0xf7, 0xda, 0x2b, + 0x4b, 0x80, 0xca, 0x03, 0x12, 0xaa, 0x00, 0x15, 0xf1, 0x5f,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, 0xfc, 0x27, 0x04, 0xcf, 0x7b, 0xd1, + 0x28, 0x8e, 0x42, 0x1a, 0x8a, 0x03, 0x97, 0xb9, 0x23, 0x2a, 0x28, 0xbb, 0x33, 0xa1, 0x8c, 0xf9, + 0x7d, 0xca, 0x9b, 0x55, 0x95, 0xdd, 0x5b, 0x73, 0x64, 0xb7, 0x37, 0xe3, 0xbd, 0xfb, 0x82, 0x09, + 0xee, 0xf9, 0xde, 0xd9, 0xc8, 0xe4, 0xa3, 0xc2, 0x72, 0xde, 0x29, 0xe5, 0xea, 0xed, 0x30, 0xe9, + 0x6f, 0x75, 0x30, 0xa6, 0xda, 0x16, 0xd5, 0xdf, 0xca, 0xa7, 0xd5, 0x2a, 0xea, 0x99, 0x18, 0x2c, + 0xfc, 0x2b, 0x04, 0x8d, 0x7e, 0xd6, 0x62, 0x66, 0x96, 0x7d, 0x77, 0x31, 0xd8, 0x56, 0xef, 0x66, + 0xb5, 0x60, 0x09, 0x89, 0x0d, 0x8d, 0xaf, 0x03, 0xf0, 0x69, 0xe8, 0x1d, 0x44, 0x81, 0xef, 0x4d, + 0x4d, 0x05, 0xa5, 0x03, 0xf8, 0x30, 0xd5, 0x10, 0xcb, 0xca, 0xf9, 0x73, 0x35, 0x5f, 0xd9, 0x7a, + 0x68, 0xfd, 0x0e, 0xc1, 0x25, 0x99, 0x7e, 0x97, 0xf9, 0x3c, 0x0a, 0x09, 0xe5, 0xe3, 0x40, 0x98, + 0xac, 0xee, 0xcd, 0x59, 0x0a, 0xb6, 0xcb, 0x6e, 0xd3, 0x44, 0x77, 0xa9, 0xa8, 0x21, 0x33, 0xf0, + 0xf8, 0x2d, 0x04, 0x97, 0x18, 0xf5, 0x68, 0x28, 0xb6, 0x69, 0x1c, 0x44, 0x53, 0xd5, 0x26, 0xba, + 0xf9, 0x77, 0xe7, 0x88, 0x29, 0x73, 0xb6, 0x1b, 0xde, 0x8d, 0xba, 0x9f, 0x31, 0x11, 0x5d, 0x26, + 0x05, 0x28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0x44, 0x87, 0x1d, 0x58, 0xf6, 0x5c, 0x65, 0x55, 0x55, 0x56, + 0xa0, 0x3e, 0x87, 0xdc, 0x50, 0x46, 0x46, 0xd3, 0x6d, 0x3f, 0x78, 0xd4, 0x5a, 0x7a, 0xf7, 0x51, + 0x6b, 0xe9, 0xbd, 0x47, 0xad, 0xa5, 0x37, 0x4e, 0x5b, 0xe8, 0xc1, 0x69, 0x0b, 0xbd, 0x7b, 0xda, + 0x42, 0xef, 0x9d, 0xb6, 0xd0, 0xbf, 0x4f, 0x5b, 0xe8, 0xad, 0xf7, 0x5b, 0x4b, 0x3f, 0xa8, 0x25, + 0x49, 0xfc, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8d, 0x62, 0xfb, 0xe5, 0x25, 0x1d, 0x00, 0x00, } diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index a4dfa2f44d034..90842fa3eb18c 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -23,6 +23,8 @@ message Application { optional ApplicationSpec spec = 2; optional ApplicationStatus status = 3; + + optional Operation operation = 4; } // ApplicationDestination contains deployment destination information @@ -82,6 +84,8 @@ message ApplicationStatus { repeated ComponentParameter parameters = 3; optional HealthStatus health = 4; + + optional OperationState operationState = 5; } // ApplicationWatchEvent contains information about application change. @@ -177,6 +181,24 @@ message HealthStatus { optional string statusDetails = 2; } +// Operation contains requested operation parameters. +message Operation { + optional SyncOperation sync = 1; + + optional RollbackOperation rollback = 2; +} + +// OperationState contains information about state of currently performing operation on application. +message OperationState { + optional string status = 1; + + optional string errorDetails = 2; + + optional SyncOperationResult syncResult = 3; + + optional SyncOperationResult rollbackResult = 4; +} + // Repository is a Git repository holding application configurations message Repository { optional string repo = 1; @@ -195,6 +217,16 @@ message RepositoryList { repeated Repository items = 2; } +message ResourceDetails { + optional string name = 1; + + optional string kind = 2; + + optional string namespace = 3; + + optional string message = 4; +} + // ResourceNode contains information about live resource and its children message ResourceNode { optional string state = 1; @@ -215,6 +247,30 @@ message ResourceState { optional HealthStatus health = 5; } +message RollbackOperation { + optional int64 id = 1; + + optional bool prune = 2; + + optional bool dryRun = 3; +} + +// SyncOperation contains sync operation details. +message SyncOperation { + optional string revision = 1; + + optional bool prune = 2; + + optional bool dryRun = 3; +} + +// SyncOperationResult represent result of sync operation +message SyncOperationResult { + optional string message = 1; + + repeated ResourceDetails resources = 2; +} + // TLSClientConfig contains settings to enable transport layer security message TLSClientConfig { // Server should be accessed without verifying the TLS certificate. For testing only. diff --git a/pkg/apis/application/v1alpha1/types.go b/pkg/apis/application/v1alpha1/types.go index 91b036bb17d4e..1ff6a27ea46c4 100644 --- a/pkg/apis/application/v1alpha1/types.go +++ b/pkg/apis/application/v1alpha1/types.go @@ -11,6 +11,54 @@ import ( "k8s.io/client-go/rest" ) +// SyncOperation contains sync operation details. +type SyncOperation struct { + Revision string `json:"revision" protobuf:"bytes,1,opt,name=revision"` + Prune bool `json:"prune" protobuf:"bytes,2,opt,name=prune"` + DryRun bool `json:"dryRun" protobuf:"bytes,3,opt,name=dryRun"` +} + +type RollbackOperation struct { + ID int64 `json:"id" protobuf:"bytes,1,opt,name=id"` + Prune bool `json:"prune" protobuf:"bytes,2,opt,name=prune"` + DryRun bool `json:"dryRun" protobuf:"bytes,3,opt,name=dryRun"` +} + +// Operation contains requested operation parameters. +type Operation struct { + Sync *SyncOperation `json:"sync" protobuf:"bytes,1,opt,name=sync"` + Rollback *RollbackOperation `json:"rollback" protobuf:"bytes,2,opt,name=rollback"` +} + +type OperationStatus = string + +const ( + OperationStatusInProgress = "InProgress" + OperationStatusFailed = "Failed" + OperationStatusSucceeded = "Succeeded" +) + +// OperationState contains information about state of currently performing operation on application. +type OperationState struct { + Status OperationStatus `json:"status" protobuf:"bytes,1,opt,name=status"` + ErrorDetails string `json:"errorDetails" protobuf:"bytes,2,opt,name=errorDetails"` + SyncResult *SyncOperationResult `json:"syncResult" protobuf:"bytes,3,opt,name=syncResult"` + RollbackResult *SyncOperationResult `json:"rollbackResult" protobuf:"bytes,4,opt,name=rollbackResult"` +} + +// SyncOperationResult represent result of sync operation +type SyncOperationResult struct { + Message string `json:"message" protobuf:"bytes,1,opt,name=message"` + Resources []*ResourceDetails `json:"resources" protobuf:"bytes,2,opt,name=resources"` +} + +type ResourceDetails struct { + Name string `json:"name" protobuf:"bytes,1,opt,name=name"` + Kind string `json:"kind" protobuf:"bytes,2,opt,name=kind"` + Namespace string `json:"namespace" protobuf:"bytes,3,opt,name=namespace"` + Message string `json:"message" protobuf:"bytes,4,opt,name=message"` +} + // DeploymentInfo contains information relevant to an application deployment type DeploymentInfo struct { Params []ComponentParameter `json:"params" protobuf:"bytes,1,name=params"` @@ -29,6 +77,7 @@ type Application struct { metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` Spec ApplicationSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` Status ApplicationStatus `json:"status" protobuf:"bytes,3,opt,name=status"` + Operation *Operation `json:"operation,omitempty" protobuf:"bytes,4,opt,name=operation"` } // ApplicationWatchEvent contains information about application change. @@ -108,6 +157,7 @@ type ApplicationStatus struct { RecentDeployments []DeploymentInfo `json:"recentDeployments" protobuf:"bytes,2,opt,name=recentDeployment"` Parameters []ComponentParameter `json:"parameters,omitempty" protobuf:"bytes,3,opt,name=parameters"` Health HealthStatus `json:"health,omitempty" protobuf:"bytes,4,opt,name=health"` + OperationState *OperationState `json:"operationState,omitempty" protobuf:"bytes,5,opt,name=operationState"` } // ComparisonResult is a comparison result of application spec and deployed application. diff --git a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go index a3682e4b984cb..449828da92b5f 100644 --- a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go @@ -15,6 +15,15 @@ func (in *Application) DeepCopyInto(out *Application) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) + if in.Operation != nil { + in, out := &in.Operation, &out.Operation + if *in == nil { + *out = nil + } else { + *out = new(Operation) + (*in).DeepCopyInto(*out) + } + } return } @@ -141,6 +150,15 @@ func (in *ApplicationStatus) DeepCopyInto(out *ApplicationStatus) { copy(*out, *in) } out.Health = in.Health + if in.OperationState != nil { + in, out := &in.OperationState, &out.OperationState + if *in == nil { + *out = nil + } else { + *out = new(OperationState) + (*in).DeepCopyInto(*out) + } + } return } @@ -313,6 +331,74 @@ func (in *HealthStatus) DeepCopy() *HealthStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Operation) DeepCopyInto(out *Operation) { + *out = *in + if in.Sync != nil { + in, out := &in.Sync, &out.Sync + if *in == nil { + *out = nil + } else { + *out = new(SyncOperation) + **out = **in + } + } + if in.Rollback != nil { + in, out := &in.Rollback, &out.Rollback + if *in == nil { + *out = nil + } else { + *out = new(RollbackOperation) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Operation. +func (in *Operation) DeepCopy() *Operation { + if in == nil { + return nil + } + out := new(Operation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperationState) DeepCopyInto(out *OperationState) { + *out = *in + if in.SyncResult != nil { + in, out := &in.SyncResult, &out.SyncResult + if *in == nil { + *out = nil + } else { + *out = new(SyncOperationResult) + (*in).DeepCopyInto(*out) + } + } + if in.RollbackResult != nil { + in, out := &in.RollbackResult, &out.RollbackResult + if *in == nil { + *out = nil + } else { + *out = new(SyncOperationResult) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperationState. +func (in *OperationState) DeepCopy() *OperationState { + if in == nil { + return nil + } + out := new(OperationState) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Repository) DeepCopyInto(out *Repository) { *out = *in @@ -351,6 +437,22 @@ func (in *RepositoryList) DeepCopy() *RepositoryList { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceDetails) DeepCopyInto(out *ResourceDetails) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceDetails. +func (in *ResourceDetails) DeepCopy() *ResourceDetails { + if in == nil { + return nil + } + out := new(ResourceDetails) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceNode) DeepCopyInto(out *ResourceNode) { *out = *in @@ -398,6 +500,66 @@ func (in *ResourceState) DeepCopy() *ResourceState { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RollbackOperation) DeepCopyInto(out *RollbackOperation) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RollbackOperation. +func (in *RollbackOperation) DeepCopy() *RollbackOperation { + if in == nil { + return nil + } + out := new(RollbackOperation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncOperation) DeepCopyInto(out *SyncOperation) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncOperation. +func (in *SyncOperation) DeepCopy() *SyncOperation { + if in == nil { + return nil + } + out := new(SyncOperation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncOperationResult) DeepCopyInto(out *SyncOperationResult) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]*ResourceDetails, len(*in)) + for i := range *in { + if (*in)[i] == nil { + (*out)[i] = nil + } else { + (*out)[i] = new(ResourceDetails) + (*in)[i].DeepCopyInto((*out)[i]) + } + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncOperationResult. +func (in *SyncOperationResult) DeepCopy() *SyncOperationResult { + if in == nil { + return nil + } + out := new(SyncOperationResult) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TLSClientConfig) DeepCopyInto(out *TLSClientConfig) { *out = *in diff --git a/reposerver/repository/repository.go b/reposerver/repository/repository.go index 7f611cfcb23af..681efbd1d27bb 100644 --- a/reposerver/repository/repository.go +++ b/reposerver/repository/repository.go @@ -102,6 +102,11 @@ func (s *Service) GenerateManifest(c context.Context, q *ManifestRequest) (*Mani return nil, fmt.Errorf("unable to load application from %s: %v", appPath, err) } + params, err := ksApp.ListEnvParams(q.Environment) + if err != nil { + return nil, err + } + if q.ComponentParameterOverrides != nil { for _, override := range q.ComponentParameterOverrides { err = ksApp.SetComponentParams(q.Environment, override.Component, override.Name, override.Value) @@ -140,6 +145,7 @@ func (s *Service) GenerateManifest(c context.Context, q *ManifestRequest) (*Mani Manifests: manifests, Namespace: env.Destination.Namespace, Server: env.Destination.Server, + Params: params, } err = s.cache.Set(&cache.Item{ Key: cacheKey, @@ -174,62 +180,6 @@ func setAppLabels(target *unstructured.Unstructured, appName string) error { return nil } -// GetEnvParams retrieves Ksonnet environment params in specified repo name and revision -func (s *Service) GetEnvParams(c context.Context, q *EnvParamsRequest) (*EnvParamsResponse, error) { - appRepoPath := tempRepoPath(q.Repo.Repo) - s.repoLock.Lock(appRepoPath) - defer s.repoLock.Unlock(appRepoPath) - - gitClient := s.gitFactory.NewClient(q.Repo.Repo, appRepoPath, q.Repo.Username, q.Repo.Password, q.Repo.SSHPrivateKey) - err := gitClient.Init() - if err != nil { - return nil, err - } - commitSHA, err := gitClient.LsRemote(q.Revision) - if err != nil { - return nil, err - } - cacheKey := envParamCacheKey(commitSHA, q) - var res EnvParamsResponse - err = s.cache.Get(cacheKey, &res) - if err == nil { - log.Infof("env params cache hit: %s", cacheKey) - return &res, nil - } - if err != cache.ErrCacheMiss { - log.Warnf("env params cache error %s: %v", cacheKey, err) - } else { - log.Infof("env params cache miss: %s", cacheKey) - } - - err = checkoutRevision(gitClient, q.Revision) - if err != nil { - return nil, err - } - appPath := path.Join(appRepoPath, q.Path) - ksApp, err := ksutil.NewKsonnetApp(appPath) - if err != nil { - return nil, err - } - target, err := ksApp.ListEnvParams(q.Environment) - if err != nil { - return nil, err - } - - res = EnvParamsResponse{ - Params: target, - } - err = s.cache.Set(&cache.Item{ - Key: cacheKey, - Object: &res, - Expiration: DefaultRepoCacheExpiration, - }) - if err != nil { - log.Warnf("env params cache set error %s: %v", cacheKey, err) - } - return &res, nil -} - // tempRepoPath returns a formulated temporary directory location to clone a repository func tempRepoPath(repo string) string { return path.Join(os.TempDir(), strings.Replace(repo, "/", "_", -1)) @@ -256,7 +206,3 @@ func manifestCacheKey(commitSHA string, q *ManifestRequest) string { pStr, _ := json.Marshal(q.ComponentParameterOverrides) return fmt.Sprintf("mfst|%s|%s|%s|%s", q.Path, q.Environment, commitSHA, string(pStr)) } - -func envParamCacheKey(commitSHA string, q *EnvParamsRequest) string { - return fmt.Sprintf("envparam|%s|%s|%s", q.Path, q.Environment, commitSHA) -} diff --git a/reposerver/repository/repository.pb.go b/reposerver/repository/repository.pb.go index 5b97e627427db..e34945ec3e61f 100644 --- a/reposerver/repository/repository.pb.go +++ b/reposerver/repository/repository.pb.go @@ -10,8 +10,6 @@ It has these top-level messages: ManifestRequest ManifestResponse - EnvParamsRequest - EnvParamsResponse GetFileRequest GetFileResponse */ @@ -99,10 +97,11 @@ func (m *ManifestRequest) GetComponentParameterOverrides() []*github_com_argopro } type ManifestResponse struct { - Manifests []string `protobuf:"bytes,1,rep,name=manifests" json:"manifests,omitempty"` - Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` - Server string `protobuf:"bytes,3,opt,name=server,proto3" json:"server,omitempty"` - Revision string `protobuf:"bytes,4,opt,name=revision,proto3" json:"revision,omitempty"` + Manifests []string `protobuf:"bytes,1,rep,name=manifests" json:"manifests,omitempty"` + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` + Server string `protobuf:"bytes,3,opt,name=server,proto3" json:"server,omitempty"` + Revision string `protobuf:"bytes,4,opt,name=revision,proto3" json:"revision,omitempty"` + Params []*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ComponentParameter `protobuf:"bytes,5,rep,name=params" json:"params,omitempty"` } func (m *ManifestResponse) Reset() { *m = ManifestResponse{} } @@ -138,56 +137,7 @@ func (m *ManifestResponse) GetRevision() string { return "" } -type EnvParamsRequest struct { - Repo *github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Repository `protobuf:"bytes,1,opt,name=repo" json:"repo,omitempty"` - Revision string `protobuf:"bytes,2,opt,name=revision,proto3" json:"revision,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` - Environment string `protobuf:"bytes,4,opt,name=environment,proto3" json:"environment,omitempty"` -} - -func (m *EnvParamsRequest) Reset() { *m = EnvParamsRequest{} } -func (m *EnvParamsRequest) String() string { return proto.CompactTextString(m) } -func (*EnvParamsRequest) ProtoMessage() {} -func (*EnvParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptorRepository, []int{2} } - -func (m *EnvParamsRequest) GetRepo() *github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Repository { - if m != nil { - return m.Repo - } - return nil -} - -func (m *EnvParamsRequest) GetRevision() string { - if m != nil { - return m.Revision - } - return "" -} - -func (m *EnvParamsRequest) GetPath() string { - if m != nil { - return m.Path - } - return "" -} - -func (m *EnvParamsRequest) GetEnvironment() string { - if m != nil { - return m.Environment - } - return "" -} - -type EnvParamsResponse struct { - Params []*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ComponentParameter `protobuf:"bytes,1,rep,name=params" json:"params,omitempty"` -} - -func (m *EnvParamsResponse) Reset() { *m = EnvParamsResponse{} } -func (m *EnvParamsResponse) String() string { return proto.CompactTextString(m) } -func (*EnvParamsResponse) ProtoMessage() {} -func (*EnvParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptorRepository, []int{3} } - -func (m *EnvParamsResponse) GetParams() []*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ComponentParameter { +func (m *ManifestResponse) GetParams() []*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ComponentParameter { if m != nil { return m.Params } @@ -204,7 +154,7 @@ type GetFileRequest struct { func (m *GetFileRequest) Reset() { *m = GetFileRequest{} } func (m *GetFileRequest) String() string { return proto.CompactTextString(m) } func (*GetFileRequest) ProtoMessage() {} -func (*GetFileRequest) Descriptor() ([]byte, []int) { return fileDescriptorRepository, []int{4} } +func (*GetFileRequest) Descriptor() ([]byte, []int) { return fileDescriptorRepository, []int{2} } func (m *GetFileRequest) GetRepo() *github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Repository { if m != nil { @@ -235,7 +185,7 @@ type GetFileResponse struct { func (m *GetFileResponse) Reset() { *m = GetFileResponse{} } func (m *GetFileResponse) String() string { return proto.CompactTextString(m) } func (*GetFileResponse) ProtoMessage() {} -func (*GetFileResponse) Descriptor() ([]byte, []int) { return fileDescriptorRepository, []int{5} } +func (*GetFileResponse) Descriptor() ([]byte, []int) { return fileDescriptorRepository, []int{3} } func (m *GetFileResponse) GetData() []byte { if m != nil { @@ -247,8 +197,6 @@ func (m *GetFileResponse) GetData() []byte { func init() { proto.RegisterType((*ManifestRequest)(nil), "repository.ManifestRequest") proto.RegisterType((*ManifestResponse)(nil), "repository.ManifestResponse") - proto.RegisterType((*EnvParamsRequest)(nil), "repository.EnvParamsRequest") - proto.RegisterType((*EnvParamsResponse)(nil), "repository.EnvParamsResponse") proto.RegisterType((*GetFileRequest)(nil), "repository.GetFileRequest") proto.RegisterType((*GetFileResponse)(nil), "repository.GetFileResponse") } @@ -266,8 +214,6 @@ const _ = grpc.SupportPackageIsVersion4 type RepositoryServiceClient interface { // Generate manifest for application in specified repo name and revision GenerateManifest(ctx context.Context, in *ManifestRequest, opts ...grpc.CallOption) (*ManifestResponse, error) - // Retrieve Ksonnet environment params in specified repo name and revision - GetEnvParams(ctx context.Context, in *EnvParamsRequest, opts ...grpc.CallOption) (*EnvParamsResponse, error) // GetFile returns the file contents at the specified repo and path GetFile(ctx context.Context, in *GetFileRequest, opts ...grpc.CallOption) (*GetFileResponse, error) } @@ -289,15 +235,6 @@ func (c *repositoryServiceClient) GenerateManifest(ctx context.Context, in *Mani return out, nil } -func (c *repositoryServiceClient) GetEnvParams(ctx context.Context, in *EnvParamsRequest, opts ...grpc.CallOption) (*EnvParamsResponse, error) { - out := new(EnvParamsResponse) - err := grpc.Invoke(ctx, "/repository.RepositoryService/GetEnvParams", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *repositoryServiceClient) GetFile(ctx context.Context, in *GetFileRequest, opts ...grpc.CallOption) (*GetFileResponse, error) { out := new(GetFileResponse) err := grpc.Invoke(ctx, "/repository.RepositoryService/GetFile", in, out, c.cc, opts...) @@ -312,8 +249,6 @@ func (c *repositoryServiceClient) GetFile(ctx context.Context, in *GetFileReques type RepositoryServiceServer interface { // Generate manifest for application in specified repo name and revision GenerateManifest(context.Context, *ManifestRequest) (*ManifestResponse, error) - // Retrieve Ksonnet environment params in specified repo name and revision - GetEnvParams(context.Context, *EnvParamsRequest) (*EnvParamsResponse, error) // GetFile returns the file contents at the specified repo and path GetFile(context.Context, *GetFileRequest) (*GetFileResponse, error) } @@ -340,24 +275,6 @@ func _RepositoryService_GenerateManifest_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } -func _RepositoryService_GetEnvParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EnvParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RepositoryServiceServer).GetEnvParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/repository.RepositoryService/GetEnvParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RepositoryServiceServer).GetEnvParams(ctx, req.(*EnvParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _RepositoryService_GetFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetFileRequest) if err := dec(in); err != nil { @@ -384,10 +301,6 @@ var _RepositoryService_serviceDesc = grpc.ServiceDesc{ MethodName: "GenerateManifest", Handler: _RepositoryService_GenerateManifest_Handler, }, - { - MethodName: "GetEnvParams", - Handler: _RepositoryService_GetEnvParams_Handler, - }, { MethodName: "GetFile", Handler: _RepositoryService_GetFile_Handler, @@ -509,73 +422,9 @@ func (m *ManifestResponse) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintRepository(dAtA, i, uint64(len(m.Revision))) i += copy(dAtA[i:], m.Revision) } - return i, nil -} - -func (m *EnvParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EnvParamsRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Repo != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintRepository(dAtA, i, uint64(m.Repo.Size())) - n2, err := m.Repo.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n2 - } - if len(m.Revision) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintRepository(dAtA, i, uint64(len(m.Revision))) - i += copy(dAtA[i:], m.Revision) - } - if len(m.Path) > 0 { - dAtA[i] = 0x1a - i++ - i = encodeVarintRepository(dAtA, i, uint64(len(m.Path))) - i += copy(dAtA[i:], m.Path) - } - if len(m.Environment) > 0 { - dAtA[i] = 0x22 - i++ - i = encodeVarintRepository(dAtA, i, uint64(len(m.Environment))) - i += copy(dAtA[i:], m.Environment) - } - return i, nil -} - -func (m *EnvParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EnvParamsResponse) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l if len(m.Params) > 0 { for _, msg := range m.Params { - dAtA[i] = 0xa + dAtA[i] = 0x2a i++ i = encodeVarintRepository(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) @@ -607,11 +456,11 @@ func (m *GetFileRequest) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintRepository(dAtA, i, uint64(m.Repo.Size())) - n3, err := m.Repo.MarshalTo(dAtA[i:]) + n2, err := m.Repo.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n3 + i += n2 } if len(m.Revision) > 0 { dAtA[i] = 0x12 @@ -714,34 +563,6 @@ func (m *ManifestResponse) Size() (n int) { if l > 0 { n += 1 + l + sovRepository(uint64(l)) } - return n -} - -func (m *EnvParamsRequest) Size() (n int) { - var l int - _ = l - if m.Repo != nil { - l = m.Repo.Size() - n += 1 + l + sovRepository(uint64(l)) - } - l = len(m.Revision) - if l > 0 { - n += 1 + l + sovRepository(uint64(l)) - } - l = len(m.Path) - if l > 0 { - n += 1 + l + sovRepository(uint64(l)) - } - l = len(m.Environment) - if l > 0 { - n += 1 + l + sovRepository(uint64(l)) - } - return n -} - -func (m *EnvParamsResponse) Size() (n int) { - var l int - _ = l if len(m.Params) > 0 { for _, e := range m.Params { l = e.Size() @@ -1167,227 +988,7 @@ func (m *ManifestResponse) Unmarshal(dAtA []byte) error { } m.Revision = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRepository(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRepository - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EnvParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRepository - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EnvParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EnvParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Repo", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRepository - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRepository - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Repo == nil { - m.Repo = &github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Repository{} - } - if err := m.Repo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRepository - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRepository - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Revision = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRepository - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRepository - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Path = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Environment", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRepository - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRepository - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Environment = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRepository(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRepository - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EnvParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRepository - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EnvParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EnvParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } @@ -1769,40 +1370,38 @@ var ( func init() { proto.RegisterFile("reposerver/repository/repository.proto", fileDescriptorRepository) } var fileDescriptorRepository = []byte{ - // 557 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0xb1, 0x8e, 0x13, 0x3d, - 0x10, 0xfe, 0x7d, 0xc9, 0x1f, 0x88, 0x73, 0xe2, 0x72, 0x16, 0x42, 0xab, 0x4d, 0x88, 0xa2, 0x95, - 0x40, 0x69, 0xd8, 0x55, 0x42, 0x43, 0x87, 0x04, 0x1c, 0x11, 0x12, 0xd1, 0xa1, 0xa5, 0x82, 0x06, - 0x39, 0x9b, 0x61, 0x63, 0x92, 0xb5, 0x8d, 0xed, 0x5b, 0x09, 0x4a, 0x5e, 0x80, 0x07, 0xe0, 0x61, - 0x68, 0x29, 0x79, 0x04, 0x94, 0x9a, 0x17, 0xa0, 0x43, 0xeb, 0x38, 0xd9, 0xcd, 0x5d, 0xb8, 0x06, - 0x0a, 0xe8, 0xc6, 0xdf, 0x8c, 0xbf, 0xcf, 0xf3, 0x8d, 0x35, 0xf8, 0xb6, 0x02, 0x29, 0x34, 0xa8, - 0x1c, 0x54, 0x64, 0x43, 0x66, 0x84, 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e6, 0x93, 0x92, 0x4e, 0x58, 0x59, 0x71, 0xe7, 0x36, 0x85, 0xdf, 0xdd, 0x9f, 0x5c, - 0x0b, 0x07, 0xff, 0x91, 0x09, 0x3e, 0x1c, 0x83, 0xd9, 0x8e, 0x8a, 0xec, 0xd4, 0x9f, 0xff, 0x82, - 0xfe, 0xcd, 0x5f, 0x64, 0xb7, 0x74, 0x8f, 0xf0, 0x15, 0xd7, 0x1c, 0xf1, 0xab, 0xb5, 0xbb, 0xe3, - 0xf0, 0x3b, 0x7b, 0x73, 0x1b, 0x96, 0x07, 0xf7, 0xbf, 0xac, 0x7a, 0xe8, 0xeb, 0xaa, 0x87, 0xbe, - 0xad, 0x7a, 0xe8, 0xe5, 0xf0, 0xb2, 0x5d, 0xba, 0x77, 0xe7, 0x4f, 0x1b, 0x76, 0x75, 0xde, 0xfd, - 0x19, 0x00, 0x00, 0xff, 0xff, 0x03, 0x5d, 0x68, 0xe0, 0x13, 0x06, 0x00, 0x00, + // 518 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xdd, 0x8a, 0x13, 0x31, + 0x18, 0x35, 0xbb, 0xdd, 0x6a, 0x53, 0x71, 0xd7, 0x20, 0x32, 0x4c, 0x4b, 0x29, 0x03, 0x4a, 0x6f, + 0x4c, 0x68, 0xbd, 0xf1, 0x4e, 0xf0, 0x6f, 0x11, 0x5c, 0x56, 0xc6, 0x2b, 0xbd, 0x91, 0x74, 0xfa, + 0x39, 0x8d, 0xed, 0x24, 0x31, 0xc9, 0x0e, 0xf8, 0x14, 0x3e, 0x80, 0x6f, 0xe0, 0x93, 0x78, 0xe9, + 0x23, 0x48, 0xef, 0x04, 0x1f, 0x42, 0x26, 0x4d, 0x3b, 0xb3, 0xbb, 0x65, 0x6f, 0x44, 0xf0, 0xee, + 0xe4, 0x7c, 0x99, 0x73, 0xbe, 0x39, 0x49, 0x3e, 0x7c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0, 0xa4, 0xe2, 0xfe, 0xee, 0xe2, 0xda, 0x38, 0xb9, 0x46, 0x9e, 0xe1, + 0xeb, 0xa1, 0x1b, 0x12, 0x37, 0xb7, 0x9e, 0xcf, 0x2f, 0xee, 0xed, 0xac, 0x6d, 0x54, 0x9e, 0x3c, + 0xfe, 0xbe, 0x1a, 0xa0, 0x1f, 0xab, 0x01, 0xfa, 0xb9, 0x1a, 0xa0, 0x77, 0xe3, 0xab, 0xa6, 0xc4, + 0xce, 0x69, 0x36, 0x6d, 0xfb, 0xa1, 0xf0, 0xf0, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x37, 0x1e, + 0x65, 0x64, 0xed, 0x04, 0x00, 0x00, } diff --git a/reposerver/repository/repository.proto b/reposerver/repository/repository.proto index 6e023e1c45d10..7abbda521a4cc 100644 --- a/reposerver/repository/repository.proto +++ b/reposerver/repository/repository.proto @@ -23,17 +23,7 @@ message ManifestResponse { string namespace = 2; string server = 3; string revision = 4; -} - -message EnvParamsRequest { - github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Repository repo = 1; - string revision = 2; - string path = 3; - string environment = 4; -} - -message EnvParamsResponse { - repeated github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ComponentParameter params = 1; + repeated github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ComponentParameter params = 5; } // GetFileRequest return @@ -56,10 +46,6 @@ service RepositoryService { rpc GenerateManifest(ManifestRequest) returns (ManifestResponse) { } - // Retrieve Ksonnet environment params in specified repo name and revision - rpc GetEnvParams(EnvParamsRequest) returns (EnvParamsResponse) { - } - // GetFile returns the file contents at the specified repo and path rpc GetFile(GetFileRequest) returns (GetFileResponse) { } diff --git a/server/application/application.go b/server/application/application.go index f86dc12547bc1..2e34628ebb442 100644 --- a/server/application/application.go +++ b/server/application/application.go @@ -29,16 +29,11 @@ import ( "k8s.io/api/core/v1" apierr "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" ) -const ( - maxRecentDeploymentsCnt = 5 -) - // Server provides a Application service type Server struct { ns string @@ -48,7 +43,7 @@ type Server struct { // TODO(jessesuen): move common cluster code to shared libraries clusterService cluster.ClusterServiceServer repoService apirepository.RepositoryServiceServer - appComparator controller.AppComparator + appComparator controller.AppStateManager } // NewServer returns a new instance of the Application service @@ -67,7 +62,7 @@ func NewServer( clusterService: clusterService, repoClientset: repoClientset, repoService: repoService, - appComparator: controller.NewKsonnetAppComparator(clusterService), + appComparator: controller.NewAppStateManager(clusterService, repoService, appclientset, repoClientset, namespace), } } @@ -370,116 +365,6 @@ func (s *Server) PodLogs(q *PodLogsQuery, ws ApplicationService_PodLogsServer) e return nil } -// Sync syncs an application to its target state -func (s *Server) Sync(ctx context.Context, syncReq *ApplicationSyncRequest) (*ApplicationSyncResult, error) { - return s.deployAndPersistDeploymentInfo(ctx, syncReq.Name, syncReq.Revision, nil, syncReq.DryRun, syncReq.Prune) -} - -func (s *Server) Rollback(ctx context.Context, rollbackReq *ApplicationRollbackRequest) (*ApplicationSyncResult, error) { - app, err := s.Get(ctx, &ApplicationQuery{Name: rollbackReq.Name}) - if err != nil { - return nil, err - } - var deploymentInfo *appv1.DeploymentInfo - for _, info := range app.Status.RecentDeployments { - if info.ID == rollbackReq.ID { - deploymentInfo = &info - break - } - } - if deploymentInfo == nil { - return nil, status.Errorf(codes.InvalidArgument, "application %s does not have deployment with id %v", rollbackReq.Name, rollbackReq.ID) - } - return s.deployAndPersistDeploymentInfo(ctx, rollbackReq.Name, deploymentInfo.Revision, &deploymentInfo.ComponentParameterOverrides, rollbackReq.DryRun, rollbackReq.Prune) -} - -func (s *Server) deployAndPersistDeploymentInfo( - ctx context.Context, appName string, revision string, overrides *[]appv1.ComponentParameter, dryRun bool, prune bool) (*ApplicationSyncResult, error) { - - log.Infof("Syncing application %s", appName) - app, err := s.Get(ctx, &ApplicationQuery{Name: appName}) - if err != nil { - return nil, err - } - - if revision != "" { - app.Spec.Source.TargetRevision = revision - } - - if overrides != nil { - app.Spec.Source.ComponentParameterOverrides = *overrides - } - - res, manifest, err := s.deploy(ctx, app, dryRun, prune) - if err != nil { - return nil, err - } - if !dryRun { - err = s.persistDeploymentInfo(ctx, appName, manifest.Revision, nil) - if err != nil { - return nil, err - } - } - return res, err -} - -func (s *Server) persistDeploymentInfo(ctx context.Context, appName string, revision string, overrides *[]appv1.ComponentParameter) error { - app, err := s.Get(ctx, &ApplicationQuery{Name: appName}) - if err != nil { - return err - } - - repo := s.getRepo(ctx, app.Spec.Source.RepoURL) - conn, repoClient, err := s.repoClientset.NewRepositoryClient() - if err != nil { - return err - } - defer util.Close(conn) - - log.Infof("Retrieving deployment params for application %s", appName) - envParams, err := repoClient.GetEnvParams(ctx, &repository.EnvParamsRequest{ - Repo: repo, - Environment: app.Spec.Source.Environment, - Path: app.Spec.Source.Path, - Revision: revision, - }) - - if err != nil { - return err - } - - params := make([]appv1.ComponentParameter, len(envParams.Params)) - for i := range envParams.Params { - param := *envParams.Params[i] - params[i] = param - } - var nextId int64 = 0 - if len(app.Status.RecentDeployments) > 0 { - nextId = app.Status.RecentDeployments[len(app.Status.RecentDeployments)-1].ID + 1 - } - recentDeployments := append(app.Status.RecentDeployments, appv1.DeploymentInfo{ - ComponentParameterOverrides: app.Spec.Source.ComponentParameterOverrides, - Revision: revision, - Params: params, - DeployedAt: metav1.NewTime(time.Now()), - ID: nextId, - }) - if len(recentDeployments) > maxRecentDeploymentsCnt { - recentDeployments = recentDeployments[1 : maxRecentDeploymentsCnt+1] - } - - patch, err := json.Marshal(map[string]map[string][]appv1.DeploymentInfo{ - "status": { - "recentDeployments": recentDeployments, - }, - }) - if err != nil { - return err - } - _, err = s.appclientset.ArgoprojV1alpha1().Applications(s.ns).Patch(app.Name, types.MergePatchType, patch) - return err -} - func (s *Server) getApplicationDestination(ctx context.Context, name string) (string, string, error) { app, err := s.appclientset.ArgoprojV1alpha1().Applications(s.ns).Get(name, metav1.GetOptions{}) if err != nil { @@ -498,134 +383,45 @@ func (s *Server) getRepo(ctx context.Context, repoURL string) *appv1.Repository return repo } -func (s *Server) deploy( - ctx context.Context, - app *appv1.Application, - dryRun bool, - prune bool) (*ApplicationSyncResult, *repository.ManifestResponse, error) { - - repo := s.getRepo(ctx, app.Spec.Source.RepoURL) - conn, repoClient, err := s.repoClientset.NewRepositoryClient() - if err != nil { - return nil, nil, err - } - defer util.Close(conn) - overrides := make([]*appv1.ComponentParameter, len(app.Spec.Source.ComponentParameterOverrides)) - if app.Spec.Source.ComponentParameterOverrides != nil { - for i := range app.Spec.Source.ComponentParameterOverrides { - item := app.Spec.Source.ComponentParameterOverrides[i] - overrides[i] = &item - } - } - - manifestInfo, err := repoClient.GenerateManifest(ctx, &repository.ManifestRequest{ - Repo: repo, - Environment: app.Spec.Source.Environment, - Path: app.Spec.Source.Path, - Revision: app.Spec.Source.TargetRevision, - ComponentParameterOverrides: overrides, - AppLabel: app.Name, +// Sync syncs an application to its target state +func (s *Server) Sync(ctx context.Context, syncReq *ApplicationSyncRequest) (*appv1.Application, error) { + return s.setAppOperation(ctx, syncReq.Name, func(app *appv1.Application) (*appv1.Operation, error) { + return &appv1.Operation{ + Sync: &appv1.SyncOperation{ + Revision: syncReq.Revision, + Prune: syncReq.Prune, + DryRun: syncReq.DryRun, + }, + }, nil }) - if err != nil { - return nil, nil, err - } - - targetObjs := make([]*unstructured.Unstructured, len(manifestInfo.Manifests)) - for i, manifest := range manifestInfo.Manifests { - obj, err := appv1.UnmarshalToUnstructured(manifest) - if err != nil { - return nil, nil, err - } - targetObjs[i] = obj - } +} - server, namespace := app.Spec.Destination.Server, app.Spec.Destination.Namespace +func (s *Server) Rollback(ctx context.Context, rollbackReq *ApplicationRollbackRequest) (*appv1.Application, error) { + return s.setAppOperation(ctx, rollbackReq.Name, func(app *appv1.Application) (*appv1.Operation, error) { + return &appv1.Operation{ + Rollback: &appv1.RollbackOperation{ + ID: rollbackReq.ID, + Prune: rollbackReq.Prune, + DryRun: rollbackReq.DryRun, + }, + }, nil + }) +} - comparison, err := s.appComparator.CompareAppState(server, namespace, targetObjs, app) +func (s *Server) setAppOperation(ctx context.Context, appName string, operationCreator func(app *appv1.Application) (*appv1.Operation, error)) (*appv1.Application, error) { + app, err := s.Get(ctx, &ApplicationQuery{Name: appName}) if err != nil { - return nil, nil, err + return nil, err } - - clst, err := s.clusterService.Get(ctx, &cluster.ClusterQuery{Server: server}) - if err != nil { - return nil, nil, err + if app.Operation != nil { + return nil, status.Errorf(codes.InvalidArgument, "another operation is already in progress") } - config := clst.RESTConfig() - - var syncRes ApplicationSyncResult - syncRes.Resources = make([]*ResourceDetails, 0) - for _, resourceState := range comparison.Resources { - var liveObj, targetObj *unstructured.Unstructured - - if resourceState.LiveState != "null" { - liveObj = &unstructured.Unstructured{} - err = json.Unmarshal([]byte(resourceState.LiveState), liveObj) - if err != nil { - return nil, nil, err - } - } - - if resourceState.TargetState != "null" { - targetObj = &unstructured.Unstructured{} - err = json.Unmarshal([]byte(resourceState.TargetState), targetObj) - if err != nil { - return nil, nil, err - } - } - - needsCreate := liveObj == nil - needsDelete := targetObj == nil - - obj := targetObj - if obj == nil { - obj = liveObj - } - resDetails := ResourceDetails{ - Name: obj.GetName(), - Kind: obj.GetKind(), - Namespace: namespace, - } - - if resourceState.Status == appv1.ComparisonStatusSynced { - resDetails.Message = fmt.Sprintf("already synced") - } else if dryRun { - if needsCreate { - resDetails.Message = fmt.Sprintf("will create") - } else if needsDelete { - if prune { - resDetails.Message = fmt.Sprintf("will delete") - } else { - resDetails.Message = fmt.Sprintf("will be ignored (should be deleted)") - } - } else { - resDetails.Message = fmt.Sprintf("will update") - } - } else { - if needsDelete { - if prune { - err = kube.DeleteResource(config, liveObj, namespace) - if err != nil { - return nil, nil, err - } - - resDetails.Message = fmt.Sprintf("deleted") - } else { - resDetails.Message = fmt.Sprintf("ignored (should be deleted)") - } - } else { - _, err := kube.ApplyResource(config, targetObj, namespace) - if err != nil { - return nil, nil, err - } - if needsCreate { - resDetails.Message = fmt.Sprintf("created") - } else { - resDetails.Message = fmt.Sprintf("updated") - } - } - } - syncRes.Resources = append(syncRes.Resources, &resDetails) + op, err := operationCreator(app) + if err != nil { + return nil, err } - syncRes.Message = "successfully synced" - return &syncRes, manifestInfo, nil + app.Operation = op + app.Status.OperationState = nil + _, err = s.Update(ctx, app) + return app, err } diff --git a/server/application/application.pb.go b/server/application/application.pb.go index d353077e1a290..39b34e499f01b 100644 --- a/server/application/application.pb.go +++ b/server/application/application.pb.go @@ -17,9 +17,7 @@ DeleteApplicationRequest ApplicationSyncRequest ApplicationSpecRequest - ApplicationSyncResult ApplicationRollbackRequest - ResourceDetails DeletePodQuery PodLogsQuery LogEntry @@ -188,31 +186,6 @@ func (m *ApplicationSpecRequest) GetSpec() *github_com_argoproj_argo_cd_pkg_apis return nil } -// ApplicationSyncResult is a result of a sync requeswt -type ApplicationSyncResult struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - Resources []*ResourceDetails `protobuf:"bytes,2,rep,name=resources" json:"resources,omitempty"` -} - -func (m *ApplicationSyncResult) Reset() { *m = ApplicationSyncResult{} } -func (m *ApplicationSyncResult) String() string { return proto.CompactTextString(m) } -func (*ApplicationSyncResult) ProtoMessage() {} -func (*ApplicationSyncResult) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{5} } - -func (m *ApplicationSyncResult) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func (m *ApplicationSyncResult) GetResources() []*ResourceDetails { - if m != nil { - return m.Resources - } - return nil -} - type ApplicationRollbackRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` ID int64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` @@ -224,7 +197,7 @@ func (m *ApplicationRollbackRequest) Reset() { *m = ApplicationRollbackR func (m *ApplicationRollbackRequest) String() string { return proto.CompactTextString(m) } func (*ApplicationRollbackRequest) ProtoMessage() {} func (*ApplicationRollbackRequest) Descriptor() ([]byte, []int) { - return fileDescriptorApplication, []int{6} + return fileDescriptorApplication, []int{5} } func (m *ApplicationRollbackRequest) GetName() string { @@ -255,46 +228,6 @@ func (m *ApplicationRollbackRequest) GetPrune() bool { return false } -type ResourceDetails struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` - Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` - Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` -} - -func (m *ResourceDetails) Reset() { *m = ResourceDetails{} } -func (m *ResourceDetails) String() string { return proto.CompactTextString(m) } -func (*ResourceDetails) ProtoMessage() {} -func (*ResourceDetails) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{7} } - -func (m *ResourceDetails) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *ResourceDetails) GetKind() string { - if m != nil { - return m.Kind - } - return "" -} - -func (m *ResourceDetails) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *ResourceDetails) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - type DeletePodQuery struct { ApplicationName string `protobuf:"bytes,1,opt,name=applicationName,proto3" json:"applicationName,omitempty"` PodName string `protobuf:"bytes,2,opt,name=podName,proto3" json:"podName,omitempty"` @@ -303,7 +236,7 @@ type DeletePodQuery struct { func (m *DeletePodQuery) Reset() { *m = DeletePodQuery{} } func (m *DeletePodQuery) String() string { return proto.CompactTextString(m) } func (*DeletePodQuery) ProtoMessage() {} -func (*DeletePodQuery) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{8} } +func (*DeletePodQuery) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{6} } func (m *DeletePodQuery) GetApplicationName() string { if m != nil { @@ -332,7 +265,7 @@ type PodLogsQuery struct { func (m *PodLogsQuery) Reset() { *m = PodLogsQuery{} } func (m *PodLogsQuery) String() string { return proto.CompactTextString(m) } func (*PodLogsQuery) ProtoMessage() {} -func (*PodLogsQuery) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{9} } +func (*PodLogsQuery) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{7} } func (m *PodLogsQuery) GetApplicationName() string { if m != nil { @@ -391,7 +324,7 @@ type LogEntry struct { func (m *LogEntry) Reset() { *m = LogEntry{} } func (m *LogEntry) String() string { return proto.CompactTextString(m) } func (*LogEntry) ProtoMessage() {} -func (*LogEntry) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{10} } +func (*LogEntry) Descriptor() ([]byte, []int) { return fileDescriptorApplication, []int{8} } func (m *LogEntry) GetContent() string { if m != nil { @@ -413,9 +346,7 @@ func init() { proto.RegisterType((*DeleteApplicationRequest)(nil), "application.DeleteApplicationRequest") proto.RegisterType((*ApplicationSyncRequest)(nil), "application.ApplicationSyncRequest") proto.RegisterType((*ApplicationSpecRequest)(nil), "application.ApplicationSpecRequest") - proto.RegisterType((*ApplicationSyncResult)(nil), "application.ApplicationSyncResult") proto.RegisterType((*ApplicationRollbackRequest)(nil), "application.ApplicationRollbackRequest") - proto.RegisterType((*ResourceDetails)(nil), "application.ResourceDetails") proto.RegisterType((*DeletePodQuery)(nil), "application.DeletePodQuery") proto.RegisterType((*PodLogsQuery)(nil), "application.PodLogsQuery") proto.RegisterType((*LogEntry)(nil), "application.LogEntry") @@ -447,9 +378,9 @@ type ApplicationServiceClient interface { // Delete deletes an application Delete(ctx context.Context, in *DeleteApplicationRequest, opts ...grpc.CallOption) (*ApplicationResponse, error) // Sync syncs an application to its target state - Sync(ctx context.Context, in *ApplicationSyncRequest, opts ...grpc.CallOption) (*ApplicationSyncResult, error) + Sync(ctx context.Context, in *ApplicationSyncRequest, opts ...grpc.CallOption) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) // Sync syncs an application to its target state - Rollback(ctx context.Context, in *ApplicationRollbackRequest, opts ...grpc.CallOption) (*ApplicationSyncResult, error) + Rollback(ctx context.Context, in *ApplicationRollbackRequest, opts ...grpc.CallOption) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) // PodLogs returns stream of log entries for the specified pod. Pod DeletePod(ctx context.Context, in *DeletePodQuery, opts ...grpc.CallOption) (*ApplicationResponse, error) // PodLogs returns stream of log entries for the specified pod. Pod @@ -550,8 +481,8 @@ func (c *applicationServiceClient) Delete(ctx context.Context, in *DeleteApplica return out, nil } -func (c *applicationServiceClient) Sync(ctx context.Context, in *ApplicationSyncRequest, opts ...grpc.CallOption) (*ApplicationSyncResult, error) { - out := new(ApplicationSyncResult) +func (c *applicationServiceClient) Sync(ctx context.Context, in *ApplicationSyncRequest, opts ...grpc.CallOption) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) { + out := new(github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application) err := grpc.Invoke(ctx, "/application.ApplicationService/Sync", in, out, c.cc, opts...) if err != nil { return nil, err @@ -559,8 +490,8 @@ func (c *applicationServiceClient) Sync(ctx context.Context, in *ApplicationSync return out, nil } -func (c *applicationServiceClient) Rollback(ctx context.Context, in *ApplicationRollbackRequest, opts ...grpc.CallOption) (*ApplicationSyncResult, error) { - out := new(ApplicationSyncResult) +func (c *applicationServiceClient) Rollback(ctx context.Context, in *ApplicationRollbackRequest, opts ...grpc.CallOption) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) { + out := new(github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application) err := grpc.Invoke(ctx, "/application.ApplicationService/Rollback", in, out, c.cc, opts...) if err != nil { return nil, err @@ -627,9 +558,9 @@ type ApplicationServiceServer interface { // Delete deletes an application Delete(context.Context, *DeleteApplicationRequest) (*ApplicationResponse, error) // Sync syncs an application to its target state - Sync(context.Context, *ApplicationSyncRequest) (*ApplicationSyncResult, error) + Sync(context.Context, *ApplicationSyncRequest) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) // Sync syncs an application to its target state - Rollback(context.Context, *ApplicationRollbackRequest) (*ApplicationSyncResult, error) + Rollback(context.Context, *ApplicationRollbackRequest) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) // PodLogs returns stream of log entries for the specified pod. Pod DeletePod(context.Context, *DeletePodQuery) (*ApplicationResponse, error) // PodLogs returns stream of log entries for the specified pod. Pod @@ -1072,42 +1003,6 @@ func (m *ApplicationSpecRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *ApplicationSyncResult) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ApplicationSyncResult) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Message) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintApplication(dAtA, i, uint64(len(m.Message))) - i += copy(dAtA[i:], m.Message) - } - if len(m.Resources) > 0 { - for _, msg := range m.Resources { - dAtA[i] = 0x12 - i++ - i = encodeVarintApplication(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } - } - return i, nil -} - func (m *ApplicationRollbackRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1157,48 +1052,6 @@ func (m *ApplicationRollbackRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *ResourceDetails) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ResourceDetails) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Name) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintApplication(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) - } - if len(m.Kind) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintApplication(dAtA, i, uint64(len(m.Kind))) - i += copy(dAtA[i:], m.Kind) - } - if len(m.Namespace) > 0 { - dAtA[i] = 0x1a - i++ - i = encodeVarintApplication(dAtA, i, uint64(len(m.Namespace))) - i += copy(dAtA[i:], m.Namespace) - } - if len(m.Message) > 0 { - dAtA[i] = 0x22 - i++ - i = encodeVarintApplication(dAtA, i, uint64(len(m.Message))) - i += copy(dAtA[i:], m.Message) - } - return i, nil -} - func (m *DeletePodQuery) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1409,22 +1262,6 @@ func (m *ApplicationSpecRequest) Size() (n int) { return n } -func (m *ApplicationSyncResult) Size() (n int) { - var l int - _ = l - l = len(m.Message) - if l > 0 { - n += 1 + l + sovApplication(uint64(l)) - } - if len(m.Resources) > 0 { - for _, e := range m.Resources { - l = e.Size() - n += 1 + l + sovApplication(uint64(l)) - } - } - return n -} - func (m *ApplicationRollbackRequest) Size() (n int) { var l int _ = l @@ -1444,28 +1281,6 @@ func (m *ApplicationRollbackRequest) Size() (n int) { return n } -func (m *ResourceDetails) Size() (n int) { - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovApplication(uint64(l)) - } - l = len(m.Kind) - if l > 0 { - n += 1 + l + sovApplication(uint64(l)) - } - l = len(m.Namespace) - if l > 0 { - n += 1 + l + sovApplication(uint64(l)) - } - l = len(m.Message) - if l > 0 { - n += 1 + l + sovApplication(uint64(l)) - } - return n -} - func (m *DeletePodQuery) Size() (n int) { var l int _ = l @@ -2084,116 +1899,6 @@ func (m *ApplicationSpecRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *ApplicationSyncResult) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ApplicationSyncResult: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ApplicationSyncResult: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApplication - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Message = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resources", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthApplication - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Resources = append(m.Resources, &ResourceDetails{}) - if err := m.Resources[len(m.Resources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApplication(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthApplication - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *ApplicationRollbackRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2332,172 +2037,6 @@ func (m *ApplicationRollbackRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *ResourceDetails) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ResourceDetails: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceDetails: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApplication - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApplication - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Kind = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApplication - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Namespace = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApplication - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApplication - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Message = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApplication(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthApplication - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *DeletePodQuery) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3054,71 +2593,66 @@ var ( func init() { proto.RegisterFile("server/application/application.proto", fileDescriptorApplication) } var fileDescriptorApplication = []byte{ - // 1054 bytes of a gzipped FileDescriptorProto + // 976 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x97, 0x77, 0x37, 0x9b, 0x64, 0x52, 0x28, 0x1a, 0x92, 0xc8, 0x75, 0xd3, 0x34, 0x9a, 0xa4, - 0x10, 0x82, 0xb0, 0x9b, 0x00, 0x02, 0x45, 0xe5, 0x40, 0x48, 0x81, 0xa2, 0x08, 0x05, 0xa7, 0x08, - 0x89, 0x03, 0x68, 0x62, 0xbf, 0x3a, 0x26, 0xf6, 0x8c, 0xeb, 0x99, 0x35, 0x5a, 0x4a, 0x0e, 0x70, - 0x82, 0x13, 0xe2, 0xcf, 0x9d, 0x13, 0x47, 0x3e, 0x00, 0xdf, 0x00, 0x6e, 0x48, 0xdc, 0x11, 0x8a, - 0xf8, 0x20, 0x68, 0xc6, 0xf6, 0xda, 0xde, 0xec, 0x6e, 0x5b, 0xb4, 0x87, 0x9e, 0x76, 0xde, 0xcc, - 0xf3, 0xfc, 0x7e, 0xef, 0xbd, 0x99, 0xf7, 0x9b, 0x45, 0x1b, 0x02, 0xd2, 0x0c, 0x52, 0x87, 0x26, - 0x49, 0x14, 0x7a, 0x54, 0x86, 0x9c, 0xd5, 0xc7, 0x76, 0x92, 0x72, 0xc9, 0xf1, 0x42, 0x6d, 0xca, - 0x5a, 0x0c, 0x78, 0xc0, 0xf5, 0xbc, 0xa3, 0x46, 0xb9, 0x8b, 0xb5, 0x12, 0x70, 0x1e, 0x44, 0xe0, - 0xd0, 0x24, 0x74, 0x28, 0x63, 0x5c, 0x6a, 0x67, 0x51, 0xac, 0x92, 0xd3, 0xd7, 0x85, 0x1d, 0x72, - 0xbd, 0xea, 0xf1, 0x14, 0x9c, 0x6c, 0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0xe0, 0xce, 0x7a, 0x66, 0x9f, 0xfd, 0x0f, 0x71, 0xd0, 0xb1, 0x4f, + 0xea, 0x17, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x0b, 0x98, 0x18, 0x60, 0x0c, 0x00, 0x00, } diff --git a/server/application/application.proto b/server/application/application.proto index a526d34933646..c51c96c59acb9 100644 --- a/server/application/application.proto +++ b/server/application/application.proto @@ -41,12 +41,6 @@ message ApplicationSpecRequest { github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationSpec spec = 2; } -// ApplicationSyncResult is a result of a sync requeswt -message ApplicationSyncResult { - string message = 1; - repeated ResourceDetails resources = 2; -} - message ApplicationRollbackRequest { string name = 1; int64 id = 2 [(gogoproto.customname) = "ID"]; @@ -54,13 +48,6 @@ message ApplicationRollbackRequest { bool prune = 4; } -message ResourceDetails { - string name = 1; - string kind = 2; - string namespace = 3; - string message = 4; -} - message DeletePodQuery { string applicationName = 1; string podName = 2; @@ -129,7 +116,7 @@ service ApplicationService { } // Sync syncs an application to its target state - rpc Sync(ApplicationSyncRequest) returns (ApplicationSyncResult) { + rpc Sync(ApplicationSyncRequest) returns (github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Application) { option (google.api.http) = { post: "/api/v1/applications/{name}/sync" body: "*" @@ -137,7 +124,7 @@ service ApplicationService { } // Sync syncs an application to its target state - rpc Rollback(ApplicationRollbackRequest) returns (ApplicationSyncResult) { + rpc Rollback(ApplicationRollbackRequest) returns (github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Application) { option (google.api.http) = { post: "/api/v1/applications/{name}/rollback" body: "*" diff --git a/server/server.go b/server/server.go index d1d137910e42b..235718412ffcf 100644 --- a/server/server.go +++ b/server/server.go @@ -46,12 +46,7 @@ import ( "k8s.io/client-go/kubernetes" ) -const ( - port = 8080 -) - var ( - endpoint = fmt.Sprintf("localhost:%d", port) // ErrNoSession indicates no auth token was supplied as part of a request ErrNoSession = status.Errorf(codes.Unauthenticated, "no session information") // ErrInvalidSession indicates that specified token is invalid @@ -100,19 +95,15 @@ func NewServer(opts ArgoCDServerOpts) *ArgoCDServer { // We use k8s.io/code-generator/cmd/go-to-protobuf to generate the .proto files from the API types. // k8s.io/ go-to-protobuf uses protoc-gen-gogo, which comes from gogo/protobuf (a fork of // golang/protobuf). -func (a *ArgoCDServer) Run() { - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - defer cancel() - +func (a *ArgoCDServer) Run(ctx context.Context, port int) { grpcS := a.newGRPCServer() var httpS *http.Server var httpsS *http.Server if a.useTLS() { - httpS = newRedirectServer() - httpsS = a.newHTTPServer(ctx) + httpS = newRedirectServer(port) + httpsS = a.newHTTPServer(ctx, port) } else { - httpS = a.newHTTPServer(ctx) + httpS = a.newHTTPServer(ctx, port) } // Cmux is used to support servicing gRPC and HTTP1.1+JSON on the same port @@ -246,7 +237,8 @@ func (a *ArgoCDServer) translateGrpcCookieHeader(ctx context.Context, w http.Res // newHTTPServer returns the HTTP server to serve HTTP/HTTPS requests. This is implemented // using grpc-gateway as a proxy to the gRPC server. -func (a *ArgoCDServer) newHTTPServer(ctx context.Context) *http.Server { +func (a *ArgoCDServer) newHTTPServer(ctx context.Context, port int) *http.Server { + endpoint := fmt.Sprintf("localhost:%d", port) mux := http.NewServeMux() httpS := http.Server{ Addr: endpoint, @@ -342,9 +334,9 @@ func (a *ArgoCDServer) registerDexHandlers(mux *http.ServeMux) { } // newRedirectServer returns an HTTP server which does a 307 redirect to the HTTPS server -func newRedirectServer() *http.Server { +func newRedirectServer(port int) *http.Server { return &http.Server{ - Addr: endpoint, + Addr: fmt.Sprintf("localhost:%d", port), Handler: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { target := "https://" + req.Host + req.URL.Path if len(req.URL.RawQuery) > 0 { diff --git a/test/e2e/app_management_test.go b/test/e2e/app_management_test.go new file mode 100644 index 0000000000000..85d0acb22cb78 --- /dev/null +++ b/test/e2e/app_management_test.go @@ -0,0 +1,85 @@ +package e2e + +import ( + "context" + "fmt" + "testing" + + "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + // load the gcp plugin (required to authenticate against GKE clusters). + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + // load the oidc plugin (required to authenticate with OpenID Connect). + + _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" +) + +func TestAppManagement(t *testing.T) { + + testApp := &v1alpha1.Application{ + ObjectMeta: metav1.ObjectMeta{GenerateName: "e2e-test"}, + Spec: v1alpha1.ApplicationSpec{ + Source: v1alpha1.ApplicationSource{ + RepoURL: "https://github.com/argoproj/argo-cd.git", Path: ".", Environment: "minikube", + }, + Destination: v1alpha1.ApplicationDestination{ + Server: fixture.Config.Host, + Namespace: fixture.Namespace, + }, + }, + } + + t.Run("TestTrackAppStateAndSyncApp", func(t *testing.T) { + ctrl := fixture.CreateController() + ctx, cancel := context.WithCancel(context.Background()) + go ctrl.Run(ctx, 1, 1) + defer cancel() + + // create app and ensure it reaches OutOfSync state + app := fixture.CreateApp(t, testApp) + WaitUntil(t, func() (done bool, err error) { + app, err = fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) + return err == nil && app.Status.ComparisonResult.Status != v1alpha1.ComparisonStatusUnknown, err + }) + + assert.Equal(t, v1alpha1.ComparisonStatusOutOfSync, app.Status.ComparisonResult.Status) + + // sync app and make sure it reaches InSync state + _, err := fixture.RunCli("app", "sync", app.Name) + if err != nil { + t.Fatal(fmt.Sprintf("Unable to sync app %v", err)) + } + + WaitUntil(t, func() (done bool, err error) { + app, err = fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) + return err == nil && app.Status.ComparisonResult.Status == v1alpha1.ComparisonStatusSynced, err + }) + assert.Equal(t, v1alpha1.ComparisonStatusSynced, app.Status.ComparisonResult.Status) + }) + + t.Run("TestComparisonFailsIfClusterNotAdded", func(t *testing.T) { + invalidApp := testApp.DeepCopy() + invalidApp.Spec.Destination.Server = "https://not-registered-cluster/api" + + ctrl := fixture.CreateController() + ctx, cancel := context.WithCancel(context.Background()) + go ctrl.Run(ctx, 1, 1) + defer cancel() + + app := fixture.CreateApp(t, invalidApp) + + WaitUntil(t, func() (done bool, err error) { + app, err := fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) + return err == nil && app.Status.ComparisonResult.Status != v1alpha1.ComparisonStatusUnknown, err + }) + + app, err := fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) + if err != nil { + t.Fatal(fmt.Sprintf("Unable to get app %v", err)) + } + + assert.Equal(t, v1alpha1.ComparisonStatusError, app.Status.ComparisonResult.Status) + }) +} diff --git a/test/e2e/controller_test.go b/test/e2e/controller_test.go deleted file mode 100644 index 2b370ee8f30f3..0000000000000 --- a/test/e2e/controller_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package e2e - -import ( - "context" - "fmt" - "testing" - - "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" - "github.com/stretchr/testify/assert" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - // load the gcp plugin (required to authenticate against GKE clusters). - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" - // load the oidc plugin (required to authenticate with OpenID Connect). - _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" -) - -func TestController(t *testing.T) { - testApp := &v1alpha1.Application{ - ObjectMeta: metav1.ObjectMeta{GenerateName: "e2e-test"}, - Spec: v1alpha1.ApplicationSpec{Source: v1alpha1.ApplicationSource{ - RepoURL: "https://github.com/ksonnet/ksonnet.git", Path: ".", Environment: "default", - }}, - } - - t.Run("TestComparisonErrorIfRepoDoesNotExist", func(t *testing.T) { - ctrl := fixture.CreateController() - ctx, cancel := context.WithCancel(context.Background()) - go ctrl.Run(ctx, 1) - defer cancel() - app := fixture.CreateApp(t, testApp) - - PollUntil(t, func() (done bool, err error) { - app, err := fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) - return err == nil && app.Status.ComparisonResult.Status != v1alpha1.ComparisonStatusUnknown, err - }) - - app, err := fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) - if err != nil { - t.Fatal(fmt.Sprintf("Unable to get app %v", err)) - } - - assert.Equal(t, app.Status.ComparisonResult.Status, v1alpha1.ComparisonStatusError) - }) - - t.Run("TestComparisonFailsIfClusterNotAdded", func(t *testing.T) { - ctrl := fixture.CreateController() - ctx, cancel := context.WithCancel(context.Background()) - go ctrl.Run(ctx, 1) - defer cancel() - _, err := fixture.ApiRepoService.Create(context.Background(), &v1alpha1.Repository{Repo: testApp.Spec.Source.RepoURL, Username: "", Password: ""}) - if err != nil { - t.Fatal(fmt.Sprintf("Unable to create repo %v", err)) - } - app := fixture.CreateApp(t, testApp) - - PollUntil(t, func() (done bool, err error) { - app, err := fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) - return err == nil && app.Status.ComparisonResult.Status != v1alpha1.ComparisonStatusUnknown, err - }) - - app, err = fixture.AppClient.ArgoprojV1alpha1().Applications(fixture.Namespace).Get(app.ObjectMeta.Name, metav1.GetOptions{}) - if err != nil { - t.Fatal(fmt.Sprintf("Unable to get app %v", err)) - } - - assert.Equal(t, app.Status.ComparisonResult.Status, v1alpha1.ComparisonStatusError) - }) - -} diff --git a/test/e2e/fixture.go b/test/e2e/fixture.go index ba2f6c077322e..24ffafb85f5cc 100644 --- a/test/e2e/fixture.go +++ b/test/e2e/fixture.go @@ -1,6 +1,8 @@ package e2e import ( + "bytes" + "context" "fmt" "log" "net" @@ -9,6 +11,7 @@ import ( "testing" "time" + "github.com/argoproj/argo-cd/cmd/argocd/commands" "github.com/argoproj/argo-cd/common" "github.com/argoproj/argo-cd/controller" "github.com/argoproj/argo-cd/install" @@ -16,11 +19,13 @@ import ( appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" "github.com/argoproj/argo-cd/reposerver" "github.com/argoproj/argo-cd/reposerver/repository" + "github.com/argoproj/argo-cd/server" "github.com/argoproj/argo-cd/server/cluster" apirepository "github.com/argoproj/argo-cd/server/repository" + "github.com/argoproj/argo-cd/util" "github.com/argoproj/argo-cd/util/cache" "github.com/argoproj/argo-cd/util/git" - "google.golang.org/grpc" + "github.com/argoproj/argo-cd/util/settings" "k8s.io/api/core/v1" apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -36,17 +41,16 @@ const ( // Fixture represents e2e tests fixture. type Fixture struct { - Config *rest.Config - KubeClient kubernetes.Interface - ExtensionsClient apiextensionsclient.Interface - AppClient appclientset.Interface - ApiRepoService apirepository.RepositoryServiceServer - RepoClientset reposerver.Clientset - AppComparator controller.AppComparator - Namespace string - InstanceID string - repoServerGRPC *grpc.Server - repoServerListener net.Listener + Config *rest.Config + KubeClient kubernetes.Interface + ExtensionsClient apiextensionsclient.Interface + AppClient appclientset.Interface + Namespace string + InstanceID string + RepoServerAddress string + ApiServerAddress string + + tearDownCallback func() } func createNamespace(kubeClient *kubernetes.Clientset) (string, error) { @@ -62,29 +66,98 @@ func createNamespace(kubeClient *kubernetes.Clientset) (string, error) { return cns.Name, nil } +func getFreePort() (int, error) { + addr, err := net.ResolveTCPAddr("tcp", "localhost:0") + if err != nil { + return 0, err + } + + l, err := net.ListenTCP("tcp", addr) + if err != nil { + return 0, err + } + defer util.Close(l) + return l.Addr().(*net.TCPAddr).Port, nil +} + func (f *Fixture) setup() error { installer, err := install.NewInstaller(f.Config, install.InstallOptions{}) if err != nil { return err } - listener, err := net.Listen("tcp", "127.0.0.1:0") + installer.InstallApplicationCRD() + + settingsMgr := settings.NewSettingsManager(f.KubeClient, f.Namespace) + err = settingsMgr.SaveSettings(&settings.ArgoCDSettings{}) if err != nil { return err } - f.repoServerListener = listener + + err = f.ensureClusterRegistered() + if err != nil { + return err + } + + apiServerPort, err := getFreePort() + if err != nil { + return err + } + + memCache := cache.NewInMemoryCache(repository.DefaultRepoCacheExpiration) + repoServerGRPC := reposerver.NewServer(&FakeGitClientFactory{}, memCache).CreateGRPC() + repoServerListener, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + return err + } + f.RepoServerAddress = repoServerListener.Addr().String() + f.ApiServerAddress = fmt.Sprintf("127.0.0.1:%d", apiServerPort) + + apiServer := server.NewServer(server.ArgoCDServerOpts{ + Namespace: f.Namespace, + AppClientset: f.AppClient, + DisableAuth: true, + Insecure: true, + KubeClientset: f.KubeClient, + RepoClientset: reposerver.NewRepositoryServerClientset(f.RepoServerAddress), + }) + + ctx, cancel := context.WithCancel(context.Background()) go func() { - err = f.repoServerGRPC.Serve(listener) + err = repoServerGRPC.Serve(repoServerListener) }() - installer.InstallApplicationCRD() + go func() { + apiServer.Run(ctx, apiServerPort) + }() + + f.tearDownCallback = func() { + cancel() + repoServerGRPC.Stop() + } + return err +} + +func (f *Fixture) ensureClusterRegistered() error { + loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() + loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig + overrides := clientcmd.ConfigOverrides{} + clientConfig := clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, &overrides, os.Stdin) + conf, err := clientConfig.ClientConfig() + if err != nil { + return err + } + // Install RBAC resources for managing the cluster + managerBearerToken := common.InstallClusterManagerRBAC(conf) + clst := commands.NewCluster(f.Config.Host, conf, managerBearerToken) + _, err = cluster.NewServer(f.Namespace, f.KubeClient, f.AppClient).Create(context.Background(), clst) return err } // TearDown deletes fixture resources. func (f *Fixture) TearDown() { - err := f.KubeClient.CoreV1().Namespaces().Delete(f.Namespace, &metav1.DeleteOptions{}) - if err != nil { - f.repoServerGRPC.Stop() + if f.tearDownCallback != nil { + f.tearDownCallback() } + err := f.KubeClient.CoreV1().Namespaces().Delete(f.Namespace, &metav1.DeleteOptions{}) if err != nil { println("Unable to tear down fixture") } @@ -104,20 +177,18 @@ func GetKubeConfig(configPath string, overrides clientcmd.ConfigOverrides) *rest return restConfig } -// NewFixture creates e2e tests fixture. +// NewFixture creates e2e tests fixture: ensures that Application CRD is installed, creates temporal namespace, starts repo and api server, +// configure currently available cluster. func NewFixture() (*Fixture, error) { - memCache := cache.NewInMemoryCache(repository.DefaultRepoCacheExpiration) config := GetKubeConfig("", clientcmd.ConfigOverrides{}) extensionsClient := apiextensionsclient.NewForConfigOrDie(config) appClient := appclientset.NewForConfigOrDie(config) kubeClient := kubernetes.NewForConfigOrDie(config) namespace, err := createNamespace(kubeClient) - clusterService := cluster.NewServer(namespace, kubeClient, appClient) - repoServerGRPC := reposerver.NewServer(&FakeGitClientFactory{}, memCache).CreateGRPC() if err != nil { return nil, err } - appComparator := controller.NewKsonnetAppComparator(clusterService) + fixture := &Fixture{ Config: config, ExtensionsClient: extensionsClient, @@ -125,9 +196,6 @@ func NewFixture() (*Fixture, error) { KubeClient: kubeClient, Namespace: namespace, InstanceID: namespace, - ApiRepoService: apirepository.NewServer(namespace, kubeClient, appClient), - AppComparator: appComparator, - repoServerGRPC: repoServerGRPC, } err = fixture.setup() if err != nil { @@ -154,20 +222,35 @@ func (f *Fixture) CreateApp(t *testing.T, application *v1alpha1.Application) *v1 // CreateController creates new controller instance func (f *Fixture) CreateController() *controller.ApplicationController { + repoService := apirepository.NewServer(f.Namespace, f.KubeClient, f.AppClient) + clusterService := cluster.NewServer(f.Namespace, f.KubeClient, f.AppClient) + appStateManager := controller.NewAppStateManager( + clusterService, repoService, f.AppClient, reposerver.NewRepositoryServerClientset(f.RepoServerAddress), f.Namespace) + + appHealthManager := controller.NewAppHealthManager(clusterService, f.Namespace) + return controller.NewApplicationController( f.Namespace, f.KubeClient, f.AppClient, - reposerver.NewRepositoryServerClientset(f.repoServerListener.Addr().String()), - f.ApiRepoService, cluster.NewServer(f.Namespace, f.KubeClient, f.AppClient), - f.AppComparator, - time.Second, + appStateManager, + appHealthManager, + 10*time.Second, &controller.ApplicationControllerConfig{Namespace: f.Namespace, InstanceID: f.InstanceID}) } -// PollUntil periodically executes specified condition until it returns true. -func PollUntil(t *testing.T, condition wait.ConditionFunc) { +func (f *Fixture) RunCli(args ...string) (string, error) { + cmd := commands.NewCommand() + cmd.SetArgs(append(args, "--server", f.ApiServerAddress, "--plaintext")) + output := new(bytes.Buffer) + cmd.SetOutput(output) + err := cmd.Execute() + return output.String(), err +} + +// WaitUntil periodically executes specified condition until it returns true. +func WaitUntil(t *testing.T, condition wait.ConditionFunc) { stop := make(chan struct{}) isClosed := false makeSureClosed := func() { diff --git a/util/cache/redis.go b/util/cache/redis.go index 64b60b2e75a99..ad0a4a19800cc 100644 --- a/util/cache/redis.go +++ b/util/cache/redis.go @@ -45,5 +45,5 @@ func (r *redisCache) Get(key string, obj interface{}) error { if err == rediscache.ErrCacheMiss { return ErrCacheMiss } - return nil + return err } diff --git a/util/kube/kube.go b/util/kube/kube.go index 8e87092a33868..d0efad192ad27 100644 --- a/util/kube/kube.go +++ b/util/kube/kube.go @@ -446,8 +446,10 @@ func ApplyResource(config *rest.Config, obj *unstructured.Unstructured, namespac cmd.Stdin = bytes.NewReader(manifestBytes) out, err := cmd.Output() if err != nil { - exErr := err.(*exec.ExitError) - return nil, fmt.Errorf("failed to apply '%s': %s", obj.GetName(), exErr.Stderr) + if exErr, ok := err.(*exec.ExitError); ok { + return nil, fmt.Errorf("failed to apply '%s': %s", obj.GetName(), exErr.Stderr) + } + return nil, err } var liveObj unstructured.Unstructured err = json.Unmarshal(out, &liveObj)