close
Skip to content

docs: clarify handling of postgres relation data in K8s tutorial#2256

Merged
dwilding merged 9 commits intocanonical:mainfrom
dwilding:k8s-tutorial-status-comment
Jan 14, 2026
Merged

docs: clarify handling of postgres relation data in K8s tutorial#2256
dwilding merged 9 commits intocanonical:mainfrom
dwilding:k8s-tutorial-status-comment

Conversation

@dwilding
Copy link
Copy Markdown
Contributor

@dwilding dwilding commented Dec 26, 2025

In Integrate your charm with PostgreSQL, the part from "Add relation event observers" to the end of "Share the authentication information with your application" needs improving:

  • I find the sequence of file edits confusing. I don't know what the goal is until I get to the end and work backwards.
  • A couple of the method explanations and docstrings are much wordier than they need to be.
  • A couple of places still talk about setting status without collect-status: The diagram at the end and the part mentioned in #2095.

I've reorganised the flow and improved the explanations of what's happening. That includes replacing the diagram by more focused text.

Previews of updated sections:

Other updates to the tutorial:

  • Renamed self._update_layer_and_restart() to self._replan_workload() - see comment
  • Renamed self._on_database_created() to self._on_database_endpoint() - see comment
  • Renamed self.fetch_postgres_relation_data() to self.fetch_database_relation_data() and removed other places where PostgreSQL is mentioned, to be more generic - see comment
  • Simplified self.get_app_environment() - see comment

@dwilding dwilding linked an issue Dec 26, 2025 that may be closed by this pull request
@dwilding dwilding marked this pull request as ready for review December 26, 2025 08:18
Copilot AI review requested due to automatic review settings December 26, 2025 08:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the PostgreSQL integration tutorial by reorganizing the documentation flow and simplifying docstrings. The changes make it easier to understand how to handle database relation data by presenting steps in a more logical sequence and reducing verbose explanations.

Key changes:

  • Reorganized tutorial sections to present database authentication handling before Pebble layer updates
  • Simplified overly verbose docstrings in get_app_environment() and fetch_postgres_relation_data() methods
  • Replaced a diagram with clearer textual explanation of service behavior with/without database relations

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
docs/tutorial/from-zero-to-hero-write-your-first-kubernetes-charm/integrate-your-charm-with-postgresql.md Reorganized tutorial flow to introduce database authentication methods before Pebble layer updates; replaced diagram with text explanation
examples/k8s-3-postgresql/src/charm.py Simplified docstrings for get_app_environment() and fetch_postgres_relation_data() methods
examples/k8s-4-action/src/charm.py Simplified docstrings for get_app_environment() and fetch_postgres_relation_data() methods
examples/k8s-5-observe/src/charm.py Simplified docstrings for get_app_environment() and fetch_postgres_relation_data() methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@tonyandrewmeyer tonyandrewmeyer 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 doing this! I agree the flow makes more sense now, and the renames are good.

I agree the simple text is clearer than the diagram being removed. I wonder if (later, in a different PR) some sort of diagrammatic summary at the end of the tutorial might be useful for people - often the event flow is challenging to understand and I think that's where a diagram can best help.

@dwilding dwilding merged commit d9d6183 into canonical:main Jan 14, 2026
57 checks passed
@dwilding dwilding deleted the k8s-tutorial-status-comment branch January 14, 2026 03:18
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.

K8s tutorial: Clarify how status is set if no relation data

4 participants