Skip to content
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

change Clone attribute of PostgresSpec to *CloneDescription #1020

Merged
merged 7 commits into from
Jul 30, 2020

Conversation

hlihhovac
Copy link
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
@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
Copy link
Member

FxKu commented Jul 20, 2020

👍

ConnectionPoolerDefaultMemoryRequest: "100Mi",
ConnectionPoolerDefaultMemoryLimit: "100Mi",
NumberOfInstances: int32ToPointer(1),
newCluster := func() *Cluster {
Copy link
Contributor

@erthalion erthalion Jul 27, 2020

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
Member

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
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
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
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
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
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
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
Contributor

👍

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

FxKu commented Jul 30, 2020

Thanks @hlihhovac and @pashagolub for your contribution!

@pashagolub
Copy link
Contributor

Thanks for cooperation!

@hlihhovac
Copy link
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