Skip to content

change Clone attribute of PostgresSpec to *CloneDescription#1020

Merged
FxKu merged 7 commits into
zalando:masterfrom
cybertec-postgresql:change-pgspec.clone-to-ptr
Jul 30, 2020
Merged

change Clone attribute of PostgresSpec to *CloneDescription#1020
FxKu merged 7 commits into
zalando:masterfrom
cybertec-postgresql:change-pgspec.clone-to-ptr

Conversation

@hlihhovac

Copy link
Copy Markdown
Contributor

When creating postgresqls.acid.zalan.do CRD using client-go and type PostgresSpec, process fails in func (c *postgresqls) Create(ctx context.Context, postgresql *v1.Postgresql, opts metav1.CreateOptions) (result *v1.Postgresql, err error)due to the missing PostgresSpec.Clone attribute.
This was resolved changing Clone attribute to pointer *CloneDescription in PostgresSpec struct.
Other changes were required to adopt for above change.

@hlihhovac hlihhovac changed the title change Clone attribute of PostgresSpec to *ConnectionPooler change Clone attribute of PostgresSpec to *CloneDescription Jun 16, 2020
Comment thread pkg/apis/acid.zalan.do/v1/postgresql_type.go Outdated
@FxKu FxKu mentioned this pull request Jul 14, 2020
@FxKu FxKu added this to the 1.6 milestone Jul 14, 2020
Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
@FxKu

FxKu commented Jul 20, 2020

Copy link
Copy Markdown
Contributor

👍

Comment thread pkg/cluster/sync_test.go
ConnectionPoolerDefaultMemoryRequest: "100Mi",
ConnectionPoolerDefaultMemoryLimit: "100Mi",
NumberOfInstances: int32ToPointer(1),
newCluster := func() *Cluster {

@erthalion erthalion Jul 27, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@hlihhovac @pashagolub Why these changes are necessary for the CloneDescription?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ping, should this be removed for the scope of having a smaller PR=

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Jan-M do you want to remove test completely?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@erthalion these changes fix error during manual creation of postgresqls.acid.zalan.do CRD.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@erthalion these changes fix error during manual creation of postgresqls.acid.zalan.do CRD.

That's the goal of the whole PR, isn't it? I'm just trying to figure out if there is any mysterious value in changing unit test that seems to be completely unrelated (connection pooler test).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That unit test was broken with new functionality:
--- FAIL: TestConnectionPoolerSynchronization (0.00s)

Objects for testing before changes were static objects, after change introduced they became pointers... So before changes, the test just copies static objects and takes the address of it. And now copying pointer will still point to the same object! So tests always ruined the same underlying object with mock copies.

That's why all new mocked objects now created using New(), but not copying.

I hope it's clear enough :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But only CloneDescription became a point, right? And it's not involved in this test, so still sounds strange for me. But ok, at least it's not included by mistake.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The thing is the test itself was written for static properties. As soon as we've added pointers the simple copying became a problem. That's why we do not copy mock objects but create them separately so they do not interfere

@erthalion

Copy link
Copy Markdown
Contributor

👍

@FxKu FxKu merged commit 47b11f7 into zalando:master Jul 30, 2020
@FxKu

FxKu commented Jul 30, 2020

Copy link
Copy Markdown
Contributor

Thanks @hlihhovac and @pashagolub for your contribution!

@pashagolub

Copy link
Copy Markdown
Contributor

Thanks for cooperation!

@hlihhovac

Copy link
Copy Markdown
Contributor Author

Thx everybody!
It is great honour to be part of this community!

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.

5 participants