Skip to content

chore: LastCompletedNonDryRunOperation support #22530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/swagger.json

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

13 changes: 8 additions & 5 deletions controller/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,14 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha

logEntry.WithField("duration", time.Since(start)).Info("sync/terminate complete")

if !syncOp.DryRun && len(syncOp.Resources) == 0 && state.Phase.Successful() {
err := m.persistRevisionHistory(app, compareResult.syncStatus.Revision, source, compareResult.syncStatus.Revisions, compareResult.syncStatus.ComparedTo.Sources, isMultiSourceRevision, state.StartedAt, state.Operation.InitiatedBy)
if err != nil {
state.Phase = common.OperationError
state.Message = fmt.Sprintf("failed to record sync to history: %v", err)
if !syncOp.DryRun && state.Phase.Successful() {
app.Status.LastCompletedNonDryRunOperation = state
if len(syncOp.Resources) == 0 {
err := m.persistRevisionHistory(app, compareResult.syncStatus.Revision, source, compareResult.syncStatus.Revisions, compareResult.syncStatus.ComparedTo.Sources, isMultiSourceRevision, state.StartedAt, state.Operation.InitiatedBy)
if err != nil {
state.Phase = common.OperationError
state.Message = fmt.Sprintf("failed to record sync to history: %v", err)
}
}
}
}
Expand Down
1,882 changes: 1,882 additions & 0 deletions manifests/core-install-with-hydrator.yaml

Large diffs are not rendered by default.

1,882 changes: 1,882 additions & 0 deletions manifests/core-install.yaml

Large diffs are not rendered by default.

1,882 changes: 1,882 additions & 0 deletions manifests/crds/application-crd.yaml

Large diffs are not rendered by default.

1,882 changes: 1,882 additions & 0 deletions manifests/ha/install-with-hydrator.yaml

Large diffs are not rendered by default.

1,882 changes: 1,882 additions & 0 deletions manifests/ha/install.yaml

Large diffs are not rendered by default.

1,882 changes: 1,882 additions & 0 deletions manifests/install-with-hydrator.yaml

Large diffs are not rendered by default.

1,882 changes: 1,882 additions & 0 deletions manifests/install.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/apiclient/application/forwarder_overwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var appFields = map[string]func(app *v1alpha1.Application) any{
}
return nil
},
"status.lastNonDryRunOperationState": func(app *v1alpha1.Application) any { return app.GetLastNonDryRunOperationState() },
"status.resources": func(app *v1alpha1.Application) any {
if len(app.Status.Resources) > 0 {
return app.Status.Resources
Expand Down
1,476 changes: 766 additions & 710 deletions pkg/apis/application/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pkg/apis/application/v1alpha1/generated.proto

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

11 changes: 11 additions & 0 deletions pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,8 @@ type ApplicationStatus struct {
ControllerNamespace string `json:"controllerNamespace,omitempty" protobuf:"bytes,13,opt,name=controllerNamespace"`
// SourceHydrator stores information about the current state of source hydration
SourceHydrator SourceHydratorStatus `json:"sourceHydrator,omitempty" protobuf:"bytes,14,opt,name=sourceHydrator"`
// OperationState contains information about the last non dryrun completed operation
LastCompletedNonDryRunOperation *OperationState `json:"lastCompletedNonDryRunOperation,omitempty" protobuf:"bytes,15,opt,name=lastCompletedNonDryRunOperation"`
}

// SourceHydratorStatus contains information about the current state of source hydration
Expand Down Expand Up @@ -3214,6 +3216,15 @@ func (app *Application) IsFinalizerPresent(finalizer string) bool {
return getFinalizerIndex(app.ObjectMeta, finalizer) > -1
}

// GetLastNonDryRunOperationState returns the last complete or ongoing non dryrun operation if exists or nil in other case
func (app *Application) GetLastNonDryRunOperationState() *OperationState {
if app.Status.OperationState != nil && app.Status.OperationState.Operation.DryRun() {
return app.Status.LastCompletedNonDryRunOperation
}

return app.Status.OperationState
}

// SetConditions updates the application status conditions for a subset of evaluated types.
// If the application has a pre-existing condition of a type that is not in the evaluated list,
// it will be preserved. If the application has a pre-existing condition of a type that
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/application/v1alpha1/zz_generated.deepcopy.go

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

Loading