Skip to content

Conversation

afzal442
Copy link

@afzal442 afzal442 commented May 6, 2025

@afzal442 afzal442 force-pushed the fix-ncspawns-22800 branch from c0feb28 to bb8f471 Compare May 6, 2025 08:48
@afzal442
Copy link
Author

afzal442 commented May 6, 2025

@blakepettersson if I try to pass in those numbers as parameters to the NewTransport function, there will be a lot of services to be changed/ get impacted. Any input plz.

@blakepettersson
Copy link
Member

@afzal442 yes indeed, but I don't think it's a bad idea to be allowed to set those http settings for any service that make use of it.

So we can expand this task to allow all affected services to set these http.Transport settings. You'll need to add relevant fields for all the *Options structs that could make use of these settings.

Copy link

codecov bot commented May 9, 2025

Codecov Report

Attention: Patch coverage is 28.57143% with 65 lines in your changes missing coverage. Please review.

Project coverage is 54.61%. Comparing base (f485671) to head (99f8af3).
Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/opsgenie.go 0.00% 8 Missing ⚠️
pkg/services/alertmanager.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/github.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/googlechat.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/grafana.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/mattermost.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/newrelic.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/teams.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/webex.go 25.00% 5 Missing and 1 partial ⚠️
pkg/services/webhook.go 25.00% 5 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #376      +/-   ##
==========================================
- Coverage   55.35%   54.61%   -0.74%     
==========================================
  Files          35       46      +11     
  Lines        3438     4202     +764     
==========================================
+ Hits         1903     2295     +392     
- Misses       1256     1562     +306     
- Partials      279      345      +66     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@afzal442 afzal442 requested a review from blakepettersson May 12, 2025 07:41
@afzal442 afzal442 force-pushed the fix-ncspawns-22800 branch from 800ebff to d3dfddf Compare May 12, 2025 07:54
@blakepettersson
Copy link
Member

@afzal442 can you

  1. Update the docs for all of these options
  2. Verify that this works from Argo CD?

@afzal442
Copy link
Author

afzal442 commented May 12, 2025

To verify this further, do I need to create instances and check against it using argocd CLI locally on this branch?

@blakepettersson
Copy link
Member

blakepettersson commented May 13, 2025

So you'll need to setup a local copy of Argo CD.

You'll need to configure go.mod to replace notifications-engine with your own version, e.g.

github.com/argoproj/gitops-engine => github.com/afzal442/notifications-engine <your latest commit on this PR>

then run go mod tidy. Then run your local version of Argo CD and verify that this works as intended.

Ideally we should check that setting up notifications both work without setting the new fields as well as by setting the new fields (to ensure we haven't broken anything).

@afzal442
Copy link
Author

go mod tidy

go: downloading github.com/argoproj/notifications-engine v0.4.1-0.20250309174002-87bf0576a872
go: github.com/argoproj/argo-cd/v3/cmd/argocd/commands imports
        github.com/argoproj/gitops-engine/pkg/health: github.com/afzal442/[email protected]: parsing go.mod:
        module declares its path as: github.com/argoproj/notifications-engine
                but was required as: github.com/afzal442/notifications-engine

@blakepettersson
Copy link
Member

blakepettersson commented Jun 2, 2025

@afzal442 what does your go.mod look like?

You should have a go.mod which looks something like this (look at the very bottom of go.mod to see where all the replaces happen)

module github.com/argoproj/argo-cd/v3

go 1.24.3

require (
	github.com/argoproj/notifications-engine v0.4.1-0.20250309174002-87bf0576a872
        // Other requires snipped for brevity
)

// Other requires snipped for brevity

replace (
	github.com/argoproj/notifications-engine => github.com/afzal442/notifications-engine d3dfddfec1fb8b2e9ce7af27317d42e880aa676a
        // Other replaces snipped for brevity
)

Once it looks like that, you can run go mod tidy which will fix the dependency tree for you.

@afzal442
Copy link
Author

afzal442 commented Jun 2, 2025

Ideally we should check that setting up notifications both work without setting the new fields as well as by setting the new fields

Thanks! but any help on how I can set up notifications with setting the new fields. Do I need to setup Github notification svc? any further test?

Copy link
Member

@blakepettersson blakepettersson left a comment

Choose a reason for hiding this comment

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

Hey @afzal442, sorry for the (very) late review 😞

I gave this a spin and it generally LGTM, with the exception that duration strings cannot be directly parsed with Golang's JSON parser (that's on me, I thought that worked). So basically you will need to use strings and handle the conversions manually.

There's also a minor section where the wrong parameter is used.

Beyond that, could we get some docs documenting these values where applicable? Otherwise LGTM!

@afzal442
Copy link
Author

@blakepettersson
Copy link
Member

@afzal442 yes, before parsing the conn timeouts you need to check if the conn timeout is an empty string. If it's empty don't parse

@afzal442 afzal442 force-pushed the fix-ncspawns-22800 branch 2 times, most recently from 40c5811 to 9854d6e Compare July 10, 2025 18:31
@afzal442
Copy link
Author

could we get some docs documenting these values where applicable?

How about making a separate PR for this?

@blakepettersson
Copy link
Member

How about making a separate PR for this?

@afzal442, no these changes need to be documented in this PR, given that there are a bunch of parameters which are important to know about.

@afzal442 afzal442 force-pushed the fix-ncspawns-22800 branch 3 times, most recently from 0e908bc to 0da98d1 Compare July 14, 2025 11:40
@afzal442 afzal442 force-pushed the fix-ncspawns-22800 branch from 037ea8b to 01a91bd Compare July 14, 2025 19:16
@afzal442 afzal442 force-pushed the fix-ncspawns-22800 branch 2 times, most recently from 43bc138 to 493a8e1 Compare July 15, 2025 18:04
@afzal442 afzal442 requested a review from blakepettersson July 16, 2025 06:57
@blakepettersson
Copy link
Member

@afzal442 this looks good to me in general

Before merging this, I believe you should do the following:

  1. Ask in the #argocd-contributors channel about this feature - for me this seems good, but would like to have some consensus before merging
  2. Assuming you get a 👍, that we try to get in some unit tests exercising the conversions from string -> duration

@pasha-codefresh
Copy link
Member

Looks good, but i would try to move transport creation in single place, otherwise we need to duplicate it in every provider

@blakepettersson
Copy link
Member

@afzal442 do you have further thoughts regarding what Pasha said?

@afzal442
Copy link
Author

sure! I think that makes sense. But I'll need to apply the suggestions it in order to check this.

@afzal442
Copy link
Author

I tried moving the transport as a new helper function like below, but need your thoughts whether that is feasible; I'd create this inside transport.go and use it as a helper

func NewServiceHTTPClient(serviceName, webhookUrl string, maxIdleConns, maxIdleConnsPerHost, maxConnsPerHost int, idleConnTimeout time.Duration, insecureSkipVerify bool) *http.Client {
	transport := NewTransport(webhookUrl, maxIdleConns, maxIdleConnsPerHost, maxConnsPerHost, idleConnTimeout, insecureSkipVerify)
	return &http.Client{
		Transport: NewLoggingRoundTripper(transport, log.WithField("service", serviceName)),
	}
}

cc @blakepettersson @pasha-codefresh

@blakepettersson
Copy link
Member

@afzal442 yes, something like this should work

func NewServiceHTTPClient(maxIdleConns, maxIdleConnsPerHost, maxConnsPerHost int, idleConnTimeout, serviceName string, insecureSkipVerify bool, apiURL string) (client *http.Client, err error) {
	var timeout time.Duration
	if idleConnTimeout != "" {
		timeout, err = time.ParseDuration(idleConnTimeout)
		if err != nil {
			return nil, fmt.Errorf("failed to parse idle connection timeout: %w", err)
		}
	}
	transport := httputil.NewTransport(apiURL, maxIdleConns, maxIdleConnsPerHost, maxConnsPerHost, timeout, insecureSkipVerify)
	return &http.Client{
		Transport: httputil.NewLoggingRoundTripper(transport, log.WithField("service", serviceName)),
	}, nil
}

afzal442 and others added 18 commits August 29, 2025 19:07
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
* Adding info about template

Signed-off-by: lrochette <[email protected]>

* signing off

Signed-off-by: lrochette <[email protected]>

---------

Signed-off-by: lrochette <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
There's a major upgrade of it. This is an initial upgrade to make the
changes as minimal as possible.

Signed-off-by: Blake Pettersson <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Try to slowly converge towards what exists on argo-cd.

Signed-off-by: Blake Pettersson <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
@afzal442 afzal442 force-pushed the fix-ncspawns-22800 branch from 74f642c to 57306f0 Compare August 29, 2025 19:07
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.

4 participants