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 status once installation CR is written #668

Merged
merged 3 commits into from Jul 10, 2020
Merged

Conversation

lmm
Copy link
Contributor

@lmm lmm commented Jun 29, 2020

Description

This PR writes an empty status block after we've written the installation CR to the datastore. We want this change because an operator scorecard test checks for the existence of the status in the CR after applying the CR manifest. The operator scorecard tests are run when we submit an operator metadata bundle to certify a new version of our operator.

We'll want to backport this to 1.6, 1.7 and 1.8 to cover Calico v3.14 and v3.15.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

// A status is needed at this point for operator scorecard tests.
// status.variant is written later but for some tests the reconciliation
// does not get to that point.
instance.Status = operator.InstallationStatus{}
Copy link
Member

Choose a reason for hiding this comment

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

This will overwrite any previously written status. Is that what we want here? Or should we be maintaining any status that the controller had previously written?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that wasn't right. I've updated the commit so that we only do the pre-write of the installation status if there was no status at the start of the reconcile.

// status.variant is written later but for some tests the reconciliation
// does not get to that point.
instance.Status = operator.InstallationStatus{}
if err = r.client.Status().Update(ctx, instance); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense during the first run. But on subsequent runthroughs of the reconcilliation loop, won't this nuke existing statuses? Or is that not a problem because we mainly write status to the tigerastatus CR instead of the installation CR?

FWIW, I ran into this same gap while working on a different feature and this is what I came up with: ozdanborne@df37bb4 . Though my code is different in that I'm trying to initialize the tigerastatus, not the installation.status

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I had was wrong. But thanks for sharing that diff... I've written my fixed commit so that it might merge with your future changes a bit more easily.

Copy link
Member

@tmjd tmjd left a comment

Choose a reason for hiding this comment

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

For the most part this looks reasonable. But higher level I'm wondering if there is a 'real' status we should be adding at this point. It just feels like we're adding this to check a box and not providing any real information.

  • What status information does the operator scorecard expect to be present?
  • A 'real' status that we could include here is a 'Valid' field indicating that the resource has been parsed and looks to be valid.
  • Maybe since we intend our main status reporting to be through the tigerastatus resource we should include a reference in the Installation.Status that points to the tigerastatus? (just throwing out ideas)

test/mainline_test.go Show resolved Hide resolved
test/mainline_test.go Show resolved Hide resolved
@lmm
Copy link
Contributor Author

lmm commented Jul 6, 2020

Thanks for looking @tmjd

What status information does the operator scorecard expect to be present?

The test checks whether the Installation CR has a status block present. It's checkstatustest in this list: https://sdk.operatorframework.io/docs/scorecard/scorecard/#basic-operator

A 'real' status that we could include here is a 'Valid' field indicating that the resource has been parsed and looks to be valid.

That's a reasonable idea, maybe we can revisit that later, wdyt?

Maybe since we intend our main status reporting to be through the tigerastatus resource we should include a reference in the Installation.Status that points to the tigerastatus? (just throwing out ideas)

👍 I think there's something to explore there for sure. But for the sake of satisfying the scorecard test maybe we can just add in the empty status block for now since it's an easier change to approve since we're not changing the API.

Copy link
Member

@tmjd tmjd left a comment

Choose a reason for hiding this comment

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

LGTM

@tmjd tmjd merged commit 1dd77fd into tigera:master Jul 10, 2020
@lmm lmm deleted the lmm-status branch July 10, 2020 21:50
lmm pushed a commit to lmm/operator that referenced this pull request Jul 10, 2020
Update status once installation CR is written
lmm pushed a commit to lmm/operator that referenced this pull request Jul 10, 2020
Update status once installation CR is written
lmm pushed a commit to lmm/operator that referenced this pull request Jul 10, 2020
Update status once installation CR is written
lmm pushed a commit to lmm/operator that referenced this pull request Jul 10, 2020
Update status once installation CR is written
lmm pushed a commit to lmm/operator that referenced this pull request Jul 13, 2020
Update status once installation CR is written
tmjd added a commit that referenced this pull request Jul 13, 2020
release-v1.5 - Cherry-pick status and RBAC changes #668 and #691
tmjd added a commit that referenced this pull request Jul 13, 2020
release-v1.6 - Cherry-pick status and RBAC changes #668 and #691
tmjd added a commit that referenced this pull request Jul 13, 2020
release-v1.7 - Cherry-pick status and RBAC changes #668 and #691
tmjd added a commit that referenced this pull request Jul 13, 2020
release-v1.8 - Cherry-pick status and RBAC changes #668 and #691
@tmjd tmjd added this to the v1.9.0 milestone Jul 16, 2020
@tmjd tmjd added the kind/enhancement New feature or request label Jul 16, 2020
lmm pushed a commit to lmm/operator that referenced this pull request Jul 24, 2020
Update status once installation CR is written
lmm pushed a commit to lmm/operator that referenced this pull request Aug 7, 2020
Update status once installation CR is written
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants