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

Add support for imagePullSecrets for Scylla and Agent images #678

Merged
merged 3 commits into from Jul 29, 2021

Conversation

rzetelskik
Copy link
Member

@rzetelskik rzetelskik commented Jul 5, 2021

Description of your changes:

  • Add support for imagePullSecrets for Scylla and Agent images.
  • Add unit tests for StatefulSetForRack, including imagePullSecrets diffs

Resolves #348

@rzetelskik rzetelskik requested a review from zimnx July 5, 2021 13:56
@rzetelskik rzetelskik added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 5, 2021
@rzetelskik rzetelskik added this to the v1.4 milestone Jul 5, 2021
Copy link
Collaborator

@zimnx zimnx left a comment

Choose a reason for hiding this comment

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

Thanks, please rename PR title and commit msg to follow current naming convention.
Please also extract autogenerated changes to separate commit.

pkg/api/scylla/v1/cluster_types.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
@rzetelskik rzetelskik force-pushed the private_scylla_images branch 2 times, most recently from d4569cc to 275fb05 Compare July 5, 2021 15:39
@rzetelskik rzetelskik changed the title api: add ImagePullSecrets - fixes #348 Add support for imagePullSecrets for Scylla and Agent images Jul 5, 2021
@rzetelskik rzetelskik requested a review from zimnx July 5, 2021 15:45
pkg/api/scylla/v1/cluster_types.go Outdated Show resolved Hide resolved

storageCapacity, _ := resource.ParseQuantity(basicRack.Storage.Capacity)

expectedSts := &appsv1.StatefulSet{
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh this is painful to work with. Do something simillar to this approach:

expectedSts: func() *appsv1.StatefulSet {
sts := newSts()
sts.Spec.Replicas = pointer.Int32Ptr(*sts.Spec.Replicas + 1)
utilruntime.Must(SetHashAnnotation(sts))
return sts
}(),

Copy link
Member Author

Choose a reason for hiding this comment

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

done

pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/api/scylla/v1/cluster_types.go Outdated Show resolved Hide resolved
@rzetelskik rzetelskik force-pushed the private_scylla_images branch 2 times, most recently from b333f18 to 0b19dd8 Compare July 7, 2021 16:17
@rzetelskik rzetelskik requested a review from tnozicka July 7, 2021 16:19
@tnozicka tnozicka modified the milestones: v1.4, v1.5 Jul 8, 2021
@rzetelskik rzetelskik force-pushed the private_scylla_images branch 3 times, most recently from 8023196 to 73e8622 Compare July 13, 2021 10:41
@tnozicka tnozicka added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Jul 21, 2021
@tnozicka
Copy link
Member

API approved

@rzetelskik rzetelskik force-pushed the private_scylla_images branch 2 times, most recently from 63486a4 to ad8f159 Compare July 21, 2021 10:10
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
}
}

newNonNilImagePullSecrets := func() []corev1.LocalObjectReference {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd find it more readable we inline short functions like that, but that might be opinionated. in the other case the nonNil prefix is kind of implicit, I'd not assume you make a function to create nil

Copy link
Member Author

Choose a reason for hiding this comment

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

I was taking example from how it's done in existing test, e.g. cluster_validation_test. Inlining would require duplicating the anonymous function in each test case. What would you change the "nonNil" to?

Copy link
Member

Choose a reason for hiding this comment

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

I was taking example from how it's done in existing test, e.g. cluster_validation_test.

I guess that could have used some tweaking as well :)

Inlining would require duplicating the anonymous function in each test case.

actually, there wouldn't be an anonymous function at all

sc.Spec.ImagePullSecrets = []corev1.LocalObjectReference{
	{
		Name: "basic-secrets",
	},
}

What would you change the "nonNil" to?

I'd drop it, the other helper functions (like newBasicStatefulSet) don't start with the prefix, yet we assume they return non-nil values

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I changed the shorter functions to inline and renamed the other ones

expectedStatefulSet: nil,
expectedError: func() error {
_, err := resource.ParseQuantity("")
return fmt.Errorf("cannot parse %q: %v", "", err)
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd just put the string inside, calling the function assumes to much internals that could change while the string stays constant

Copy link
Member Author

Choose a reason for hiding this comment

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

compared string + added cmpopts.EquateErrors() for recommended error comparison

pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
@rzetelskik rzetelskik force-pushed the private_scylla_images branch 2 times, most recently from a0ccc09 to 43c26f8 Compare July 24, 2021 11:12
@rzetelskik rzetelskik requested a review from tnozicka July 24, 2021 12:26
Copy link
Member

@tnozicka tnozicka left a comment

Choose a reason for hiding this comment

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

please split generated files and go.mod + vendor into separate commits

}
}

newNonNilImagePullSecrets := func() []corev1.LocalObjectReference {
Copy link
Member

Choose a reason for hiding this comment

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

I was taking example from how it's done in existing test, e.g. cluster_validation_test.

I guess that could have used some tweaking as well :)

Inlining would require duplicating the anonymous function in each test case.

actually, there wouldn't be an anonymous function at all

sc.Spec.ImagePullSecrets = []corev1.LocalObjectReference{
	{
		Name: "basic-secrets",
	},
}

What would you change the "nonNil" to?

I'd drop it, the other helper functions (like newBasicStatefulSet) don't start with the prefix, yet we assume they return non-nil values

pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
pkg/controller/scyllacluster/resource/resource_test.go Outdated Show resolved Hide resolved
@rzetelskik rzetelskik force-pushed the private_scylla_images branch 2 times, most recently from 08a7d79 to 441f53f Compare July 28, 2021 08:24
@rzetelskik rzetelskik requested a review from tnozicka July 28, 2021 08:27
Copy link
Member

@tnozicka tnozicka left a comment

Choose a reason for hiding this comment

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

nits, lgtm otherwise

Copy link
Member

@tnozicka tnozicka left a comment

Choose a reason for hiding this comment

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

/lgtm
thanks!

Copy link
Collaborator

@zimnx zimnx left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@zimnx zimnx merged commit 9230a4a into scylladb:master Jul 29, 2021
@rzetelskik rzetelskik deleted the private_scylla_images branch July 29, 2021 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support imagePullSecrets for Scylla image
3 participants