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

relaxed regexp to parse version out of a tag #24

Merged
merged 3 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/types/v1alpha1/srl_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func parseVersionString(s string) (*SrlVersion, error) {
return &SrlVersion{"0", "", "", "", ""}, nil
}

// https://regex101.com/r/eWS6Ms/1
// https://regex101.com/r/eWS6Ms/3
re := regexp.MustCompile(
`^v?(?P<major>\d{1,3})\.(?P<minor>\d{1,2})\.?(?P<patch>\d{1,2})?-?(?P<build>\d{1,10})?-?(?P<commit>\S+)?`,
`(?P<major>\d{1,3})\.(?P<minor>\d{1,2})\.?(?P<patch>\d{1,2})?-?(?P<build>\d{1,10})?-?(?P<commit>\S+)?`,
)

v := re.FindStringSubmatch(s)
Expand Down
5 changes: 5 additions & 0 deletions api/types/v1alpha1/srl_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func TestParseVersionString(t *testing.T) {
got: "0.0.0-34652",
want: &SrlVersion{"0", "0", "0", "34652", ""},
},
{
desc: "version_0.0.0-34652",
got: "version_0.0.0-34652",
want: &SrlVersion{"0", "0", "0", "34652", ""},
},
{
desc: "latest",
got: "latest",
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to see the following usecases be met:

  1. If a user specifies a model that does not require a license then the tag of their image should not matter

  2. If a user specifies a model that does require a license and the user has provided a single "catch all" license then the tag of their image should not matter

  3. If a user specifies a model that does require a license and the user has not provided a license or has provided a license that matches a specific version other than the one they provided then the failure should clearly output during topology creation instead of the current behavior of hanging (presumably due to some wait or retry from kne <-> srl-controller) or bringing the pods up, marking them running, then realizing there is no license and continue into a crash loop

What work would you need on KNE to help achieve this in tandem with srl-controller changes? Do the above usecases seem like the right behavior to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also in the short term can you add the "ga" tag as recognized in the same way "latest" is?

Expand Down
4 changes: 2 additions & 2 deletions api/types/v1alpha1/srlinux_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestGetImageVersion(t *testing.T) {
{
desc: "invalid version is present",
spec: &SrlinuxSpec{
Version: "abc21.11.1",
Version: "abc",
Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:somever"},
},
err: ErrVersionParse,
Expand All @@ -110,7 +110,7 @@ func TestGetImageVersion(t *testing.T) {
{
desc: "version is not present, invalid image tag is given",
spec: &SrlinuxSpec{
Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:21"},
Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:somesrl"},
},
err: ErrVersionParse,
},
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ kind: Kustomization
images:
- name: controller
newName: ghcr.io/srl-labs/srl-controller
newTag: 0.4.4
newTag: 0.4.5