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

Log a warning if the channel doesn't match the default #1178

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

skitt
Copy link
Member

@skitt skitt commented Oct 23, 2023

Users can configure a non-default channel, but support needs to know about this, so log it.

@skitt
Copy link
Member Author

skitt commented Oct 23, 2023

@tpantelis is there a fake logger we could use to test this?

@@ -214,6 +214,10 @@ func applySubmarinerConfig(brokerInfo *SubmarinerBrokerInfo, submarinerConfig *c
setIfValueNotDefault(&brokerInfo.CatalogStartingCSV, submarinerConfig.Spec.SubscriptionConfig.StartingCSV)
setIfValueNotDefault(&brokerInfo.InstallPlanApproval, submarinerConfig.Spec.SubscriptionConfig.InstallPlanApproval)

if brokerInfo.CatalogChannel != defaultCatalogChannel {
logger.Warningf("Tracking non-default catalog channel %q (default is %q)", brokerInfo.CatalogChannel, defaultCatalogChannel)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this a warning? Is this something a user isn't supposed to do?

Copy link
Member Author

Choose a reason for hiding this comment

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

In most cases they shouldn’t, and in all cases support needs to know about it. It could be an info-level message but then it wouldn’t necessarily be logged...

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you use logger.V(...).Infof it may not be but if you use logger.Infof, it should always be logged.

@tpantelis
Copy link
Collaborator

@tpantelis is there a fake logger we could use to test this?

Not that I know of. But I don't think we should verify specific log messages in unit tests. If the visibility of this message is significant enough, perhaps you should use the event Recorder instead. There is an InMemoryRecorder in the openshift library that is intended for unit tests where you can query the events and verify.

@skitt skitt force-pushed the warn-on-non-default-channel branch from 9d36a38 to 9d46eaa Compare October 23, 2023 13:53
@skitt
Copy link
Member Author

skitt commented Oct 23, 2023

I just wanted to verify that we’re logging something if the channel is configured to a value other than the default. I don’t think this warrants recording an actual event.

@@ -214,6 +214,10 @@ func applySubmarinerConfig(brokerInfo *SubmarinerBrokerInfo, submarinerConfig *c
setIfValueNotDefault(&brokerInfo.CatalogStartingCSV, submarinerConfig.Spec.SubscriptionConfig.StartingCSV)
setIfValueNotDefault(&brokerInfo.InstallPlanApproval, submarinerConfig.Spec.SubscriptionConfig.InstallPlanApproval)

if brokerInfo.CatalogChannel != defaultCatalogChannel {
logger.Infof("Tracking non-default catalog channel %q (default is %q)", brokerInfo.CatalogChannel, defaultCatalogChannel)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will get logged on every reconcile loop which might get excessive.

Why can't we have support inspect the SubmarinerConfig resource or the Subscription to see if the channel is custom rather than via a log message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah I was just checking how often the loop runs...

When we discussed this a while back we decided to log a message for two reasons:

  • end-users might notice it if things go wrong, and figure out they need to fix something on their own (assuming they remember they set up a specific channel)
  • the log message can provide all the information support needs — both the configured value, and the expected default

I’ll memoize the channel value and only log it the first time it changes.

Users can configure a non-default channel, but support needs to know
about this, so log it.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
@skitt skitt force-pushed the warn-on-non-default-channel branch from 9d46eaa to df494bc Compare October 25, 2023 14:46
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tpantelis

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

@sonarcloud
Copy link

sonarcloud bot commented Oct 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@openshift-ci openshift-ci bot merged commit 951fd43 into stolostron:main Oct 25, 2023
13 checks passed
@skitt skitt deleted the warn-on-non-default-channel branch October 26, 2023 07:58
@skitt
Copy link
Member Author

skitt commented Oct 26, 2023

/cherrypick release-2.8

@openshift-cherrypick-robot

@skitt: new pull request created: #1180

In response to this:

/cherrypick release-2.8

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.

@skitt
Copy link
Member Author

skitt commented Oct 26, 2023

/cherrypick release-2.7

@openshift-cherrypick-robot

@skitt: new pull request created: #1181

In response to this:

/cherrypick release-2.7

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.

@skitt
Copy link
Member Author

skitt commented Oct 26, 2023

/cherrypick release-2.6

@openshift-cherrypick-robot

@skitt: new pull request created: #1182

In response to this:

/cherrypick release-2.6

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants