Skip to content

OCPBUGS-858: Package Server Manager should enforce expected csv values #378

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

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

awgreene
Copy link
Contributor

@awgreene awgreene commented Sep 6, 2022

Problem:
The package-server-manifest (PSM) is a downstream specific component responsible for reconciling the package-server csv, which is defined here as a yaml file. When the PSM reconciles the package-server csv, it:

  • Attempts to generate the base of the expected CSV here
  • Passes the reconcile function as the mutateFn parameter and the expectedCSV as the obj parameter into into controller-runtime's createOrUpdate function. Controller runtime's createOrUpdate function will apply the mutateFn function against:
  • The obj you passed in if it does not already exist.
    OR
  • The existing on cluster object.

In the case where the mutateFn is applied to the applied to the existing object, changes made to the package-server csv yaml are ignored because the mutateFn (ie the reconcileCSV function) doesn't consider changes to the manifest.

Solution:
Update the reconcileCSV function to:

  • Ensure that expected annotations and labels are present on the csv.
  • Ensure that the expected spec is present on the csv.

@awgreene awgreene changed the title Fixes an issue where package-server-manager doesn't respect changes t… OCPBUGS-867: Fixes an issue where package-server-manager doesn't respect changes t… Sep 6, 2022
@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Sep 6, 2022
@openshift-ci-robot
Copy link

@awgreene: This pull request references Jira Issue OCPBUGS-867, which is invalid:

  • expected the bug to target the "4.12.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

…o the packageserver manifest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@awgreene
Copy link
Contributor Author

awgreene commented Sep 6, 2022

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Sep 6, 2022
@openshift-ci-robot
Copy link

@awgreene: This pull request references Jira Issue OCPBUGS-867, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.12.0) matches configured target version for branch (4.12.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@awgreene
Copy link
Contributor Author

awgreene commented Sep 6, 2022

WIP
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 6, 2022
@openshift-ci openshift-ci bot requested review from exdx and gallettilance September 6, 2022 21:25
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 6, 2022
@awgreene awgreene changed the title OCPBUGS-867: Fixes an issue where package-server-manager doesn't respect changes t… OCPBUGS-858: Fixes an issue where package-server-manager doesn't respect changes t… Sep 6, 2022
@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. and removed jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Sep 6, 2022
@openshift-ci-robot
Copy link

@awgreene: This pull request references Jira Issue OCPBUGS-858, which is invalid:

  • expected the bug to target the "4.12.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

…o the packageserver manifest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@awgreene
Copy link
Contributor Author

awgreene commented Sep 6, 2022

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Sep 6, 2022
@openshift-ci-robot
Copy link

@awgreene: This pull request references Jira Issue OCPBUGS-858, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.12.0) matches configured target version for branch (4.12.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@awgreene
Copy link
Contributor Author

awgreene commented Sep 7, 2022

/retest

Copy link
Contributor

@tylerslaton tylerslaton left a comment

Choose a reason for hiding this comment

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

/lgtm

log.V(3).Info("no further updates are necessary to the packageserver csv")
}

// Ensure defaults
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe expand a bit more on what it means to ensure these defaults here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 7, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 7, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awgreene, tylerslaton

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-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2022
@grokspawn
Copy link
Contributor

/hold until we get the qe-approved label

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 8, 2022
@anik120
Copy link
Contributor

anik120 commented Sep 8, 2022

I wonder if there's a way to launch a 4.9 cluster with this PR. It'd be ideal to do an upgrade testing from 4.9->4.12 with this PR, and make sure that for each OCP version, the correct CSV version is being deployed on upgrade.

}
if !ensureCSV(log, image, csv, highAvailabilityMode) {

if modified {
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean if !modified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2022
tt := []struct {
name string
inputCSV *olmv1alpha1.ClusterServiceVersion
expectedCSV *olmv1alpha1.ClusterServiceVersion
highlyAvailable bool
want bool
want wanted
Copy link
Contributor

Choose a reason for hiding this comment

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

all test cases seem to set expectedErr to nil. Is it worth exercising the failure path as well?
Seems like it only happens when there are issues deserializing the csv

Copy link
Contributor Author

@awgreene awgreene Sep 8, 2022

Choose a reason for hiding this comment

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

That's correct, all tests expect no error from this method. The request to add an error testcase seems reasonable, but the only instance where the ensureCSV function can return an error is when the manifests.NewPackageServerCSV function has an error unmarshalling the packageserver.yaml, which is hardcoded (as it should be IMO). While we could mock the function or update it to take a configurable path, it seemed like overkill and I didn't want to increase the scope of this PR given that it will need to be backported to 4.9.

If you feel strongly that we should test this path, I can update it when I'm back from vacation next week.

Copy link
Contributor

Choose a reason for hiding this comment

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

my preference would be to not increase the scope of this PR either, specially with the need to backport in mind. We could always have a follow up PR for the test

Copy link
Contributor Author

@awgreene awgreene left a comment

Choose a reason for hiding this comment

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

Last minute additions

csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs[0].Spec.Template.Spec.Affinity = affinity
}
}
func withRolloutStrategy(strategy *appsv1.RollingUpdateDeployment) func(*olmv1alpha1.ClusterServiceVersion) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shoot, @grokspawn could you change this to the name of the field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe withRollingUpdateStrategy? Open to suggestions

Copy link
Contributor

Choose a reason for hiding this comment

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

How about withRollingUpdateStrategy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Funny that your comment came in after mine, but at least great minds think alike. :)


var modified bool

for k, v := range expectedCSV.GetLabels() {
Copy link
Contributor Author

@awgreene awgreene Sep 8, 2022

Choose a reason for hiding this comment

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

We should add a check that the csv's annotations and label maps are not nil @grokspawn. If they are nil, set them to new maps and populate with the following for loops.

Copy link
Contributor Author

@awgreene awgreene Sep 8, 2022

Choose a reason for hiding this comment

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

Something like

'''
if csv.GetAnnotations() == nil {
csv.SetAnnotations(make(map[string]string))
modified = true
}
'''

Could add a check if the expectedCSV has annotations, but it always should.

**Problem:**
The package-server-manifest (PSM) is a downstream specific component
responsible for reconciling the package-server csv, which is defined
in code as a yaml file. When the PSM reconciles the package-server
csv, it:
- Attempts to generate the base of the expected CSV from the yaml
mentioned above.
- Passes the reconcileCSV function as the mutateFn parameter and
the expectedCSV  as the `obj` parameter into into controller-runtime's
createOrUpdate function.

Controller runtime's createOrUpdate function will apply the mutateFn
function against:
- The `obj` you passed in if it does not already exist.
OR
- The existing on cluster object.

In the case where the mutateFn is applied to the applied to the
existing object, changes made to the package-server csv yaml are
ignored because the mutateFn (ie the reconcileCSV function)
doesn't consider changes to the manifest.

**Solution:**
Update the reconcileCSV function to:
- Ensure that expected annotations and labels are present on the csv.
- Ensure that the expected spec is present on the csv.
@grokspawn
Copy link
Contributor

@ qe, please take a look at the reproduction steps in OCPBUGS-867 for a (relatively) easy verification.

@anik120
Copy link
Contributor

anik120 commented Sep 9, 2022

/test e2e-gcp-ovn

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2022

@awgreene: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@jianzhangbjz
Copy link
Contributor

I wonder if there's a way to launch a 4.9 cluster with this PR. It'd be ideal to do an upgrade testing from 4.9->4.12 with this PR, and make sure that for each OCP version, the correct CSV version is being deployed on upgrade.

Yes, but I guess no. In fact, I build a payload with this PR by using cluster-bot, and upgrade OCP 4.10.32 to it forcefully, it works well.

@bandrade
Copy link
Contributor

bandrade commented Sep 9, 2022

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Sep 9, 2022
Copy link
Member

@dinhxuanvu dinhxuanvu left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 9, 2022
@grokspawn
Copy link
Contributor

/hold cancel
got the qe-approved label 😄

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 9, 2022
@openshift-merge-robot openshift-merge-robot merged commit 208ce9a into openshift:master Sep 9, 2022
@openshift-ci-robot
Copy link

@awgreene: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-858 has been moved to the MODIFIED state.

In response to this:

Problem:
The package-server-manifest (PSM) is a downstream specific component responsible for reconciling the package-server csv, which is defined here as a yaml file. When the PSM reconciles the package-server csv, it:

  • Attempts to generate the base of the expected CSV here
  • Passes the reconcile function as the mutateFn parameter and the expectedCSV as the obj parameter into into controller-runtime's createOrUpdate function. Controller runtime's createOrUpdate function will apply the mutateFn function against:
  • The obj you passed in if it does not already exist.
    OR
  • The existing on cluster object.

In the case where the mutateFn is applied to the applied to the existing object, changes made to the package-server csv yaml are ignored because the mutateFn (ie the reconcileCSV function) doesn't consider changes to the manifest.

Solution:
Update the reconcileCSV function to:

  • Ensure that expected annotations and labels are present on the csv.
  • Ensure that the expected spec is present on the csv.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jianzhangbjz
Copy link
Contributor

@anik120
Copy link
Contributor

anik120 commented Sep 9, 2022

/cherry-pick release-4.11

for https://issues.redhat.com/browse/OCPBUGS-1103

@openshift-cherrypick-robot

@anik120: new pull request created: #381

In response to this:

/cherry-pick release-4.11

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.