Skip to content

Commit

Permalink
Makes the operator's own namespace available to its actions
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomjinx committed Feb 23, 2022
1 parent bb90e0e commit 53d5231
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (r *ReconcileSyndesis) Reconcile(ctx context.Context, request reconcile.Req

if a.CanExecute(syndesis) {
log.V(synpkg.DEBUG_LOGGING_LVL).Info("Running action", "action", reflect.TypeOf(a))
if err := a.Execute(ctx, syndesis); err != nil {
if err := a.Execute(ctx, syndesis, request.Namespace); err != nil {
log.Error(err, "Error reconciling", "action", reflect.TypeOf(a), "phase", syndesis.Status.Phase)
return reconcile.Result{
Requeue: true,
Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var actionLog = logf.Log.WithName("action")

type SyndesisOperatorAction interface {
CanExecute(syndesis *synapi.Syndesis) bool
Execute(ctx context.Context, syndesis *synapi.Syndesis) error
Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error
}

// NewOperatorActions gives the default set of actions operator will perform
Expand Down
6 changes: 3 additions & 3 deletions install/operator/pkg/syndesis/action/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (a *backupAction) CanExecute(syndesis *synapi.Syndesis) bool {
}

// Schedule a cronjob for systematic backups
func (a *backupAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a *backupAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {
entries := c.Entries()

if s := syndesis.Spec.Backup.Schedule; s != "" {
Expand All @@ -74,7 +74,7 @@ func (a *backupAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) e
client, _ := a.clientTools.RuntimeClient()
return client.Status().Update(ctx, syndesis)
} else {
return fmt.Errorf("unsopported number of entries for cron instance, cron %v", c)
return fmt.Errorf("unsupported number of entries for cron instance, cron %v", c)
}
} else {
if len(entries) == 1 {
Expand All @@ -84,7 +84,7 @@ func (a *backupAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) e
c.Remove(e.ID)
c.Stop()
} else if len(entries) > 1 {
return fmt.Errorf("unsopported number of entries for cron instance, cron %v", c)
return fmt.Errorf("unsupported number of entries for cron instance, cron %v", c)
}
}

Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/checkupdates.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (a checkUpdatesAction) CanExecute(syndesis *synapi.Syndesis) bool {
synapi.SyndesisPhaseStartupFailed)
}

func (a checkUpdatesAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a checkUpdatesAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {
if a.operatorVersion == "" {
a.operatorVersion = pkg.DefaultOperatorTag
}
Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (a *initializeAction) CanExecute(syndesis *synapi.Syndesis) bool {
synapi.SyndesisPhaseNotInstalled)
}

func (a *initializeAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a *initializeAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {
list := synapi.SyndesisList{}
rtClient, _ := a.clientTools.RuntimeClient()
err := rtClient.List(ctx, &list, &client.ListOptions{Namespace: syndesis.Namespace})
Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (a *installAction) CanExecute(syndesis *synapi.Syndesis) bool {

var kindsReportedNotAvailable = map[schema.GroupVersionKind]time.Time{}

func (a *installAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a *installAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {
if syndesisPhaseIs(syndesis, synapi.SyndesisPhaseInstalling) {
a.log.Info("installing Syndesis resource", "name", syndesis.Name)
} else if syndesisPhaseIs(syndesis, synapi.SyndesisPhasePostUpgradeRun) {
Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/pod_scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (a *podSchedulingAction) CanExecute(syndesis *synapi.Syndesis) bool {
return canExecute
}

func (a *podSchedulingAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a *podSchedulingAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {
if a.updateIntegrationScheduling {
a.executeIntegrationScheduling(ctx, syndesis)
}
Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (a *startupAction) CanExecute(syndesis *synapi.Syndesis) bool {
synapi.SyndesisPhaseStartupFailed)
}

func (a *startupAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a *startupAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {

list := v1.DeploymentConfigList{
TypeMeta: metav1.TypeMeta{
Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (a *upgradeAction) CanExecute(syndesis *synapi.Syndesis) bool {
)
}

func (a *upgradeAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a *upgradeAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {
targetVersion := pkg.DefaultOperatorTag

if syndesis.Status.Phase == synapi.SyndesisPhaseUpgrading {
Expand Down
2 changes: 1 addition & 1 deletion install/operator/pkg/syndesis/action/upgradebackoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (a *upgradeBackoffAction) CanExecute(syndesis *synapi.Syndesis) bool {
return syndesisPhaseIs(syndesis, synapi.SyndesisPhaseUpgradeFailureBackoff)
}

func (a *upgradeBackoffAction) Execute(ctx context.Context, syndesis *synapi.Syndesis) error {
func (a *upgradeBackoffAction) Execute(ctx context.Context, syndesis *synapi.Syndesis, operatorNamespace string) error {
rtClient, _ := a.clientTools.RuntimeClient()

// Check number of attempts to fail fast
Expand Down

0 comments on commit 53d5231

Please sign in to comment.