Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Conversation

@wallrj
Copy link
Member

@wallrj wallrj commented Apr 10, 2018

  • Only allow versions >= 3.0.0 && < 4.0.0
  • Disallow version changes in API updates (pending WIP: cassandra upgrade #277)
  • Document the supported versions.
  • Remove home made Cassandra version parsing code and replace with Hashicorp go-version which parses the looser form of version used by Cassandra.
  • Add github.com/hashicorp/go-version as a dependency.

Fixes: #320
Release note:

NONE

@wallrj
Copy link
Member Author

wallrj commented Apr 10, 2018

/retest

case versionSpecGe:
if v.LessThan(opVersion) {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we invert the implementation here?

i.e. versionSpecGe should run v.Greater and v.Equal and return true

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 deleted this code and instead use github.com/hashicorp/go-version constraints.

if opVersion.Equal(v) {
return false
}
if opVersion.LessThan(v) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We switch to testing opVersion instead of v here - can we be consistent for readability?

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 deleted this code and instead use github.com/hashicorp/go-version constraints.

for op, opVersion := range vs {
out = append(out, fmt.Sprintf("%s %s", op, opVersion))
}
return strings.Join(out, ", ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maps are not consistently ordered, so this version string will be unstable. Can we make it stable?

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 deleted this code and instead use github.com/hashicorp/go-version constraints.

versionSpecLt: version.New("4.0.0"),
}

func (vs versionSpec) Check(v *version.Version) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a quick unit test for this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to github.com/hashicorp/go-version constraints which already has unit tests.

@wallrj wallrj force-pushed the 320-version-validation branch from 9af030e to f284870 Compare April 25, 2018 15:03
@wallrj
Copy link
Member Author

wallrj commented Apr 25, 2018

Hey @munnerz.

Please take another look.

  • I replaced my home grown constraints checking code with github.com/hashicorp/go-version constraints.
  • Which seems to be more popular and better tested than the alternative https://github.com/Masterminds/semver
  • Also used Hashicorp version instead of coreos semver in the Cassandra Version type.
  • And added generated DeepCopy functions to that, as discussed.

I can follow this up with PRs to

  • use the same custom Version type for Elastic search.
  • have the controller perform an additional check for supported versions to handle the case where the API server may have been upgraded but the controller has not.

@wallrj
Copy link
Member Author

wallrj commented Apr 26, 2018

/retest

if err != nil {
return err
}
v.versionString = s
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to keep the versionString in memory? Surely semver.String will be more up to date?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need it because we want to remember the format of the originally supplied version string.
So if the Cassandra node reports version 3.11 via nodetool and a JMX query, we want to report that exact version in the Pilot.Status.Cassandra.Version rather than the semver 3.11.0.

We also don't want a user to submit CassandraCluster.Spec.Version: 3.11 and then have that change to 3.11.0 when they do kubectl get CassandraCluster -o yaml.

However, when we infer the Docker image tag, we use the semver, because we don't want docker to simply pull the latest 3.11 image from Dockerhub.

"github.com/coreos/go-semver/semver"
semver "github.com/hashicorp/go-version"
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this file out of pkg/cassandra and into something like pkg/api/util? This is an API type, but it isn't by default part of an API group (hence it isn't in apis).

It'd be good to denote it as such in the file structure, to make it clear this isn't specific to just cassandra (and also denotes that this type may be exposed in an api)

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.

t.Run(
"zero value",
func(t *testing.T) {
t.Log(version.Version{}.DeepCopy())
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't test anything, or ever fail afaict

Copy link
Member Author

Choose a reason for hiding this comment

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

It tests that a Zero value can be DeepCopied.
It originally caused a panic before I added a check for nil pointer in the implementation.
I'll leave it for now.

if v.semver == nil {
return Version{}
}
return *New(v.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Gopkg.toml Outdated

[[constraint]]
branch = "master"
name = "github.com/hashicorp/go-version"
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think this needs to be added as a constraint given we are constraining it to master anyway. A simple dep ensure without adding this block should yield the same result, sans this change

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.

@wallrj
Copy link
Member Author

wallrj commented Apr 26, 2018

/retest

@wallrj
Copy link
Member Author

wallrj commented Apr 26, 2018

The navigator-e2e-v1-9 E2E test failure was a flake, described here: jetstack/test-infra#180

@munnerz
Copy link
Contributor

munnerz commented May 8, 2018

/lgtm
/approve

@jetstack-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: munnerz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jetstack-bot jetstack-bot merged commit 4eb5cb2 into jetstack:master May 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants