-
Notifications
You must be signed in to change notification settings - Fork 181
Add support of named and digest scylladb image reference with google cr #2491
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
base: master
Are you sure you want to change the base?
Add support of named and digest scylladb image reference with google cr #2491
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: grzywin The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
cad74fd
to
3209648
Compare
eeeda12
to
43394ad
Compare
da639b8
to
1d114b8
Compare
1d114b8
to
21a0f03
Compare
989ab65
to
57cf6e7
Compare
3fd1dcb
to
c7414b0
Compare
4b0ff85
to
2a7a7ae
Compare
/retest |
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.
first batch
@@ -13,6 +13,6 @@ operator: | |||
prometheusVersion: "v2.54.1" | |||
operatorTests: | |||
scyllaDBVersions: | |||
updateFrom: "6.2.0-rc2" | |||
upgradeFrom: "6.1.2" | |||
updateFrom: "sha256:cf00b8bfcce4d27e8527cad913e83db89af842e6cfb64ff4736bce83594b33d1" |
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's unclear what it's being tested, use tag+sha format
@@ -1,5 +1,5 @@ | |||
operator: | |||
scyllaDBVersion: "6.2.0" | |||
scyllaDBVersion: "sha256:5b53a7c60d9f9555bb87791ff29b2e633c6f472aec00de7afaf4db1addc6d594" |
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's unclear what version it is. Use tag+sha format
@@ -463,7 +468,7 @@ endef | |||
# $1 - values.yaml | |||
define update-scylla-helm-versions | |||
$(YQ) eval-all -i -P '\ | |||
select(fi==0).scyllaImage.tag = ( select(fi==1) | .operator.scyllaDBVersion ) | \ | |||
select(fi==0).scyllaImage.tag = ( select(fi==1) | "$(SCYLLADB_SEM_VER)" ) | \ |
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.
Would you mind elaborating why this is changed?
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.
When we execute make update
command it is updating the manifests. Without this change the ScyllaDB version is taken directly from config.yaml file which at this moment I changed to digest. So in manifest we will something like below which won't work.
spec:
version: sha256:5b53a7c60d9f9555bb87791ff29b2e633c6f472aec00de7afaf4db1addc6d594
Note: Just to clarify. My solution is not changing almost any logic directly in operator. I just added logic to handle digest and convert it to 'supported' version before it reaches the operator/manifests.
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.
Note: Just to clarify. My solution is not changing almost any logic directly in operator. I just added logic to handle digest and convert it to 'supported' version before it reaches the operator/manifests.
Lets do other way around. Having manipulations in tests and scripts doesn't bring any value to the user. If Operator would support all valid formats of image references, then any transformation in test/scripts wouldn't be needed, and users could use all variants of image references.
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 as part of this feature, we could also restructure config.yaml to accept full Scylla image ref instead just version. Places where split between repository and other part is required would be handled by the scripts around assets.
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.
Ok, I thought the goal of this change was to allow us to use the digest/tag/'latest', so that we have more control over the exact version we're testing, rather than to please the users.
@@ -47,3 +66,91 @@ func (sv ScyllaVersion) SupportFeatureUnsafe(featureVersion semver.Version) bool | |||
func (sv ScyllaVersion) SupportFeatureSafe(featureVersion semver.Version) bool { | |||
return !sv.unknown && sv.version.GTE(featureVersion) | |||
} | |||
|
|||
func GetImageVersionAndDigest(imageName, version string) (string, string, error) { |
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.
Based on the name it's unclear what is returned from this function.
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.
Please also add unit tests for it.
return semVersion, version, nil | ||
} | ||
|
||
imageReference := fmt.Sprintf("scylladb/%s", imageName) |
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.
Lets not hardcode anything. ScyllaCluster spec accepts also repository which might not contain scylladb substring at all.
func computeSemVersion(fullVersion string) (string, error) { | ||
reSemVersion := regexp.MustCompile(`\d+\.\d+\.\d+`) | ||
semVersion := reSemVersion.FindString(fullVersion) | ||
|
||
if semVersion == "" { | ||
return "", fmt.Errorf("could not extract semantic version from: %s", fullVersion) | ||
} | ||
|
||
reSuffix := regexp.MustCompile(`[~-]([a-zA-Z]+\d*)`) | ||
suffixMatch := reSuffix.FindStringSubmatch(fullVersion) | ||
if len(suffixMatch) > 1 { | ||
semVersion = fmt.Sprintf("%s-%s", semVersion, suffixMatch[1]) | ||
} | ||
return semVersion, nil | ||
} |
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.
https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
Why not using semver dependancy we already have?
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 will take another look on that but semver dependency was not working for me here as for RCs ScyllaDB version label has a bit unusual format:
6.2.0~rc2-0.20241002.93700ff5d1ce@sha256:92dfd26d64c6d076c5a641b3526c63fd827c777bc8c0fbce3bfddc6c9913e9b6
As far as I had a problem with tilde sign.
@@ -172,7 +171,7 @@ var _ = g.Describe("ScyllaCluster", func() { | |||
}, | |||
g.Entry(describeEntry, &entry{ | |||
scyllaImageRepository: scyllaOSImageRepository, | |||
scyllaVersion: configassests.Project.Operator.ScyllaDBVersion, | |||
scyllaVersion: framework.TestContext.ScyllaDBVersion, |
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 this is changed?
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.
With my previous commit b2d7fb1 I added flags support.
This line is actually an oversight which should be changed/added in the commit above.
if _, err := semver.Parse(o.ScyllaDBVersion); err != nil { | ||
semScyllaDBVersion, fullScyllaDBVersion, err := scyllasemver.GetImageVersionAndDigest("scylla", o.ScyllaDBVersion) | ||
if err != nil { | ||
return fmt.Errorf("failed to resolve ScyllaDB version: %w", err) | ||
} | ||
fmt.Println("Extracted", semScyllaDBVersion, "from ScyllaDB version:", fullScyllaDBVersion) | ||
|
||
o.ScyllaDBVersion = semScyllaDBVersion | ||
} | ||
|
||
if !tagOrDigestRegexp.MatchString(o.ScyllaDBUpdateFrom) { |
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 all of this be part of Operator not the tests?
We shouldn't manipulate the input parameters there to transform it to format accepted by the Operator, but Operator should accept any valid image reference and support it.
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@grzywin: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
The Scylla Operator project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
/lifecycle stale |
Description of your changes:
Add support of named and digest scylladb image reference with google cr. Supported syntax: <tag><digest>, <digest>, <tag> (also tags like "latest")
Which issue is resolved by this Pull Request:
Resolves #2455