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

Use log_with_downgradable_level for user password configuration warnings #5927

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

ani-sinha
Copy link
Contributor

@ani-sinha ani-sinha commented Dec 12, 2024

Proposed Commit Message

Introduction of new WARNING level logs could be problematic for stable
downstream distros. Customers using these distros would then see a new and
unexpected behavior change or a new WARNING log that can confuse them. So for
handling user account passwords, use log_with_downgradable_level() helper api
instead so that downstream distros can maintain stability while also making
progressive changes in upstream towards improved user experience.
Downstream distros can convert these logs to DEBUG level by setting
DEPRECATION_INFO_BOUNDARY to a value older than the cloud-init version at which
these logs were first introduced (24.3). Please see the documentation for
log_with_downgradable_level().

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@ani-sinha ani-sinha force-pushed the warn-to-info branch 2 times, most recently from 6318fc9 to 8cc3a60 Compare December 12, 2024 10:23
@ani-sinha
Copy link
Contributor Author

@TheRealFalcon what do you think?

@TheRealFalcon
Copy link
Member

TheRealFalcon commented Dec 19, 2024

@ani-sinha

Warning logs tends to alert customers that something is broken

Hmmm, I would say that errors are for alerting that something is broken. In the cases pointed out in this PR, cloud-init was asked to do something that it was not able to. I think that is something worthy of a warning, especially surrounding user passwords. Otherwise the only way somebody would be alerted to this condition is if they go digging through the logs which won't happen unless somebody notices a problem and correctly identifies cloud-init as the cause.

That said, in the case of passwd, I can see the case for downgrading that to INFO, both in that we specifically document that passwd doesn't apply to existing users and to use hashed_passwd instead for that use case, along with the fact that a new instance id or calling of cloud-init clean can wind up triggering this warning without the user having done anything to cause this warning. For the other two though, it seems they can only be triggered if this user is asking for something that doesn't make sense.

May I ask where this request is coming from? Is there a customer on a stable platform that started seeing a return code of 2 after our new warning mechanism was backported? If so, do you think it makes mores sense for the lock_passwd cases to be downstream changes rather than upstream?

@ani-sinha
Copy link
Contributor Author

May I ask where this request is coming from? Is there a customer on a stable platform that started seeing a return code of 2 after our new warning mechanism was backported?

The request is not yet from a customer but we suspect that once we start rolling this out to the hands of our customers, they will complain and get confused. This has happened before with other logs and the schema validator.

@ani-sinha
Copy link
Contributor Author

If so, do you think it makes mores sense for the lock_passwd cases to be downstream changes rather than upstream?

If upstream is not willing to change this, we are debating whether to have a downstream only patch or to simply document it and point customers to it if they ask.

@zhaohuijuan
Copy link

May I ask where this request is coming from? Is there a customer on a stable platform that started seeing a return code of 2 after our new warning mechanism was backported?

The request is not yet from a customer but we suspect that once we start rolling this out to the hands of our customers, they will complain and get confused. This has happened before with other logs and the schema validator.

Yes, agree with here.
And I think this scenario is a common case(lock_passwd: false, but without password configuration), it means customer would hit it easily, suggest to change the WARNING log to a more friendly info to avoid any customer case or confusion.

@holmanb
Copy link
Member

holmanb commented Jan 6, 2025

they will complain

That could happen, however the commit that introduced these warnings was released in 24.3 - at the end of August. Nobody has complained about it yet on Ubuntu which has been running this code (backported to old series of Ubuntu) for months.

This has happened before with other logs and the schema validator.

Spurious warnings messages that cropped up for a few reasons: cloud-init automatically accepted multiple key types in some cases that were missed, and in other cases it was just an auditing error when generating the schema. It is unfortunate that this happened, however I think that the bulk of the issues have been resolved - and the rate of new warnings being added has slowed significantly.

In the cases pointed out in this PR, cloud-init was asked to do something that it was not able to. I think that is something worthy of a warning, especially surrounding user passwords. Otherwise the only way somebody would be alerted to this condition is if they go digging through the logs which won't happen unless somebody notices a problem and correctly identifies cloud-init as the cause.
For the other two though, it seems they can only be triggered if this user is asking for something that doesn't make sense.

In the case of a configuration that cloud-init cannot successfully fulfill, I strongly believe that emitting a warning to aid user debugging is better for end users than silently failing. In the cases where cloud-init was asked to do something that it is unable to do, choosing to not log a warning seems to prioritize downstream stability over what I think is best for future users. This isn't a tradeoff that I want to accept in upstream cloud-init.

@holmanb
Copy link
Member

