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

Update condition lib to use v2 #61

Conversation

awgreene
Copy link
Member

The v2 OperatorCondition CRD was introduced to the operator-framework/api
repository. This change updates the condition library to consume the new
changes.

Copy link
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

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

A quick doubt, is OLM still going to support v1 condition CRD's for a release and then deprecate (eventually remove) later? If thats the case, I suppose this condition lib should also be versioned in a way to support both the condition CRD versions till OLM removes v1 Conditions. Or is it not necessary?
cc: @estroz @jmrodri

@awgreene
Copy link
Member Author

A quick doubt, is OLM still going to support v1 condition CRD's for a release and then deprecate (eventually remove) later? If thats the case, I suppose this condition lib should also be versioned in a way to support both the condition CRD versions till OLM removes v1 Conditions. Or is it not necessary?
cc: @estroz @jmrodri

OperatorCondition V1 does not handle race conditions so it is broken. We do not want anyone using v1.

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 May 26, 2021
@coveralls
Copy link

coveralls commented May 26, 2021

Pull Request Test Coverage Report for Build 1004777565

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 79.187%

Totals Coverage Status
Change from base Build 943897131: 0.0%
Covered Lines: 331
Relevant Lines: 418

💛 - Coveralls

@estroz
Copy link
Member

estroz commented May 26, 2021

So clearly there is not enough test coverage somewhere that resulted in this race condition not being caught. Has that coverage been implemented somewhere? Are more tests needed here?

ObjectMeta: metav1.ObjectMeta{Name: "operator-condition-test", Namespace: ns},
Status: apiv1.OperatorConditionStatus{
Spec: apiv2.OperatorConditionSpec{
Copy link
Member

@varshaprasad96 varshaprasad96 May 26, 2021

Choose a reason for hiding this comment

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

a non-blocker, but it would be helpful to have conditionType declared in v2 too. Its odd that for someone using this library, they would have to use conditionType from v1 and refer to OperatorCondition api from v2. Example - here.

If not the other option is - to remove the conditionType itself and let users specify a string directly.

Copy link
Member

Choose a reason for hiding this comment

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

@awgreene
Copy link
Member Author

So clearly there is not enough test coverage somewhere that resulted in this race condition not being caught. Has that coverage been implemented somewhere? Are more tests needed here?

@estroz this should be handled in the OLM PR operator-framework/operator-lifecycle-manager#2160

@awgreene awgreene force-pushed the fix-operator-condition-lib branch from f89aaba to 180e696 Compare May 27, 2021 14:00
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label May 27, 2021
@awgreene awgreene force-pushed the fix-operator-condition-lib branch from 180e696 to 3ae2713 Compare May 27, 2021 14:14
@varshaprasad96
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2021
@estroz
Copy link
Member

estroz commented May 27, 2021

Reposting from operator-framework/api#119 for visibility:

Out of curiosity: why v2 and not v2beta1 [or even v2alpha1]? Are we confident no significant changes will be needed soon? I feel that it’s a bit hasty to just throw a new stable version out, especially given how short the lifetime of v1 was.

@dinhxuanvu
Copy link
Member

Reposting from operator-framework/api#119 for visibility:

Out of curiosity: why v2 and not v2beta1 [or even v2alpha1]? Are we confident no significant changes will be needed soon? I feel that it’s a bit hasty to just throw a new stable version out, especially given how short the lifetime of v1 was.

I don't think we will have another significant changes anytime soon. Any other changes are probably on OLM side, not on the CRD side but I'm fine with keeping it v2beta1 if we all agree on that. cc @awgreene

@estroz
Copy link
Member

estroz commented May 27, 2021

Resolved in operator-framework/api#119 (comment). v2 it is.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 19, 2021
The v2 OperatorCondition CRD was introduced to the operator-framework/api
repository. This change updates the condition library to consume the new
changes.
@awgreene awgreene force-pushed the fix-operator-condition-lib branch from 3ae2713 to cc9d1af Compare July 6, 2021 14:36
@openshift-ci openshift-ci bot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 6, 2021
@awgreene
Copy link
Member Author

awgreene commented Jul 6, 2021

@varshaprasad96 can we get eyes on this pr?

@@ -84,7 +84,7 @@ func (c *condition) Get(ctx context.Context) (*metav1.Condition, error) {

// Set implements conditions.Set
func (c *condition) Set(ctx context.Context, status metav1.ConditionStatus, option ...Option) error {
operatorCond := &apiv1.OperatorCondition{}
operatorCond := &apiv2.OperatorCondition{}
err := c.client.Get(ctx, c.namespacedName, operatorCond)
if err != nil {
return ErrNoOperatorCondition
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider returning the original error, or at least wrap it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I support this change, but recommend doing so in a separate commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

See #65

@@ -69,12 +69,12 @@ func NewCondition(cl client.Client, condType apiv1.ConditionType) (Condition, er

// Get implements conditions.Get
func (c *condition) Get(ctx context.Context) (*metav1.Condition, error) {
operatorCond := &apiv1.OperatorCondition{}
operatorCond := &apiv2.OperatorCondition{}
err := c.client.Get(ctx, c.namespacedName, operatorCond)
if err != nil {
return nil, ErrNoOperatorCondition
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider returning the original error, or at least wrap it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I support this change, but recommend doing so in a separate commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

See #65

Copy link
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

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

/lgtm
Thanks @awgreene !

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 6, 2021
@varshaprasad96
Copy link
Member

/approve

@openshift-ci
Copy link

openshift-ci bot commented Jul 6, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: varshaprasad96

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 6, 2021
@openshift-merge-robot openshift-merge-robot merged commit 5eea60d into operator-framework:main Jul 6, 2021
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants