-
Notifications
You must be signed in to change notification settings - Fork 518
CLOUDP-82159: Upgrade to operator-sdk v1.4.0 #327
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
Conversation
2ff254a
to
bef215d
Compare
4eedf29
to
86596b2
Compare
@@ -19,17 +19,6 @@ functions: | |||
params: | |||
directory: mongodb-kubernetes-operator | |||
|
|||
setup_operator_sdk: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed, so I removed this step.
api/v1/mongodbcommunity_types.go
Outdated
@@ -69,7 +69,7 @@ type MongoDBCommunitySpec struct { | |||
Users []MongoDBUser `json:"users"` | |||
|
|||
// +optional | |||
StatefulSetConfiguration StatefulSetConfiguration `json:"statefulSet,omitempty"` | |||
StatefulSetConfiguration appsv1.StatefulSetSpec `json:"statefulSet,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixed the statefulset_arbitrary e2e tests. For some reason, even though the custom marshal/unmarshal code should be including this field when annotated with "-", it is being ignored. For that reason I reintroduced the CRD generation (which should be fine as long as we can automatically generate the CRD).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to make sure the end resource still works by specifying statefulSet.spec
@@ -9,4 +9,5 @@ if ! whoami >/dev/null 2>&1; then | |||
fi | |||
fi | |||
|
|||
exec "${OPERATOR}" "$@" | |||
echo "Running ./${OPERATOR}" | |||
"./${OPERATOR}" "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exec was not working, so I switched to "./"
86596b2
to
5c054bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, massive work! Had a few comments, the main issue we need to address is fixing the test failures in the additionalMongodConfig test and making sure that the spec of the MongoDBCommunity resources is still mdb.spec.statefulSet.spec.*
test/e2e/statefulset_arbitrary_config/statefulset_arbitrary_config_test.go
Outdated
Show resolved
Hide resolved
config/samples/arbitrary_statefulset_configuration/mongodb.com_v1_custom_volume_cr.yaml
Outdated
Show resolved
Hide resolved
api/v1/mongodbcommunity_types.go
Outdated
@@ -69,7 +69,7 @@ type MongoDBCommunitySpec struct { | |||
Users []MongoDBUser `json:"users"` | |||
|
|||
// +optional | |||
StatefulSetConfiguration StatefulSetConfiguration `json:"statefulSet,omitempty"` | |||
StatefulSetConfiguration appsv1.StatefulSetSpec `json:"statefulSet,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to make sure the end resource still works by specifying statefulSet.spec
|
||
return nil | ||
// SetupWithManager sets up the controller with the Manager and configures the necessary watches. | ||
func (r *ReplicaSetReconciler) SetupWithManager(mgr ctrl.Manager) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[q] is there a reason this is a method and not a function? Does this implement some interface that is required?
Not a big deal either way!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's required, but it is the way the scaffolding intended (and matches the Reconcile method). I don't think this particular method gets called anywhere outside of main.go (e.g. by the library), but my vote would be to keep it consistent with operator-sdk's expectations so that we don't diverge too far, just in case they introduce code expecting it to follow this format.
Pushed changes to move back to CRD version v1beta1 and address feedback. Note that whenever we are ready to move to version v1beta1, here's what needs to happen:
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=true,crdVersions=v1beta1" to: CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
// +kubebuilder:validation:XPreserveUnknownFields
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks amazing! I think we're good to go, I think if @bznein / @irajdeep can take a look at this as well that would be great.
We can tackle the upgrade from v1beta1 to v1 in a future PR.
cc @rodrigovalin this will be a great PR to use as a reference when working on the CRD project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great work. Added some minor comments.
@@ -0,0 +1,10 @@ | |||
# This kustomization.yaml is not intended to be run by itself, | |||
# since it depends on service name and namespace that are out of this kustomize package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: are we adding kustomize
support with this PR as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The project was re-scaffolded with the new version of operator-sdk, which generated a bunch of kustomize files for us. The make deploy target in the Makefile uses kustomize to generate the yaml it applies.
This change re-scaffolds the operator using the latest version of operator-sdk (v1.4.0)
make generate manifests docker-build docker-push deploy IMG=localhost:5000/mongodb-kubernetes-operator
make manifests
generates CRDsmake generate
generates deepcopy codemake docker-build docker-push
builds the docker image and pushes it. I modified this directive to generate the Dockerfile using our existing scripts, but if you want to generate a Dockerfile other than the operator, e.g. e2e, you can now runmake docker-build docker-push IMG=localhost:5000/e2e DOCKERFILE=e2e
It was necessary to remove the wrappers around the StatefulSetConfiguration field in mongodb_types, as fields annotated with
"-"
json struct tags no longer are included, not even with the custom JSON marshalling code. This reintroduced CRD pollution (and accounts for most of the liens of code changed). The CRD is automatically generated, so hopefully this shouldn't be too much of a problem.For a similar reason, these changes break the additionalMongodConfig field(the only failing e2e test is
e2e_test_replica_set_mongod_config
). However, the fix for this field is not apparent, since its type boils down tomap[string]interface{}
, which cannot be generated in the CRDs asinterface{}
is not a named type.Note: this doesn't include the necessary documentation changes, which should be added in a separate PR.