Skip to content

operator: implement roundtripping conversion of v1alpha3#892

Closed
chrisseto wants to merge 1 commit intomainfrom
chris/p/k8s-600-004-conversion
Closed

operator: implement roundtripping conversion of v1alpha3#892
chrisseto wants to merge 1 commit intomainfrom
chris/p/k8s-600-004-conversion

Conversation

@chrisseto
Copy link
Contributor

This commit adds the initial set of conversion routines to support roundtripping all valid configurations of the v1alpha3 CR through the v1alpha2 CR.

To aid in the development and testing of the conversion routines, the exhaustruct linter has been enabled on files ending in _conversion.go. It requires all fields to be explicitly declared which will prevent future additions to either CR from causing regressions.

It should be noted that v1alpha2 can NOT be roundtripped. Therefore the v1alpha3 CRD can not be safely enabled.

Future work will:

  • Improve user facing documentation of all fields
  • Support roundtripping v1alpha2 through v1alpha3
  • (Potentially) refactor conversion to make use of the conversion-gen tool.

@chrisseto chrisseto force-pushed the chris/p/k8s-600-004-conversion branch from 68351e9 to 3f2854a Compare June 9, 2025 18:58
@chrisseto chrisseto force-pushed the chris/p/k8s-600-004-conversion branch from 3f2854a to 7d306eb Compare June 10, 2025 14:25
@github-actions
Copy link

This PR is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Jun 16, 2025
@chrisseto chrisseto removed the stale label Jun 16, 2025
@chrisseto chrisseto force-pushed the chris/p/k8s-600-004-conversion branch from 7d306eb to b329522 Compare June 16, 2025 14:02
Copy link
Contributor

@RafalKorepta RafalKorepta left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +95 to +98
// TODO does rpk redpanda tune read from redpanda.yaml?
// Arguments to be passed to rpk redpanda tune
// https://docs.redpanda.com/current/reference/rpk/rpk-redpanda/rpk-redpanda-tune/
// Tuning []string `json:"tuning"`
Copy link
Contributor

Choose a reason for hiding this comment

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

@r-vasquez As far as I remember the rpk redpanda start command will not do anything with tuning configuration inside redpanda.yaml.

@chrisseto Those tuning option could take effect when the init container named tuning runs.
Reference:

func statefulSetInitContainerTuning(dot *helmette.Dot) *corev1.Container {
values := helmette.Unwrap[Values](dot.Values)
if !values.Tuning.TuneAIOEvents {
return nil
}
return &corev1.Container{
Name: "tuning",
Image: fmt.Sprintf("%s:%s", values.Image.Repository, Tag(dot)),
Command: []string{
`/bin/bash`,
`-c`,
`rpk redpanda tune all`,
},
SecurityContext: &corev1.SecurityContext{
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{`SYS_RESOURCE`},
},
Privileged: ptr.To(true),
RunAsUser: ptr.To(int64(0)),
RunAsGroup: ptr.To(int64(0)),
},
VolumeMounts: append(
CommonMounts(dot),
corev1.VolumeMount{
Name: "base-config",
MountPath: "/etc/redpanda",
},
),
}
}

return nil, false
}

// TODO Handle all cases here
Copy link
Contributor

Choose a reason for hiding this comment

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

Those Handle all cases here means follow up PR? Or when we discover problems during cloud migration? Or something completely different?

Memory: nil,
},

// TODO Audit this list.
Copy link
Contributor

Choose a reason for hiding this comment

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

By audit you mean handle them in next PR or leave them as nil?

Comment on lines +554 to +611
AdditionalRedpandaCmdFlags: nil,
AdditionalSelectorsLabels: nil,
Annotations: nil,
Budget: nil,
ExtraVolumeMounts: nil,
ExtraVolumes: nil,
InitContainerImage: nil,
LivenessProbe: nil,
NodeSelector: nil,
PodAffinity: nil,
PodAntiAffinity: nil,
PriorityClassName: nil,
ReadinessProbe: nil,
SecurityContext: nil,
SideCars: nil,
SkipChown: nil,
StartupProbe: nil,
TerminationGracePeriodSeconds: nil,
Tolerations: nil,
TopologySpreadConstraints: nil,
UpdateStrategy: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should those fields have similar TODO Audit this list..

Copy link
Contributor

@andrewstucki andrewstucki left a comment

Choose a reason for hiding this comment

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

I'm fine with this as a first pass since nothing is using it, but lots of questions before I hit approve. Also, WDYT about a rapid test that roundtrips v1alpha2 --> 3 --> 2 but with deprecated/unsupported fields ignored (as mentioned in the PR description, I'm fine doing this secondarily)? I'm assuming that was what the start of the commented test case is?

// - addresses: Expr(srv_address('tcp', 'admin', 'redpanda.redpanda.cluster.svc.cluster.local'))
type Expr string

type ObjectMeta struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason not to just use or alias metav1.ObjectMeta? I'm assuming b/c we don't want to pull in name/namespace fields?

Enabled: ptr.To(false),
Cert: nil,
RequireClientAuth: nil,
SecretRef: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is unused. Was this slurped into Cert at some point but never dropped?

SecretRef: &redpandav1alpha2.SecretRef{
Name: ptr.To(tls.Secrets.SecretRef.Name),
},
ApplyInternalDNSNames: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

deprecated?

ApplyInternalDNSNames: nil,
CAEnabled: nil,
ClientSecretRef: clientRef,
Duration: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

deprecated?

Name: ptr.To(tls.Secrets.SecretRef.Name),
},
ApplyInternalDNSNames: nil,
CAEnabled: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

deprecated? all of the above appear unused. I just worry if we haven't explicitly deprecated these fields, we'll lose behavior roundtripping.

}

var source CertificateSource
if cert.IssuerRef != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

again, mutually exclusive?

This commit adds the initial set of conversion routines to support
roundtripping all valid configurations of the v1alpha3 CR through the v1alpha2
CR.

To aid in the development and testing of the conversion routines, the
`exhaustruct` linter has been enabled on files ending in `_conversion.go`. It
requires all fields to be explicitly declared which will prevent future
additions to either CR from causing regressions.

It should be noted that v1alpha2 can NOT be roundtripped. Therefore the
v1alpha3 CRD can not be _safely_ enabled.

Future work will:
- Improve user facing documentation of all fields
- Support roundtripping v1alpha2 through v1alpha3
- (Potentially) refactor conversion to make use of the conversion-gen tool.
@chrisseto chrisseto force-pushed the chris/p/k8s-600-004-conversion branch from b329522 to 807d5c3 Compare June 16, 2025 19:49
@chrisseto
Copy link
Contributor Author

TFTRs! I realize this PR is a lot more half baked than I was remembering. I'm going to take a quick stab at the conversion-gen approach and adding both directions of round trips to see if I can make this feel less janky. There's so many TODOs that I will forget the context of if I merge it as is :/

@github-actions
Copy link

This PR is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Jun 22, 2025
@chrisseto chrisseto removed the stale label Jun 27, 2025
@github-actions
Copy link

github-actions bot commented Jul 3, 2025

This PR is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Jul 3, 2025
@github-actions
Copy link

github-actions bot commented Jul 8, 2025

This PR was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants