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

Added versioning check to Broker on bootstrap #457

Merged
merged 6 commits into from
Sep 29, 2017

Conversation

dymurray
Copy link
Member

This PR adds version checks to the broker when bootstrapping an APB

Changes proposed in this pull request

  • Move version.go to its own version pkg
  • Add version check on imageToSpec conversion
  • Add unit tests for compatible version checks

Note:
I plan to open an issue to move the version to the spec itself so that this check moves out of the adapter pkg.

maxMajorVersion, err := strconv.Atoi(strings.Split(maxVersion, ".")[0])
maxMinorVersion, err := strconv.Atoi(strings.Split(maxVersion, ".")[1])
if err != nil {
return false
Copy link
Member Author

Choose a reason for hiding this comment

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

Oh crap, this is a typo. Let me fix this.

@dymurray dymurray changed the title Added versioning check to Broker on bootstrap [Do Not Merge] Added versioning check to Broker on bootstrap Sep 27, 2017
if err != nil {
return false
}
specMinorVersion, err := strconv.Atoi(strings.Split(specVersion, ".")[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

This could panic when I have set the version to 1 only.

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 another good catch

return true
}
}
} else if minMajorVersion < maxMajorVersion {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is going to return false for isCompatibleVersion("2.5", "1.0", "3.6")
I don't know if this use case make sense or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 good catch.

@@ -0,0 +1,4 @@
package version

var MinAPBVersion = "1.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we may want these to be const rather than var.
Also, anything that is exported from the package needs a comment.

@dymurray
Copy link
Member Author

@shawn-hurley Thanks for the feedback. Just making it known that this will always fail CI until the APBs are updated with the proper version which I am working on doing today as well.

@dymurray
Copy link
Member Author

Confirmed when running catasb with the canary tag for images that are being built off recent commits that they are passing version validation.

@dymurray dymurray changed the title [Do Not Merge] Added versioning check to Broker on bootstrap Added versioning check to Broker on bootstrap Sep 27, 2017
@@ -111,6 +114,15 @@ func imageToSpec(log *logging.Logger, req *http.Request, apbtag string) (*apb.Sp
log.Infof("Didn't find encoded Spec label. Assuming image is not APB and skiping")
return nil, nil
}
if conf.Config.Label.Version == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can combine this with if conf.Config.Label.Spec == "" since we now require both be set.

@jmrodri
Copy link
Contributor

jmrodri commented Sep 28, 2017

Linter errors:

pkg/version/apbversion.go:3:1: comment on exported const MinAPBVersion should be of the form "MinAPBVersion ..."

pkg/version/apbversion.go:7:7: exported const MaxAPBVersion should have comment or be unexported

Found 2 lint suggestions; failing.

make: *** [lint] Error 1

@jmrodri
Copy link
Contributor

jmrodri commented Sep 28, 2017

You need to update the version.go.tmpl package as well.

Copy link
Contributor

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

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

linter failed (see comment above for errors). Run make lint to fix.

The CI failed as well this was the end of the log:

##### CLUSTER SETUP VARIABLE LIST #####
BUILD_ERROR: false
CLUSTER_SETUP_ERROR: false
MAKE_DEPLOY_ERROR: false
##### GATE VARIABLE LIST #####
RESOURCE_ERROR: false
BIND_ERROR: true
PROVISION_ERROR: false
POD_PRESET_ERROR: false
VERIFY_CI_ERROR: false
UNBIND_ERROR: false
DEPROVISION_ERROR: false
DEVAPI_ERROR: false
make: *** [ci] Error 1

@jmrodri
Copy link
Contributor

jmrodri commented Sep 28, 2017

@dymurray forget my CI comment then, I see your comment about being dependent on apbs. But the linter is still broken so that comment still stands.

@dymurray
Copy link
Member Author

CI is failing on binding... unsure how my PR affects binding of mediawiki to postgres. I have confirmed the latest images on dockerhub have the proper version and the broker is bootstrapping them.

if conf.Config.Label.Spec == "" {
log.Infof("Didn't find encoded Spec label. Assuming image is not APB and skiping")
if conf.Config.Label.Spec == "" || conf.Config.Label.Version == "" {
log.Infof("Didn't find encoded Spec label and version. Assuming image is not APB and skiping")
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be: Didn't find encoded Spec label or version.

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 meant that as in "Unable to find both version and spec label" but I will change it because I can see why thats confusing.

// acceptible APBs.

// MinAPBVersion constant to describe minimum supported spec version
const MinAPBVersion = "1.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

From the spec: APB with version 1.y works with broker 1.y.z

I don't think you need two constants to track a valid APB version. I think you really only need one: BrokerVersion=1.0. Using the broker version, you can check if an APB is valid since anything >=1.x and < 2.0 is valid.

One argument I can see for having a MinAPBVersion is backwards compatibility, but we don't have a requirement for that yet.

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 do have a requirement for backwards compatibility we just have not gotten to a point where it is a problem yet. Also, I have updated the proposal with the notes we took on the 9/26 meeting. The broker version is not tied directly to the APB spec version. We want brokers to have a range of APB versions they support and not have to bump a release every time something changes in the broker when the APB spec itself has not changed.

if err != nil {
return false
}
minMinorVersion, err := strconv.Atoi(strings.Split(minVersion, ".")[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we have to check minor versions? I thought we accept APBVersions >= 1.0 and < 2.0.

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 to check minor versions because of the scenario where we support beyond 2.0. We need a way to check that the version fits outside of one major version bump.

Copy link
Contributor

Choose a reason for hiding this comment

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

So you're saying we'd support >= 1.0 and < 2.x? If we do that then we can't really say that only a major version bump will break the API. IMO, that goes against the reason to have major vs minor versioning.

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'm not sure how we can't say that? A broker that only knows how to deploy 1.X APBs will never be able to support 2.X APBs. However, I would expect a broker that knows how to deploy 2.X APBs to know how to deploy 1.X APBs as that would be supporting backwards compatibility. In this case the major version bump does break the API, it's just that we expect the broker to support 1.X APBs even as we move to a 2.X spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case the major version bump does break the API, it's just that we expect the
broker to support 1.X APBs even as we move to a 2.X spec.

👍

Here's an example of what I'm thinking:

  • We move to APBVersion 2.3.
  • APBVersion >= 1.0 and APBVersion < 3.0 are supported

Why would we need to check the minor version when we know that anything greater than or equal to the minimal major version and less than the maximum major version is valid? In other words, all breaking changes are per major version. If we support 1.0 then we also support 1.7 and 1.x so there's no reason to check beyond the major version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unless you feel that my example would imply a major version bump... then I could see why it would be trivial to check the minor version. I just worry about not checking the minor version at all and someone putting 1.Z which doesn't exist and has no associated schema.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just worry about not checking the minor version at all and someone putting 1.Z which doesn't
exist and has no associated schema.

I understand your concern, but if we follow the release plan correctly then we won't have this issue. And if we make a mistake then we can always change the version.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't mind having Ryan's logic be the default, but if a user has defined some config then we override? This might just be a feature we add later and for now, just follow Ryan's logic for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 sounds good to me

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 @rthallisey example is how I mentally pictured how this would work. The scenario of 2.4 causing a problem means IMO we failed with the change APB spec change.

if err != nil {
return false
}
minMinorVersion, err := strconv.Atoi(strings.Split(minVersion, ".")[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

So you're saying we'd support >= 1.0 and < 2.x? If we do that then we can't really say that only a major version bump will break the API. IMO, that goes against the reason to have major vs minor versioning.

@shawn-hurley shawn-hurley merged commit 852dde4 into openshift:master Sep 29, 2017
jianzhangbjz pushed a commit to jianzhangbjz/ansible-service-broker that referenced this pull request May 17, 2018
* Added versioning check to Broker on bootstrap

* Added error check

* Updates based on feedback, more error handling

* Fix linting problems

* Logging info update

* Reverted to just using major version
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.

None yet

4 participants