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
Remove context field from structs #1290
Remove context field from structs #1290
Conversation
/retest |
@fpetkovski Could you please review? |
cmd/operator/main.go
Outdated
@@ -203,7 +203,7 @@ func Main() int { | |||
|
|||
wg, ctx := errgroup.WithContext(ctx) | |||
|
|||
wg.Go(func() error { return o.Run(ctx.Done()) }) | |||
wg.Go(func() error { return o.Run(ctx, ctx.Done()) }) |
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 would rather change the signature of Run() since it could use ctx.Done()
wg.Go(func() error { return o.Run(ctx, ctx.Done()) }) | |
wg.Go(func() error { return o.Run(ctx) }) |
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.
Is operator.Run
trying to satisfy an interface that has Run(ctx, stopCh <-struct{})
?
@@ -143,7 +142,7 @@ func New(kubeConfigPath string) (*Framework, cleanUpFunc, error) { | |||
// Prometheus client depends on setup above. | |||
f.ThanosQuerierClient, err = NewPrometheusClientFromRoute( | |||
openshiftRouteClient, | |||
f.Ctx, | |||
ctx, |
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.
(nit) to follow the conventions, ctx
should be the first argument.
pkg/client/status_reporter.go
Outdated
namespace string | ||
userWorkloadNamespace string | ||
version string | ||
} | ||
|
||
func NewStatusReporter(ctx context.Context, client clientv1.ClusterOperatorInterface, name string, namespace, userWorkloadNamespace, version string) *StatusReporter { | ||
func NewStatusReporter(client clientv1.ClusterOperatorInterface, name string, namespace, userWorkloadNamespace, version string) *StatusReporter { |
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.
nit: name string,
-> name
func (o *Operator) worker() { | ||
for o.processNextWorkItem() { | ||
func (o *Operator) worker(ctx context.Context) { | ||
for o.processNextWorkItem(ctx) { |
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.
@simonpasquier I am guessing that if the context gets cancelled, the next work item be processed. Could you please confirm my hunch?
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.
good catch! yes I agree that we should verify whether the context has been cancelled before processing the next item.
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.
at the same time, Run()
currently doesn't wait for any of the goroutines to stop before exiting so it would need to be addressed not only for worker()
IMHO. I'm ok with having a follow-up PR to "fix" this.
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.
The changes looks good to me but I think we need a test that validates the expected behaviour if a context is cancelled
WDYT @slashpai @simonpasquier ?
43cb6ac
to
09ea227
Compare
unavailableMessage string = "Rollout of the monitoring stack failed and is degraded. Please investigate the degraded status error." | ||
asExpectedReason string = "AsExpected" | ||
StorageNotConfiguredMessage = "Prometheus is running without persistent storage which can lead to data loss during upgrades and cluster disruptions. Please refer to the official documentation to see how to configure storage for Prometheus: https://docs.openshift.com/container-platform/4.8/monitoring/configuring-the-monitoring-stack.html" | ||
StorageNotConfiguredReason = "PrometheusDataPersistenceNotConfigured" |
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 was changed when ran go fmt
I couldn't think of an easy way to test this so I'm fine without it. |
@slashpai could you rebase? |
Sure I will get that done when login tomorrow. Are we good with the changes or anymore changes are needed? |
091baa8
to
1fee8df
Compare
@simonpasquier rebased |
/lgtm |
/hold for @simonpasquier's final review |
5a60e3f
to
0978718
Compare
/lgtm |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fpetkovski, simonpasquier, slashpai 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:
Approvers can indicate their approval by writing |
/retest |
/hold cancel |
Following the discussion in slack we need to remove context from struct field. Removing the context from struct field and passing it as first argument to functions that require it