-
Notifications
You must be signed in to change notification settings - Fork 84
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
Conversation
pkg/registries/adapters/adapter.go
Outdated
maxMajorVersion, err := strconv.Atoi(strings.Split(maxVersion, ".")[0]) | ||
maxMinorVersion, err := strconv.Atoi(strings.Split(maxVersion, ".")[1]) | ||
if err != nil { | ||
return false |
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.
Oh crap, this is a typo. Let me fix this.
pkg/registries/adapters/adapter.go
Outdated
if err != nil { | ||
return false | ||
} | ||
specMinorVersion, err := strconv.Atoi(strings.Split(specVersion, ".")[1]) |
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 could panic when I have set the version to 1
only.
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.
+1 another good catch
pkg/registries/adapters/adapter.go
Outdated
return true | ||
} | ||
} | ||
} else if minMajorVersion < maxMajorVersion { |
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 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.
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.
+1 good catch.
pkg/version/apbversion.go
Outdated
@@ -0,0 +1,4 @@ | |||
package version | |||
|
|||
var MinAPBVersion = "1.0" |
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 think that we may want these to be const
rather than var
.
Also, anything that is exported from the package needs a comment.
@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. |
Confirmed when running catasb with the |
pkg/registries/adapters/adapter.go
Outdated
@@ -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 == "" { |
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.
You can combine this with if conf.Config.Label.Spec == ""
since we now require both be set.
Linter errors:
|
You need to update the |
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.
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
@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. |
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. |
pkg/registries/adapters/adapter.go
Outdated
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") |
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.
It should be: Didn't find encoded Spec label or 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 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" |
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.
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.
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 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.
pkg/registries/adapters/adapter.go
Outdated
if err != nil { | ||
return false | ||
} | ||
minMinorVersion, err := strconv.Atoi(strings.Split(minVersion, ".")[1]) |
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.
How come we have to check minor versions? I thought we accept APBVersions >= 1.0 and < 2.0.
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 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.
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.
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.
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 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.
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.
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.
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.
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.
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 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.
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 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.
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.
+1 sounds good to me
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.
+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.
pkg/registries/adapters/adapter.go
Outdated
if err != nil { | ||
return false | ||
} | ||
minMinorVersion, err := strconv.Atoi(strings.Split(minVersion, ".")[1]) |
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.
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.
* 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
This PR adds version checks to the broker when bootstrapping an APB
Changes proposed in this pull request
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.