holmanb commented Jan 6, 2025

There is a compromise that should satisfy downstream stability desires while enabling upstream to make forward progress to improve user experience. This helper function allows logging a warning or error message with an annotated cloud-init version at the callsite. When the cloud-init version set at the callsite is newer than the version set in features.DEPRECATION_INFO_BOUNDARY, the log level is downgraded to DEBUG. Therefore, by adding a simple patch (example) to a downstream release, upstream cloud-init can add warnings to enable users on later series to enjoy a better debugging experience without introducing changes of behavior to old releases of downstreams that prefer stability. An example of using this helper exists in main.py.

Perhaps these warning log sites could be converted to use this helper?

@ani-sinha
Copy link
Contributor Author

Perhaps these warning log sites could be converted to use this helper?

yes I think for c9s, we can use this simple downstream patch to not cause a disruption/behavior change for our customers. Let me see if I can send some patch.

@ani-sinha ani-sinha changed the title Change some log messages from warning to info Use log_with_downgradable_level for distro warnings Jan 7, 2025
@ani-sinha ani-sinha changed the title Use log_with_downgradable_level for distro warnings Use log_with_downgradable_level for user password configuration warnings Jan 7, 2025
Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

Thanks for the update @ani-sinha . This approach will work.

The changes look good, but 168f821 was recently merged that refactored the args argument to be a tuple. Would you be able to update the args in these calls to be tuples instead?

Introduction of new WARNING level logs could be problematic for stable
downstream distros. Customers using these distros would then see a new and
unexpected behavior change or a new WARNING log that can confuse them. So for
handling user account passwords, use log_with_downgradable_level() helper api
instead so that downstream distros can maintain stability while also making
progressive changes in upstream towards improved user experience.
Downstream distros can convert these logs to DEBUG level by setting
DEPRECATION_INFO_BOUNDARY to a value older than the cloud-init version at which
these logs were first introduced (24.3). Please see the documentation for
log_with_downgradable_level().

Signed-off-by: Ani Sinha <anisinha@redhat.com>
@ani-sinha
Copy link
Contributor Author

Thanks for the update @ani-sinha . This approach will work.

The changes look good, but 168f821 was recently merged that refactored the args argument to be a tuple. Would you be able to update the args in these calls to be tuples instead?

Done.

Copy link
Member

@TheRealFalcon TheRealFalcon 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!

@TheRealFalcon TheRealFalcon merged commit 38acce4 into canonical:main Jan 10, 2025
22 checks passed
TheRealFalcon pushed a commit that referenced this pull request Jan 13, 2025
Introduction of new WARNING level logs could be problematic for stable
downstream distros. Customers using these distros would then see a new and
unexpected behavior change or a new WARNING log that can confuse them. So for
handling user account passwords, use log_with_downgradable_level() helper api
instead so that downstream distros can maintain stability while also making
progressive changes in upstream towards improved user experience.
Downstream distros can convert these logs to DEBUG level by setting
DEPRECATION_INFO_BOUNDARY to a value older than the cloud-init version at which
these logs were first introduced (24.3). Please see the documentation for
log_with_downgradable_level().

Signed-off-by: Ani Sinha <anisinha@redhat.com>
holmanb pushed a commit to holmanb/cloud-init that referenced this pull request Feb 11, 2025
…#5927)

Introduction of new WARNING level logs could be problematic for stable
downstream distros. Customers using these distros would then see a new and
unexpected behavior change or a new WARNING log that can confuse them. So for
handling user account passwords, use log_with_downgradable_level() helper api
instead so that downstream distros can maintain stability while also making
progressive changes in upstream towards improved user experience.
Downstream distros can convert these logs to DEBUG level by setting
DEPRECATION_INFO_BOUNDARY to a value older than the cloud-init version at which
these logs were first introduced (24.3). Please see the documentation for
log_with_downgradable_level().

Signed-off-by: Ani Sinha <anisinha@redhat.com>
holmanb pushed a commit to holmanb/cloud-init that referenced this pull request Feb 11, 2025
…#5927)

Introduction of new WARNING level logs could be problematic for stable
downstream distros. Customers using these distros would then see a new and
unexpected behavior change or a new WARNING log that can confuse them. So for
handling user account passwords, use log_with_downgradable_level() helper api
instead so that downstream distros can maintain stability while also making
progressive changes in upstream towards improved user experience.
Downstream distros can convert these logs to DEBUG level by setting
DEPRECATION_INFO_BOUNDARY to a value older than the cloud-init version at which
these logs were first introduced (24.3). Please see the documentation for
log_with_downgradable_level().

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants