Skip to content

Commit

Permalink
Merge branch 'master' into feature/plugin-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
binboum committed May 24, 2023
2 parents 9813471 + 0a8a71e commit 7fb3353
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 26 deletions.
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ Currently, the following organizations are **officially** using Argo CD:
1. [Unifonic Inc](https://www.unifonic.com/)
1. [Universidad Mesoamericana](https://www.umes.edu.gt/)
1. [Vectra](https://www.vectra.ai)
1. [Veepee](https://www.veepee.com)
1. [Viaduct](https://www.viaduct.ai/)
1. [Vinted](https://vinted.com/)
1. [Virtuo](https://www.govirtuo.com/)
Expand Down
2 changes: 1 addition & 1 deletion assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8557,7 +8557,7 @@
},
"selfHeal": {
"type": "boolean",
"title": "SelfHeal specifes whether to revert resources back to their desired state upon modification in the cluster (default: false)"
"title": "SelfHeal specifies whether to revert resources back to their desired state upon modification in the cluster (default: false)"
}
}
},
Expand Down
33 changes: 23 additions & 10 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
}
}
for _, appName := range appNames {
_, err := waitOnApplicationStatus(ctx, acdClient, appName, timeout, watch, selectedResources)
_, _, err := waitOnApplicationStatus(ctx, acdClient, appName, timeout, watch, selectedResources)
errors.CheckError(err)
}
},
Expand Down Expand Up @@ -1771,15 +1771,15 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
errors.CheckError(err)

if !async {
app, err := waitOnApplicationStatus(ctx, acdClient, appQualifiedName, timeout, watchOpts{operation: true}, selectedResources)
app, opState, err := waitOnApplicationStatus(ctx, acdClient, appQualifiedName, timeout, watchOpts{operation: true}, selectedResources)
errors.CheckError(err)

if !dryRun {
if !app.Status.OperationState.Phase.Successful() {
log.Fatalf("Operation has completed with phase: %s", app.Status.OperationState.Phase)
if !opState.Phase.Successful() {
log.Fatalf("Operation has completed with phase: %s", opState.Phase)
} else if len(selectedResources) == 0 && app.Status.Sync.Status != argoappv1.SyncStatusCodeSynced {
// Only get resources to be pruned if sync was application-wide and final status is not synced
pruningRequired := app.Status.OperationState.SyncResult.Resources.PruningRequired()
pruningRequired := opState.SyncResult.Resources.PruningRequired()
if pruningRequired > 0 {
log.Fatalf("%d resources require pruning", pruningRequired)
}
Expand Down Expand Up @@ -1993,7 +1993,10 @@ func checkResourceStatus(watch watchOpts, healthStatus string, syncStatus string

const waitFormatString = "%s\t%5s\t%10s\t%10s\t%20s\t%8s\t%7s\t%10s\t%s\n"

func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client, appName string, timeout uint, watch watchOpts, selectedResources []*argoappv1.SyncOperationResource) (*argoappv1.Application, error) {
// waitOnApplicationStatus watches an application and blocks until either the desired watch conditions
// are fulfiled or we reach the timeout. Returns the app once desired conditions have been filled.
// Additionally return the operationState at time of fulfilment (which may be different than returned app).
func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client, appName string, timeout uint, watch watchOpts, selectedResources []*argoappv1.SyncOperationResource) (*argoappv1.Application, *argoappv1.OperationState, error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand Down Expand Up @@ -2051,10 +2054,20 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client,
AppNamespace: &appNs,
})
errors.CheckError(err)

// printFinalStatus() will refresh and update the app object, potentially causing the app's
// status.operationState to be different than the version when we break out of the event loop.
// This means the app.status is unreliable for determining the final state of the operation.
// finalOperationState captures the operationState as it was seen when we met the conditions of
// the wait, so the caller can rely on it to determine the outcome of the operation.
// See: https://github.com/argoproj/argo-cd/issues/5592
finalOperationState := app.Status.OperationState

appEventCh := acdClient.WatchApplicationWithRetry(ctx, appName, app.ResourceVersion)
for appEvent := range appEventCh {
app = &appEvent.Application

finalOperationState = app.Status.OperationState
operationInProgress := false
// consider the operation is in progress
if app.Operation != nil {
Expand Down Expand Up @@ -2092,7 +2105,7 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client,

if selectedResourcesAreReady && (!operationInProgress || !watch.operation) {
app = printFinalStatus(app)
return app, nil
return app, finalOperationState, nil
}

newStates := groupResourceStates(app, selectedResources)
Expand All @@ -2102,7 +2115,7 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client,
if prevState, found := prevStates[stateKey]; found {
if watch.health && prevState.Health != string(health.HealthStatusUnknown) && prevState.Health != string(health.HealthStatusDegraded) && newState.Health == string(health.HealthStatusDegraded) {
_ = printFinalStatus(app)
return nil, fmt.Errorf("application '%s' health state has transitioned from %s to %s", appName, prevState.Health, newState.Health)
return nil, finalOperationState, fmt.Errorf("application '%s' health state has transitioned from %s to %s", appName, prevState.Health, newState.Health)
}
doPrint = prevState.Merge(newState)
} else {
Expand All @@ -2116,7 +2129,7 @@ func waitOnApplicationStatus(ctx context.Context, acdClient argocdclient.Client,
_ = w.Flush()
}
_ = printFinalStatus(app)
return nil, fmt.Errorf("timed out (%ds) waiting for app %q match desired state", timeout, appName)
return nil, finalOperationState, fmt.Errorf("timed out (%ds) waiting for app %q match desired state", timeout, appName)
}

// setParameterOverrides updates an existing or appends a new parameter override in the application
Expand Down Expand Up @@ -2272,7 +2285,7 @@ func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobr
})
errors.CheckError(err)

_, err = waitOnApplicationStatus(ctx, acdClient, app.QualifiedName(), timeout, watchOpts{
_, _, err = waitOnApplicationStatus(ctx, acdClient, app.QualifiedName(), timeout, watchOpts{
operation: true,
}, nil)
errors.CheckError(err)
Expand Down
2 changes: 1 addition & 1 deletion manifests/core-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ spec:
as part of automated sync (default: false)'
type: boolean
selfHeal:
description: 'SelfHeal specifes whether to revert resources
description: 'SelfHeal specifies whether to revert resources
back to their desired state upon modification in the cluster
(default: false)'
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion manifests/crds/application-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ spec:
as part of automated sync (default: false)'
type: boolean
selfHeal:
description: 'SelfHeal specifes whether to revert resources
description: 'SelfHeal specifies whether to revert resources
back to their desired state upon modification in the cluster
(default: false)'
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion manifests/ha/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ spec:
as part of automated sync (default: false)'
type: boolean
selfHeal:
description: 'SelfHeal specifes whether to revert resources
description: 'SelfHeal specifies whether to revert resources
back to their desired state upon modification in the cluster
(default: false)'
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ spec:
as part of automated sync (default: false)'
type: boolean
selfHeal:
description: 'SelfHeal specifes whether to revert resources
description: 'SelfHeal specifies whether to revert resources
back to their desired state upon modification in the cluster
(default: false)'
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/application/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/application/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ func NewKustomizeReplica(text string) (*KustomizeReplica, error) {
func (k *ApplicationSourceKustomize) AllowsConcurrentProcessing() bool {
return len(k.Images) == 0 &&
len(k.CommonLabels) == 0 &&
len(k.CommonAnnotations) == 0 &&
k.NamePrefix == "" &&
k.Namespace == "" &&
k.NameSuffix == ""
Expand Down Expand Up @@ -1152,7 +1153,7 @@ type Backoff struct {
type SyncPolicyAutomated struct {
// Prune specifies whether to delete resources from the cluster that are not found in the sources anymore as part of automated sync (default: false)
Prune bool `json:"prune,omitempty" protobuf:"bytes,1,opt,name=prune"`
// SelfHeal specifes whether to revert resources back to their desired state upon modification in the cluster (default: false)
// SelfHeal specifies whether to revert resources back to their desired state upon modification in the cluster (default: false)
SelfHeal bool `json:"selfHeal,omitempty" protobuf:"bytes,2,opt,name=selfHeal"`
// AllowEmpty allows apps have zero live resources (default: false)
AllowEmpty bool `json:"allowEmpty,omitempty" protobuf:"bytes,3,opt,name=allowEmpty"`
Expand Down
18 changes: 14 additions & 4 deletions pkg/apis/application/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2973,11 +2973,21 @@ func TestRetryStrategy_NextRetryAtCustomBackoff(t *testing.T) {
}

func TestSourceAllowsConcurrentProcessing_KustomizeParams(t *testing.T) {
src := ApplicationSource{Path: ".", Kustomize: &ApplicationSourceKustomize{
NameSuffix: "test",
}}
t.Run("Has NameSuffix", func(t *testing.T) {
src := ApplicationSource{Path: ".", Kustomize: &ApplicationSourceKustomize{
NameSuffix: "test",
}}

assert.False(t, src.AllowsConcurrentProcessing())
})

assert.False(t, src.AllowsConcurrentProcessing())
t.Run("Has CommonAnnotations", func(t *testing.T) {
src := ApplicationSource{Path: ".", Kustomize: &ApplicationSourceKustomize{
CommonAnnotations: map[string]string{"foo": "bar"},
}}

assert.False(t, src.AllowsConcurrentProcessing())
})
}

func TestUnSetCascadedDeletion(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion server/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ func (s *Server) Rollback(ctx context.Context, rollbackReq *application.Applicat
}

func (s *Server) ListLinks(ctx context.Context, req *application.ListAppLinksRequest) (*application.LinksResponse, error) {
a, err := s.getApplicationEnforceRBACClient(ctx, rbacpolicy.ActionSync, req.GetNamespace(), req.GetName(), "")
a, err := s.getApplicationEnforceRBACClient(ctx, rbacpolicy.ActionGet, req.GetNamespace(), req.GetName(), "")
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
text-align: right;
label {
padding-right: 2em;
@include themify($themes) {
color: themed('text-2');
}
color: $argo-color-gray-8;
}
}
&__diff {
Expand Down
3 changes: 3 additions & 0 deletions ui/src/app/shared/components/layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ export interface LayoutProps {
isExtension?: boolean;
}

const getBGColor = (theme: string): string => (theme === 'light' ? '#dee6eb' : '#100f0f');

export const Layout = (props: LayoutProps) => (
<div className={props.pref.theme ? 'theme-' + props.pref.theme : 'theme-light'}>
<div className={`cd-layout ${props.isExtension ? 'cd-layout--extension' : ''}`}>
<Sidebar onVersionClick={props.onVersionClick} navItems={props.navItems} pref={props.pref} />
{props.pref.theme ? (document.body.style.background = getBGColor(props.pref.theme)) : null}
<div className={`cd-layout__content ${props.pref.hideSidebar ? 'cd-layout__content--sb-collapsed' : 'cd-layout__content--sb-expanded'} custom-styles`}>
{props.children}
</div>
Expand Down

0 comments on commit 7fb3353

Please sign in to comment.