postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Add SubPathExpr option for additionalVolumes

Open smutel opened this issue 1 year ago • 14 comments

Fix #2464

smutel avatar Oct 30 '23 14:10 smutel

SubPathExpr and SubPath are mutually exclusive => I don't know how to implement this. Tell me if you have an idea.

smutel avatar Oct 30 '23 14:10 smutel

Hey @hughcapet, Can we merge this PR ? It's a useful option to have. Thanx

micabe avatar Nov 09 '23 09:11 micabe

👍 Nice addition.

rds13 avatar Nov 09 '23 10:11 rds13

This PR is still lacking a few things. The CDR needs to be extended here and here. If the SubPath and SubPathExpr are mutually exclusive you can use OneOf syntax, I think. So far, we are not using it anywhere so you have to search for examples online.

When adding fields to the Postgres CRD, please also run code generation (./hack/update-codegen.sh). And mind that we also have the helm chart, where this new feature has to be addressed, too.

FxKu avatar Nov 13 '23 17:11 FxKu

Hello @FxKu,

Thank you for you review. I did the changes you ask me (I hope).

smutel avatar Nov 21 '23 15:11 smutel

I am facing this https://github.com/kubernetes/apimachinery/issues/18.

smutel avatar Nov 22 '23 08:11 smutel

Sounds good now.

smutel avatar Nov 23 '23 10:11 smutel

Any news on this ?

smutel avatar Dec 05 '23 13:12 smutel

@smutel e2e tests are failing. There's an issue with the CRD schema:

spec.validation.openAPIV3Schema.properties[spec].properties[additionalVolumes].items.oneOf[0].properties[subPath].type: Forbidden: must be empty to be structural, 
spec.validation.openAPIV3Schema.properties[spec].properties[additionalVolumes].items.oneOf[1].properties[subPathExpr].type: Forbidden: must be empty to be structural

FxKu avatar Jan 25 '24 14:01 FxKu

CRDs updated.

smutel avatar Jan 25 '24 15:01 smutel

Btw. I have just noticed that you did not add any logic to the Go code. It's not enough to just add a new field to the CRD. We use a lot of custom logic and not so much K8s specs. In this case the new SubPathExpr muss be set in generateVolumeMounts function. I would like to see a unit test then to check if the new expression is set when specified.

Sorry for suggesting oneOf here as both fields are optional. It's more typical when you have a required type field which specifies different options. You could even put the SubPathExpr in the SubPath field and use an extra bool flag isSubPathExpr. That makes implementation more straight forward. Hope you understand what I mean here.

FxKu avatar Jan 25 '24 15:01 FxKu

I changed my PR regarding your suggestion with boolean. Perhaps the default value for this boolean is missing but I don't know where to specify this.

smutel avatar Jan 29 '24 13:01 smutel

Looks good to you ?

smutel avatar Feb 19 '24 10:02 smutel

Any update on this ?

smutel avatar Mar 13 '24 19:03 smutel

LGTM now. Sorry for not getting back to this sooner.

FxKu avatar May 24 '24 09:05 FxKu

:+1:

FxKu avatar May 24 '24 09:05 FxKu

👍

idanovinda avatar May 24 '24 09:05 idanovinda