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

MON-3468: Add cli args to specify image pullspecs and versions for operants #386

Merged
merged 8 commits into from
Jan 18, 2024

Conversation

jan--f
Copy link
Collaborator

@jan--f jan--f commented Nov 9, 2023

Fixes #250

Copy link

openshift-ci bot commented Nov 9, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@jan--f jan--f force-pushed the image-version-cli-args branch from f8ec622 to 8bde370 Compare November 9, 2023 19:10
@jan--f
Copy link
Collaborator Author

jan--f commented Nov 9, 2023

Updated with prometheus/[email protected].

@jan--f jan--f force-pushed the image-version-cli-args branch from 8bde370 to 61da795 Compare November 9, 2023 19:17
@jan--f jan--f marked this pull request as ready for review November 9, 2023 19:20
@jan--f jan--f requested a review from a team as a code owner November 9, 2023 19:20
@jan--f jan--f requested review from simonpasquier and sthaha and removed request for a team November 9, 2023 19:20
@jan--f jan--f force-pushed the image-version-cli-args branch 2 times, most recently from dccb879 to af2046d Compare November 10, 2023 08:20
@jan--f jan--f changed the title Add cli args to specify image pullspecs and versions for operants MON-3468: Add cli args to specify image pullspecs and versions for operants Nov 10, 2023
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Nov 10, 2023

@jan--f: This pull request references MON-3468 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set.

In response to this:

Fixes #250

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/test-infra repository.

images := kvarg{}
flag.Var(&images, "images", "Images to use for containers managed by the observability-operator.")
versions := kvarg{}
flag.Var(&versions, "versions", "Version of containers managed by the observability-operator.")
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 define the operand versions or should we rely on the hardcoded default versions from github.com/rhobs/obo-prometheus-operator?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was going to argue for the p-o default versions. In the Thanos Querier controller I already set that explicitly https://github.com/rhobs/observability-operator/pull/386/files#diff-62df723ef5f27edbbfaa7feeb8a0612efaa9ef8d91828004287a17f77f0c48aeR74. In Prometheus objects the version is not set if empty to let p-o do its defaulting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Defaulting would be latest or does p-o do any kind of logic already?

Copy link

Choose a reason for hiding this comment

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

IMHO it makes more sense for p-o and thanos do their defaults

map[string]float64{
`{__name__="controller_runtime_reconcile_errors_total", controller="grafana-operator"}`: 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 assume we're removing this as a part of the change as grafana-operator is no longer around in p-o

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

FYI I've stumbled across https://pkg.go.dev/k8s.io/[email protected]/cli/flag#MapStringString which can translate key=val CLI args into map[string]string.

@jan--f
Copy link
Collaborator Author

jan--f commented Nov 24, 2023

FYI I've stumbled across https://pkg.go.dev/k8s.io/[email protected]/cli/flag#MapStringString which can translate key=val CLI args into map[string]string.

Nice, thank you! Added.

@jan--f jan--f force-pushed the image-version-cli-args branch from 3f0baf2 to a4d5ccc Compare January 18, 2024 07:38
This commit also decouples the monitoring-stack controller and thanos
controller by implementing a ThanosSidecar configuration struct in
monitoring-stack.

Signed-off-by: Jan Fajerski <[email protected]>
@danielmellado
Copy link
Contributor

hmmmm e2e tests are complaining about mv: cannot stat 'tmp/e2e': No such file or directory let's see

@danielmellado
Copy link
Contributor

/test observability-operator-e2e

@danielmellado
Copy link
Contributor

/assign @sthaha

@jan--f jan--f force-pushed the image-version-cli-args branch from b301231 to 300696d Compare January 18, 2024 13:50
And add some default checking and setting.

Signed-off-by: Jan Fajerski <[email protected]>
@jan--f jan--f force-pushed the image-version-cli-args branch from 300696d to c6b064c Compare January 18, 2024 13:59
cmd/operator/main.go Outdated Show resolved Hide resolved
cmd/operator/main.go Outdated Show resolved Hide resolved
cmd/operator/main.go Outdated Show resolved Hide resolved
pkg/operator/operator.go Outdated Show resolved Hide resolved
@jan--f jan--f force-pushed the image-version-cli-args branch from eb4c6c8 to c3ff294 Compare January 18, 2024 14:58
// error.
func validateImages(images *k8sflag.MapStringString) (map[string]string, error) {
res := defaultImages
if !images.Empty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) fast path if no custom images are provided

Suggested change
if !images.Empty() {
if images.Empty() {
return res
}

imgs := *images.Map
for k, v := range imgs {
if _, ok := res[k]; !ok {
return nil, fmt.Errorf(fmt.Sprintf("image %v is unknown", k))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf(fmt.Sprintf("image %v is unknown", k))
return nil, fmt.Errorf("image %v is unknown", k)

Comment on lines 44 to 54
func imagesUsed() []string {
i := 0
imgs := make([]string, len(defaultImages))
for k := range defaultImages {
imgs[i] = k
i++
}
return imgs
}
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) ensure stable sort

Suggested change
func imagesUsed() []string {
i := 0
imgs := make([]string, len(defaultImages))
for k := range defaultImages {
imgs[i] = k
i++
}
return imgs
}
func imagesUsed() []string {
i := 0
imgs := make([]string, len(defaultImages))
for k := range defaultImages {
imgs[i] = k
i++
}
slices.Sortimgs)
return imgs
}

@jan--f jan--f force-pushed the image-version-cli-args branch from c3ff294 to 324db3c Compare January 18, 2024 16:06
@danielmellado
Copy link
Contributor

/lgtm

Copy link
Contributor

@danielmellado danielmellado left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

openshift-ci bot commented Jan 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielmellado, jan--f

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [danielmellado,jan--f]

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

@openshift-merge-bot openshift-merge-bot bot merged commit c0f54ae into rhobs:main Jan 18, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid hardcoded versions for Thanos components
8 participants