Skip to content

Update postgresql_type.go #1022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Update postgresql_type.go #1022

wants to merge 2 commits into from

Conversation

Ghostbaby
Copy link

when we use client-go create PostgreSQL, get the below error message.

2020-06-16T23:01:13.763+0800 ERROR controller-runtime.controller Reconciler error {"controller": "harborcluster", "request": "pg/harborcluster-sample", "error": "postgresql.acid.zalan.do \"harbor-postgre-cluster\" is invalid: []: Invalid value: map[string]interface {}{\"apiVersion\":\"acid.zalan.do/v1\", \"kind\":\"postgresql\", \"metadata\":map[string]interface {}{\"creationTimestamp\":\"2020-06-16T15:01:13Z\", \"generation\":1, \"name\":\"harbor-postgre-cluster\", \"namespace\":\"pg\", \"ownerReferences\":[]interface {}{map[string]interface {}{\"apiVersion\":\"cluster.goharbor.io/v1\", \"blockOwnerDeletion\":true, \"controller\":true, \"kind\":\"HarborCluster\", \"name\":\"harborcluster-sample\", \"uid\":\"fbcd8e4a-afe1-11ea-b2c3-00163f003dea\"}}, \"uid\":\"38b840ad-afe2-11ea-a750-00163e0dc939\"}, \"spec\":map[string]interface {}{\"allowedSourceRanges\":interface {}(nil), \"clone\":map[string]interface {}{}, \"databases\":map[string]interface {}{\"foo\":\"zalando\"}, \"dockerImage\":\"harbor.ymmoa.com/monitoring/postgresql:12\", \"numberOfInstances\":3, \"patroni\":map[string]interface {}{\"initdb\":interface {}(nil), \"loop_wait\":0, \"maximum_lag_on_failover\":0, \"pg_hba\":interface {}(nil), \"retry_timeout\":0, \"slots\":interface {}(nil), \"synchronous_mode\":false, \"synchronous_mode_strict\":false, \"ttl\":0}, \"podAnnotations\":interface {}(nil), \"postgresql\":map[string]interface {}{\"parameters\":map[string]interface {}{}, \"version\":\"12\"}, \"resources\":map[string]interface {}{\"limits\":map[string]interface {}{\"cpu\":\"0\", \"memory\":\"0\"}, \"requests\":map[string]interface {}{\"cpu\":\"0\", \"memory\":\"0\"}}, \"serviceAnnotations\":interface {}(nil), \"standby\":interface {}(nil), \"teamId\":\"harbor\", \"tls\":interface {}(nil), \"users\":map[string]interface {}{\"foo_user\":[]interface {}{}, \"zalando\":[]interface {}{\"superuser\", \"createdb\"}}, \"volume\":map[string]interface {}{\"size\":\"1Gi\", \"storageClass\":\"\"}}}: validation failure list:\nspec.serviceAnnotations in body must be of type object: \"null\"\nspec.clone.cluster in body is required\nspec.tls in body must be of type object: \"null\"\nspec.patroni.slots in body must be of type object: \"null\"\nspec.patroni.pg_hba in body must be of type array: \"null\"\nspec.patroni.initdb in body must be of type object: \"null\"\nspec.standby in body must be of type object: \"null\"\nspec.podAnnotations in body must be of type object: \"null\""}

@FxKu
Copy link
Member

FxKu commented Jul 14, 2020

@Ghostbaby it should ...,omitempty" not ...",omitempty. Judging from #1020 it might not be necessary for *Struct types. Maybe only for the string maps.

@Ghostbaby
Copy link
Author

@FxKu pls help me review this pr.

@ffuerste
Copy link

Hello,
I stumbled over the same problem. In our current customer project we wanted to use the postgres-operator in our go automation and failed to create the postgesql custom resource with the kubernetes go-client.

The current conflict is because of PR #1020.

Moreover, it would be great if the Patroni fields are defined as optional too (introducing omitempty for the fields in the struct Patroni). E.g. the PostgresSpec.Patroni.Slots field is commented in the official complete-postgres-manifest example. Would this be fine?

I am not sure how I can participate here. I don't want to open a second PR and I cannot update this one. Hence, I am commenting to push the topic. Thanks.

@Ghostbaby
Copy link
Author

@ffuerste hi guys, maybe you can fork pg struct to local.

@ffuerste
Copy link

@Ghostbaby This is exactly what we currently do. We created a local fork and adapted the postgres_types.go as needed.

But it would be great to have that merged in the upstream project. Our actual goal is it to manage the postgres-operator and it's lifecycle with OLM.
By the way, the postgres-operator is only available as v1.2.0 and v1.3.0 at operatorhub.io. Are there any plans to update the version on operatorhub.io?

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.

3 participants