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

fix: Add struct-wide RWMutex to metrics #3421

Merged
merged 1 commit into from Jul 8, 2020
Merged

Conversation

simster7
Copy link
Member

@simster7 simster7 commented Jul 8, 2020

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed the CLA.
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

@simster7 simster7 changed the title fix: Add struct-wide RWMutext to metrics fix: Add struct-wide RWMutex to metrics Jul 8, 2020
return
}
m.WorkflowDeleted(key, fromPhase)
m.WorkflowAdded(key, toPhase)
if _, ok := m.workflowsByPhase[fromPhase]; ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this copy-and-paste? maybe make private func which does not lock?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not quite copy-and-paste, there is some logic that would be redundant if we go with the private func approach; mainly, we will remove and readd the key from the map and perform an additional check unnecessarily. I actually think this is simpler and easier to understand.

However, I don't feel strongly and would gladly go with the private func approach if you think it's necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

we should just make sure that if we need to make changes in two places - we are aware of it

@alexec
Copy link
Contributor

alexec commented Jul 8, 2020

it's like in Java when you add synchronised to everything

@simster7 simster7 marked this pull request as ready for review July 8, 2020 19:25
@simster7 simster7 requested a review from alexec July 8, 2020 20:31
@simster7 simster7 merged commit 733e95f into argoproj:master Jul 8, 2020
@@ -77,6 +77,9 @@ func New(metricsConfig, telemetryConfig ServerConfig) *Metrics {
}

func (m *Metrics) allMetrics() []prometheus.Metric {
m.mutex.RLock()
Copy link
Member

Choose a reason for hiding this comment

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

will it handle concurrent read and write on map?

Copy link
Member

Choose a reason for hiding this comment

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

there is a synchronized map in golang.
https://golang.org/pkg/sync/#Map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v2.9.0 workflow-controller OOM Killed
3 participants