Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(installmodes): update support logic to match expected behavior #733

Merged

Conversation

njhale
Copy link
Member

@njhale njhale commented Feb 28, 2019

Change InstallMode behavior to match desired:

  • OwnNamespace: If supported, the operator can be a member of an OperatorGroup that selects its own namespace
  • SingleNamespace: If supported, the operator can be a member of an OperatorGroup that selects one namespace
  • MultiNamespace: If supported, the operator can be a member of an OperatorGroup that selects more than one namespace
  • AllNamespaces: If supported, the operator can be a member of an OperatorGroup that selects all namespaces (target namespace set is the empty string "")

Addresses ALM-927.

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 28, 2019
@njhale
Copy link
Member Author

njhale commented Feb 28, 2019

/hold

Need to verify community-operator still InstallModes work with the new logic.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 28, 2019
@njhale
Copy link
Member Author

njhale commented Feb 28, 2019

/retest

Copy link
Member

@ecordell ecordell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 28, 2019
@njhale
Copy link
Member Author

njhale commented Feb 28, 2019

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 28, 2019
@njhale
Copy link
Member Author

njhale commented Mar 1, 2019

/retest

@njhale
Copy link
Member Author

njhale commented Mar 1, 2019

/hold

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 1, 2019
@@ -346,6 +346,22 @@ func (a *Operator) handleClusterServiceVersionDeletion(obj interface{}) {
defer func(csv v1alpha1.ClusterServiceVersion) {
logger.Debug("removing csv from queue set")
a.csvQueueSet.Remove(csv.GetName(), csv.GetNamespace())

// Requeue all OperatorGroups in the namespace
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I was working on this, I decided to make OperatorGroup requeuing on CSV deletion more robust.

- OperatorGroup sync bails out after successful namespace update
detected
- Check CSV status before re-transitioning to failed states due to
OperatorGroup issues
- Check CSV annotations before setting OperatorGroup annotations
- Make OperatorGroup requeuing more aggressive on CSV deletion
- Requeue OperatorGroup in OperatorGroup sync if CSV update fails and
CSV still exists
@njhale njhale force-pushed the fix-installmodes branch from 1f78dce to d039748 Compare March 1, 2019 23:22
// No target annotation
if !ok {
logger.Info("no olm.targetNamespaces annotation")
return nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before adding the return, we would always associate a missing olm.targetNamespaces annotation with NamespaceAll.

if err != nil {
logger.Error("error adding operatorgroup annotation")
syncError = err
if a.operatorGroupAnnotationsDiffer(&out.ObjectMeta, operatorGroup) {
Copy link
Member Author

@njhale njhale Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for differences before updating the annotations.

logger.Warn(syncError.Error())
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonTooManyOperatorGroups, syncError.Error(), now, a.recorder)
logger.WithError(syncError).Warn("csv failed to become an operatorgroup member")
if out.Status.Reason != v1alpha1.CSVReasonTooManyOperatorGroups {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap set phase with status check to prevent unnecessary updates.

@@ -3576,6 +3576,10 @@ func TestSyncOperatorGroups(t *testing.T) {
}
}

// Sync again to catch provided API changes
err = op.syncOperatorGroups(tt.initial.operatorGroup)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed because OperatorGroup sync returns after each meaningful update and relies on the update event to trigger another sync.

}

// CSV requeue is handled by the succeeding sync
return nil
Copy link
Member Author

@njhale njhale Mar 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The status update will trigger another sync - no need to continue.

if csv.IsCopied() {
logger.Debug("csv is copied. not including in operatorgroup's provided api set")
logger.Debug("csv is copied. not updating annotations or including in operatorgroup's provided api set")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to also ignore annotation checks for copied CSVs.

metav1.SetMetaDataAnnotation(obj, v1alpha2.OperatorGroupNamespaceAnnotationKey, op.GetNamespace())
metav1.SetMetaDataAnnotation(obj, v1alpha2.OperatorGroupAnnotationKey, op.GetName())
if addTargets {

if addTargets && op.Status.Namespaces != nil {
Copy link
Member Author

@njhale njhale Mar 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guard against empty namespace list being evaluated as NamespaceAll.

@njhale
Copy link
Member Author

njhale commented Mar 4, 2019

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 4, 2019
metav1.SetMetaDataAnnotation(obj, v1alpha2.OperatorGroupTargetsAnnotationKey, strings.Join(op.Status.Namespaces, ","))
}
}

func (a *Operator) operatorGroupAnnotationsDiffer(obj *metav1.ObjectMeta, op *v1alpha2.OperatorGroup) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@njhale
Copy link
Member Author

njhale commented Mar 5, 2019

/test all

@njhale
Copy link
Member Author

njhale commented Mar 6, 2019

/retest

@ecordell
Copy link
Member

ecordell commented Mar 7, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2019
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ecordell, njhale

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 8d22327 into operator-framework:master Mar 7, 2019
ecordell pushed a commit to ecordell/operator-lifecycle-manager that referenced this pull request Mar 8, 2019
fix(installmodes): update support logic to match expected behavior
@njhale njhale added the kind/bug Categorizes issue or PR as related to a bug. label Mar 19, 2019
@ecordell ecordell removed kind/bug Categorizes issue or PR as related to a bug. labels Mar 19, 2019
@njhale njhale added the kind/bug Categorizes issue or PR as related to a bug. label Mar 19, 2019
@ecordell ecordell added kind/bug Categorizes issue or PR as related to a bug. and removed kind/bug Categorizes issue or PR as related to a bug. labels Mar 19, 2019
@njhale njhale deleted the fix-installmodes branch September 30, 2019 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants