-
Notifications
You must be signed in to change notification settings - Fork 31
Add 'version' field to ESC. Auto-generate Elasticsearch image details #205
Conversation
3d6d08b
to
c153a55
Compare
/test e2e |
1 similar comment
/test e2e |
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 good, but similar questions as for #206
- If I omit the ElasticSearch image spec when I create my cluster resource, what happens when I try and change the new
Version
attribute? - Do I then need to also provide the full image spec or will the appropriate default image spec be selected for that version?
if esImage.FsGroup == 0 && | ||
esImage.ImageSpec.PullPolicy == "" && | ||
esImage.ImageSpec.Repository == "" && | ||
esImage.ImageSpec.Tag == "" { |
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.
- Why check for FsGroup here?
- Could you instead compare esImage.ImageSpec to the zero value of ImageSpec?
- What if I supply FsGroup, but omit the ImageSpec? It looks like the pod will fail to start.
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.
-
Changing the
version
attribute is expected use. This should cause navigator to begin an upgrade/downgrade/report an error that upgrade/downgrade isn't possible. -
Nope - provide the
version
and everything else is handled for you. As soon as you specify either FsGroup, PullPolicy, Repository or Tag however, you've gone into manual mode. Manual mode might be removed at some point in the future (as discussed today) -
As above, fsGroup is checked because if specified, you've switched to 'manual mode' (and so all the others are required too). Perhaps this will make a bit more sense once we get the validation PR (Add basic ElasticsearchCluster resource validation #199) merged.
-
Yep potentially we could just check the zero values - or as you suggested earlier, make this field a pointer.
-
Yep you are correct. FsGroup = manual mode. Remember users never see
imageSpec
as a field (as it's json tag is:json:",inline"
)
@munnerz PR needs rebase |
bde96d4
to
b7037ae
Compare
/test e2e |
}, | ||
// We don't error here - if the specified version is non semver but the | ||
// user has specified a manual image, validation should detect the | ||
// invalid semver and fail. |
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.
Shouldn't we always error with non-semver version?
Or does this comment mean that the non-semver version will be caught and rejected by resource validation in #199?
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.
Precisely that - yep. It seems odd to return an error in this case. The function should be returning the image that should be used for the spec, and the image is explicitly defined in the manifest, so there's not really an error.
There is however an error with the overall state/spec of the cluster, and validation should be responsible for detecting this. I guess more gates isn't a bad thing, but I think the gate might need to be moved to some other function if we do add it. I'm working on validation now and will expand that PR to encompass new fields added here once merged.
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.
Thanks @munnerz
Looks great. I like your change to make ESImage a reference. And happy to see the unit tests. 👍
- I've always been taught to convert to rich types as soon as possible, so
- I'd be inclined to make the
Version *semver.Version
, - assuming that it's simple to register a JSON unmarshaller for that type.
- That way we wouldn't have to parse the Semver everytime we need to use it.
Up to you. Merge when you're happy with everything.
pkg/apis/navigator/types.go
Outdated
@@ -89,10 +89,11 @@ type ElasticsearchClusterList struct { | |||
} | |||
|
|||
type ElasticsearchClusterSpec struct { | |||
Version string |
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'd be inclined to make this type *semver.Version
?
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'm not sure we can just make this some other struct. The Golang JSON parser would fail because string
is not a structure, which it would expect the field to be.
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.
That said, UnmarshalJSON etc. is defined so maybe it would. I'll take a look. Depending on external types in our apis can get pretty prickly though - if we update our dependency it could cause breaking API changes (and we don't 'control' the downstream code, which makes it harder to fix/manage)
/test e2e |
3558b40
to
fc7e786
Compare
@wallrj I've updated the PR to make the new Version field in our API into a The unit tests obviously work with Golang structs (and pass), but they don't test the unmarshalling from a string. I've added a Once #199 merges, I'll add further validation to this to stop invalid values being submitted to the API. |
fc7e786
to
110fab4
Compare
I've added additional validation to this now, which ensures that Unmarshaling will error if an invalid string is provided, but it doesn't error if no string is provided (it returns nil). In order to handle this case, I check for an empty |
@munnerz PR needs rebase |
… and allow override.
354149d
to
f5382aa
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.
Thanks @munnerz
Just take another look at those error cases in the tests I think they need modifying.
Then merge when happy.
NodePools: []navigator.ElasticsearchClusterNodePool{validNodePool, validNodePool}, | ||
Pilot: validPilotImage, | ||
Image: validESImage, | ||
}, |
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.
Version is missing from all the other error cases too.
So it's not clear whether they're failing because of version or minimummaster
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wallrj The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@munnerz PR needs rebase |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. |
What this PR does / why we need it:
This PR adds a version field to an ElasticsearchCluster. It is used to auto-default the ElasticsearchImageSpec in its absence. If a user wants to override the image to be used and take manual control, they can specify their own fields as before.
The new version field should be required regardless whether the image is manually specified, as in future it can be used to help influence upgrade strategy. It will be up to the administrator to update the image and listed version in unison.
In future we should make the default image repository and uid be configurable.
Special notes for your reviewer:
Ensuring the spec.version field is set will be in a follow up after #199 is merged
Release note: