Skip to content

Conversation

@pooknull
Copy link
Contributor

@pooknull pooknull commented Oct 22, 2025

K8SPS-567 Powered by Pull Request Badge

https://perconadev.atlassian.net/browse/K8SPS-567

DESCRIPTION

This PR introduces automatic generation of the example cr.yaml, backup.yaml, restore.yaml files.

How it works:

  1. A new binary cmd/example-gen generates a populated PerconaServerMySQL/PerconaServerMySQLBackup/PerconaServerMySQLRestore resources.
  2. The script cmd/example-gen/generate.sh:
    • sorts fields in a predefined order,
    • removes unnecessary fields,
    • comments out predefined values.

When a new field is added to PerconaServerMySQL/PerconaServerMySQLBackup/PerconaServerMySQLRestore, it will automatically appear in the example file after running make manifests.

By default, the field will:

  • appear at the end of its parent structure,
  • and contain a zero value (even if omitempty is used).

To adjust it:

  • Order: add the field to the sort_yaml function.
  • Default value: update example-gen/pkg/defaults/manual.go.
  • Shared defaults for multiple types: modify example-gen/pkg/defaults/preset.go.

Additional changes:

  1. VolumeSpec was moved from PodSpec to MySQLSpec as it is only used in the MySQL
  2. Removed StorageClass from BackupStorageS3Spec as it is not used

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PS version?
  • Does the change support oldest and newest supported Kubernetes version?

Copilot AI review requested due to automatic review settings October 22, 2025 12:37
@pull-request-size pull-request-size bot added the size/XXL 1000+ lines label Oct 22, 2025
Copy link
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 introduces automated generation of the example deploy/cr.yaml file for the PerconaServerMySQL operator. The solution consists of a Go binary (cmd/example-gen) that generates a populated resource and a bash script that formats, sorts, and comments the output. This automation ensures that new API fields automatically appear in the example configuration after running make manifests.

Key changes include:

  • New generation tooling with custom marshaling to ignore omitempty tags
  • Removal of deprecated StorageClass field from S3 backup specifications
  • Relocation of VolumeSpec from PodSpec to MySQLSpec to fix structural issues

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/example-gen/main.go Entry point for CR generation binary
cmd/example-gen/generate.sh Bash script to format, sort, and comment generated YAML
cmd/example-gen/defaults/*.go Default value configuration for manual and preset fields
cmd/example-gen/internal/marshal/marshal.go Custom JSON marshaler ignoring omitempty tags
cmd/example-gen/internal/fill/bytype.go Type-based field filling logic
api/v1/perconaservermysql_types.go API changes: VolumeSpec relocation and StorageClass removal
deploy/cr.yaml Regenerated example configuration
Multiple CRD files Updated schemas reflecting API changes
Test files Updated test fixtures for VolumeSpec relocation
Makefile Added generate-cr-yaml target to manifest generation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 22, 2025 12:40
Copy link
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

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

deploy/cr.yaml Outdated
# proxy: false
# proxySize: false
# pause: false
# pause: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

@pooknull, we need to have default values in commented options

Copilot AI review requested due to automatic review settings October 27, 2025 12:32
Copy link
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

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.


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

Copilot AI review requested due to automatic review settings October 27, 2025 14:47
Copy link
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

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


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

Copilot AI review requested due to automatic review settings October 28, 2025 09:14
Copy link
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

Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

cmd/example-gen/scripts/lib/util.sh:1

  • This complex awk script that transforms diff hunks lacks inline comments explaining its logic. Add comments describing: (1) what 'has_lt', 'has_gt', 'has_sep' track, (2) why delete hunks are converted to change hunks, and (3) how lines are prefixed with '> #' for commenting. This would significantly improve maintainability.
#!/usr/bin/env bash

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

Copilot AI review requested due to automatic review settings October 28, 2025 09:38
Copy link
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

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.


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

Copilot AI review requested due to automatic review settings October 28, 2025 09:49
Copy link
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

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.


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

@pooknull pooknull requested a review from hors October 28, 2025 09:57
@pooknull pooknull marked this pull request as ready for review October 28, 2025 09:57
@pooknull pooknull requested a review from egegunes as a code owner October 28, 2025 09:57
Copilot AI review requested due to automatic review settings October 28, 2025 09:57
@pooknull pooknull changed the title K8SPS-567: automatic cr.yaml generation K8SPS-567: automatic yaml generation Oct 28, 2025
Copy link
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

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.


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

@egegunes
Copy link
Contributor

I think this PR should also add a job to github actions to check if example cr.yaml is updated like we do for manifests.

@pooknull
Copy link
Contributor Author

This reverts commit ed6a0a0.
Copilot AI review requested due to automatic review settings October 28, 2025 12:04
Copy link
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

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL 1000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants