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

Fix snapd growpart and final message warnings #5215

Conversation

blackboxsw
Copy link
Collaborator

rebase merge use individual commits

Proposed Commit Message(s)

  • fix(final_message): do not warn on datasourcenone when single ds

    Avoid warning level log "Used fallback datasource" when base
    configuration defines datasource_list: [ None ].

    Using DataSourceNone in this case is desired behavior.

    Also drop unused is_disconnected property from DataSource
    which was only used by DataSourceNone in cc_final_message.

    Instead compare based on dsname property.

    Fixes: Remove DataSourceNone warning in cc_final_message  #5192

  • fix(growpart): correct growpart log message to include value of mode

Additional Context

Affects snapd UC24 which sets `datasource_list: [ None ]' in some configs

Test Steps

Checklist

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>)

@blackboxsw blackboxsw force-pushed the fix-snapd-growpart-and-final-message-warnings branch from a71721c to 5dc4b0b Compare April 25, 2024 19:17
@blackboxsw
Copy link
Collaborator Author

cc: @Meulengracht for snap-related concerns.

@Meulengracht
Copy link
Member

Thank you to everyone involved here for getting this ball rolling and fixed so quickly!

@blackboxsw blackboxsw force-pushed the fix-snapd-growpart-and-final-message-warnings branch 3 times, most recently from 52e64e9 to 6d5f33b Compare April 25, 2024 21:25
@blackboxsw blackboxsw added the documentation This Pull Request changes documentation label Apr 26, 2024
@holmanb holmanb self-assigned this Apr 30, 2024
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Hey @blackboxsw, thanks for this PR. I just added some wording nits to hopefully make our docs a bit clearer.

log_func = LOG.debug
else:
log_func = LOG.warning
log_func("Used fallback datasource")
Copy link
Member

Choose a reason for hiding this comment

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

Plenty of other logs in the log file by this point would have indicated that the user is using DatasourceNone, so I don't see what this adds as a debug message. Maybe just log a warning if this is not the expected behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good pt. droppng debug version of msg.

Copy link
Member

Choose a reason for hiding this comment

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

@blackboxsw I'm guessing this was forgotten?

doc/rtd/explanation/configuration.rst Show resolved Hide resolved
@@ -23,6 +23,11 @@ From lowest priority to highest, configuration sources are:

These four sources make up the base configuration.

.. note::
The base configuration files must be valid `YAML 1.1`_ syntax and they can
be declared as :ref:`jinja templates <instancedata-Using>`.
Copy link
Member

Choose a reason for hiding this comment

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

The base configuration files must be valid YAML 1.1_ syntax and they can be declared as :ref:jinja templates <instancedata-Using>.

A jinja template that contains a base configuration is not necessarily valid yaml, so how can this be true? This seems self-contradictory.

We work around this with ## template: jinja template headers, but this means that a base configuration file must be either YAML 1.1 or a jinja template using instance-data which, when rendered, produces a YAML 1.1 file.

Additionally, I don't think that the phrase "valid YAML 1.1 syntax" really accomplishes what I think you're trying to say. YAML 1.2 can be valid 1.1, but the point we're trying to make is that cloud-init uses the YAML 1.1 interpretation of the configuration.

Maybe something like this will help clarify this statement a bit?

  The base configuration format uses `YAML version 1.1`_, but may be defined as jinja
  templates which cloud-init will render at runtime with
  :ref:`instance-data<instancedata-Using>` variables. 

What do you think about making this content part of the first paragraph on this page?

doc/rtd/explanation/configuration.rst Outdated Show resolved Hide resolved
@@ -24,7 +24,7 @@ These things include:
- *and many more...*

.. note::
This file must be valid YAML syntax.
This file must be valid `YAML 1.1`_ syntax.
Copy link
Member

Choose a reason for hiding this comment

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

I know you didn't write this line, but while we're touching this line can we please update it to something that makes a little more sense?

The file isn't a syntax. YAML isn't a syntax either. YAML is a standardized language for defining data objects, and it has a syntax for describing these data objects as a stream of characters. Cloud-config is a format which uses the YAML syntax described in specification version 1.1 and a set of keys defined in the jsonschema.

This file ...

Additionally, this configuration is often times not even a file. Users may copy-paste a cloud-config into a web interface, for example, and ultimately on the instance they usually do not write a configuration file, so the mention of it being a file may be misleading to some.

Perhaps this paragraph:

Cloud-config is the simplest way to accomplish some things via user data.
Using cloud-config syntax, the user can specify certain things in a
human-friendly format.

Could be updated to say something like:

Cloud-config is the preferred user data format. The cloud config format is a
declarative syntax which uses YAML version 1.1 with keys that describe instance
state. Cloud-config can be used to define how an instance should be configured in
a human-friendly format.

And then remove the This file must be ... note?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like your updated suggestions. I've pulled the majority into the first paragraph of Cloud-config section as well as rewriting a couple of the apt-specific examples to more package format packaging format agnostic terms. CC @s-makin for doc review as well.

doc/rtd/explanation/format.rst Outdated Show resolved Hide resolved
doc/rtd/explanation/instancedata.rst Outdated Show resolved Hide resolved
@blackboxsw blackboxsw requested a review from s-makin May 2, 2024 22:47
@github-actions github-actions bot removed the documentation This Pull Request changes documentation label May 2, 2024
Copy link
Contributor

@s-makin s-makin left a comment

Choose a reason for hiding this comment

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

I don't have much to add beyond a couple of nits

@@ -79,3 +83,4 @@ images.

.. _Config: https://github.com/canonical/cloud-init/blob/b861ea8a5e1fd0eb33096f60f54eeff42d80d3bd/cloudinit/settings.py#L22
.. _cloud.cfg template: https://github.com/canonical/cloud-init/blob/main/config/cloud.cfg.tmpl
.. _YAML 1.1: https://yaml.org/spec/1.1/current.html
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.. _YAML 1.1: https://yaml.org/spec/1.1/current.html
.. _YAML version 1.1: https://yaml.org/spec/1.1/current.html

Copy link
Contributor

Choose a reason for hiding this comment

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

The mismatch is (I think) what's throwing the spellcheck error. Even though this isn't an error in the spelling.

doc/rtd/explanation/format.rst Outdated Show resolved Hide resolved
@blackboxsw blackboxsw force-pushed the fix-snapd-growpart-and-final-message-warnings branch from 7994c54 to 9fcbb9d Compare May 7, 2024 14:03
@blackboxsw blackboxsw requested a review from holmanb May 7, 2024 14:04
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

I've pulled the majority into the first paragraph of Cloud-config section as well as rewriting a couple of the apt-specific examples to more package format packaging format agnostic terms.

Great idea. This is looking much better! I left a couple more questions and suggestions inline.

doc/rtd/explanation/configuration.rst Outdated Show resolved Hide resolved
doc/rtd/explanation/format.rst Outdated Show resolved Hide resolved
doc/rtd/explanation/format.rst Outdated Show resolved Hide resolved
Copy link

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label May 23, 2024
@github-actions github-actions bot closed this May 30, 2024
@holmanb holmanb reopened this May 30, 2024
@holmanb holmanb removed the stale-pr Pull request is stale; will be auto-closed soon label May 30, 2024
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

I have no more updates to make, I'm just setting this to "request changes" to make it more obvious that this is waiting on @blackboxsw right now.

@holmanb
Copy link
Member

holmanb commented May 31, 2024

I have no more updates to make, I'm just setting this to "request changes" to make it more obvious that this is waiting on @blackboxsw right now.

@blackboxsw since this will make DataSourceNone users no longer have a warning message we might want to squeeze this one into 24.2. I'm adding it to the milestone so that it doesn't slip by without a discussion (we can remove it if we decide it's not a priority).

@holmanb holmanb added this to the cloud-init-24.2 milestone May 31, 2024
Copy link
Collaborator Author

@blackboxsw blackboxsw 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 more specific text suggestions @holmanb . I've added them all.

@blackboxsw blackboxsw requested a review from holmanb June 3, 2024 16:03
- additional ``apt`` sources should be added
- certain SSH keys should be imported
- performing package upgrades on first boot
- configuration of different package mirrors or sources
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@holmanb here's the only unreviewed diff

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Thanks @blackboxsw! Let's land it.

Update growpart schema messaging clarify having to quote the
value of growpart: {mode: 'off'}
Avoid warning level log "Used fallback datasource" when base
configuration defines `datasource_list: [ None ]`.

Using DataSourceNone in this case is desired behavior.

Also drop unused is_disconnected property from DataSource
which was only used by DataSourceNone in cc_final_message.

Instead compare based on dsname property.

Fixes: canonicalGH-5192
@blackboxsw blackboxsw force-pushed the fix-snapd-growpart-and-final-message-warnings branch from 4767da3 to e2c6fc9 Compare June 5, 2024 11:38
@blackboxsw blackboxsw merged commit fbec4d0 into canonical:main Jun 5, 2024
23 checks passed
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.

Remove DataSourceNone warning in cc_final_message
4 participants