Skip to content

Commit 2f6c6a2

Browse files
fix(backups): store the Altinity, Job and FoundationDB pod templates schemaless
backupstrategy-controller renders its strategy CRDs from templates, so Helm stores each of them twice in every release revision, and a revision is one Secret capped at 1 MiB. The Altinity, Job and FoundationDB CRDs each inline the full upstream PodTemplateSpec schema, about 600 KB apiece; once the default Strategy CRs render as well, the stored release no longer fits and the forced upgrade that creates them fails with "Secret ... is invalid: data: Too long". The Kafka, RabbitMQ and Redis strategies already carry their pod template schemaless for this reason. Give the three older fields the same markers. The Go types stay typed, the drivers decode the template as before, and the apiserver still validates the pod when the driver creates the workload; every description is kept, and the largest revision drops to about a quarter of the limit. The rationale moves to the package doc, so the six field docs only tell the reader what schemaless means for them. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent aed7fa8 commit 2f6c6a2

13 files changed

Lines changed: 64 additions & 26507 deletions

‎api/backups/strategy/v1alpha1/altinity_types.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ type AltinitySpec struct {
6666
// exposes .Name, .Namespace, and
6767
// .ApplicationRef.{APIGroup,Kind,Name} so to-copy
6868
// restores can address the source release.
69+
//
70+
// Stored schemaless: the apiserver keeps it as written rather than
71+
// checking it against the pod schema, and it is validated when the
72+
// driver creates the workload from it.
73+
//
74+
// +kubebuilder:validation:Schemaless
75+
// +kubebuilder:pruning:PreserveUnknownFields
6976
Template corev1.PodTemplateSpec `json:"template"`
7077
}
7178

‎api/backups/strategy/v1alpha1/foundationdb_types.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ type FoundationDBTemplate struct {
108108
// Admins use it to mount credentials, CA bundles, or any other
109109
// per-tenant secrets the backup_agent needs. Templating is supported
110110
// on every string field.
111+
//
112+
// Stored schemaless: the apiserver keeps it as written rather than
113+
// checking it against the pod schema, and it is validated when the
114+
// driver creates the workload from it.
115+
//
111116
// +optional
117+
// +kubebuilder:validation:Schemaless
118+
// +kubebuilder:pruning:PreserveUnknownFields
112119
BackupDeploymentPodTemplateSpec *corev1.PodTemplateSpec `json:"backupDeploymentPodTemplateSpec,omitempty"`
113120
}
114121

‎api/backups/strategy/v1alpha1/groupversion_info.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ limitations under the License.
1515
*/
1616

1717
// Package v1alpha1 contains API Schema definitions for the v1alpha1 API group.
18+
//
19+
// Fields that embed a large upstream struct, a PodTemplateSpec above all, are
20+
// marked Schemaless with PreserveUnknownFields. backupstrategy-controller
21+
// renders these CRDs from templates, so Helm stores each one twice in every
22+
// release revision, and a revision is one Secret capped at 1 MiB; with the
23+
// upstream schemas inlined the revision that renders the default strategies
24+
// no longer fits and that upgrade fails. The Go types stay typed, and the
25+
// apiserver validates the content when a driver creates the workload from it.
26+
// hack/strategy-crd-schemaless.bats fails on a strategy CRD that inlines a
27+
// pod template schema.
28+
//
1829
// +kubebuilder:object:generate=true
1930
// +groupName=strategy.backups.cozystack.io
2031
package v1alpha1

‎api/backups/strategy/v1alpha1/job_types.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ type JobSpec struct {
6161
// - `.Parameters` — the resolved BackupClass strategy parameters.
6262
// - `.Backup` — only on restore runs: `.Backup.Name`, `.Backup.Namespace`
6363
// and `.Backup.ApplicationRef` describing the source backup.
64+
//
65+
// Stored schemaless: the apiserver keeps it as written rather than
66+
// checking it against the pod schema, and it is validated when the
67+
// driver creates the workload from it.
68+
//
69+
// +kubebuilder:validation:Schemaless
70+
// +kubebuilder:pruning:PreserveUnknownFields
6471
Template corev1.PodTemplateSpec `json:"template"`
6572
}
6673

‎api/backups/strategy/v1alpha1/kafka_types.go‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ type KafkaSpec struct {
7171
// - `.Backup` — only on restore: `.Backup.Name`, `.Backup.Namespace` and
7272
// `.Backup.ApplicationRef` describing the source backup.
7373
//
74-
// Stored schemaless deliberately: the full PodTemplateSpec OpenAPI schema is
75-
// ~590 KB, and inlining it here (after Altinity/Job/FoundationDB) would push
76-
// the chart's Helm state Secret over the 1 MiB cap. See job_types.go for the
77-
// same field carried with its schema, and strategy-kafka-default.yaml for
78-
// the rendered pod.
74+
// Stored schemaless: the apiserver keeps it as written rather than
75+
// checking it against the pod schema, and it is validated when the
76+
// driver creates the workload from it. See
77+
// strategy-kafka-default.yaml for the rendered pod.
7978
//
8079
// +kubebuilder:validation:Schemaless
8180
// +kubebuilder:pruning:PreserveUnknownFields

‎api/backups/strategy/v1alpha1/rabbitmq_types.go‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,9 @@ type RabbitmqSpec struct {
8383
// .ApplicationRef.{APIGroup,Kind,Name} so a to-copy
8484
// restore can address the source release's object key.
8585
//
86-
// The template is stored schemaless (its content is preserved but not
87-
// validated by the apiserver): the driver renders and validates the pod
88-
// spec, and generating the full PodTemplateSpec OpenAPI schema here would
89-
// add ~590 KB to this CRD. The backupstrategy-controller chart inlines
90-
// every definitions/*.yaml into one Helm release, whose state Secret is
91-
// capped at 1 MiB - a fourth full PodTemplateSpec schema (after Altinity,
92-
// Job and FoundationDB) pushes that Secret over the cap and fails install.
86+
// Stored schemaless: the apiserver keeps it as written rather than
87+
// checking it against the pod schema, and it is validated when the
88+
// driver creates the workload from it.
9389
//
9490
// +kubebuilder:validation:Schemaless
9591
// +kubebuilder:pruning:PreserveUnknownFields

‎api/backups/strategy/v1alpha1/redis_types.go‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,9 @@ type RedisSpec struct {
7676
// and `.Backup.ApplicationRef` describing the source backup, so a
7777
// to-copy restore reads the SOURCE release's object-storage prefix.
7878
//
79-
// Stored schemaless (content preserved, not validated by the apiserver): the
80-
// driver renders and validates the pod spec, and generating the full
81-
// PodTemplateSpec OpenAPI schema here would add ~590 KB to this CRD. The
82-
// backupstrategy-controller chart inlines every definitions/*.yaml into one
83-
// Helm release whose state Secret is capped at 1 MiB, so a full
84-
// PodTemplateSpec schema here (a fifth after Altinity, Job, FoundationDB and
85-
// Redis's own siblings) pushes that Secret over the cap and fails install.
86-
// Same reason as rabbitmq_types.go.
79+
// Stored schemaless: the apiserver keeps it as written rather than
80+
// checking it against the pod schema, and it is validated when the
81+
// driver creates the workload from it.
8782
//
8883
// +kubebuilder:validation:Schemaless
8984
// +kubebuilder:pruning:PreserveUnknownFields

0 commit comments

Comments
 (0)