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

chore: remove v1 reporter #327

Merged
merged 11 commits into from
Aug 19, 2024
61 changes: 0 additions & 61 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4056,52 +4056,6 @@
}
}
},
"/api/v1/stream/events": {
"get": {
"tags": [
"Eventing"
],
"operationId": "Eventing_StartEventSource",
"parameters": [
{
"type": "string",
"description": "The event source name.",
"name": "name",
"in": "query"
},
{
"type": "string",
"format": "byte",
"description": "The event source configuration value.",
"name": "config",
"in": "query"
}
],
"responses": {
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"type": "object",
"title": "Stream result of genericEvent",
"properties": {
"error": {
"$ref": "#/definitions/runtimeStreamError"
},
"result": {
"$ref": "#/definitions/genericEvent"
}
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/runtimeError"
}
}
}
}
},
"/api/version": {
"get": {
"tags": [
Expand Down Expand Up @@ -4790,21 +4744,6 @@
}
}
},
"genericEvent": {
"type": "object",
"title": "*\nRepresents an event",
"properties": {
"name": {
"description": "The event source name.",
"type": "string"
},
"payload": {
"description": "The event payload.",
"type": "string",
"format": "byte"
}
}
},
"gpgkeyGnuPGPublicKeyCreateResponse": {
"type": "object",
"title": "Response to a public key creation request",
Expand Down
2 changes: 1 addition & 1 deletion changelog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
### Chore
- chore: selfheal should work with monorepo additional logs
- chore: removed v1 reporter
2 changes: 1 addition & 1 deletion controller/appcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,7 @@ func TestAlreadyAttemptSync(t *testing.T) {
t.Run("different manifest with sync result, with enabled flag", func(t *testing.T) {

_ = os.Setenv("PERSIST_CHANGE_REVISIONS", "1")

attempted, _ := alreadyAttemptedSync(app, "sha", []string{}, false, nil)
assert.False(t, attempted)
})
Expand Down
48 changes: 42 additions & 6 deletions docs/operator-manual/notifications/services/opsgenie.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,58 @@ To be able to send notifications with argocd-notifications you have to create an
3. Click "Teams" in the Menu on the left
4. Select the team that you want to notify
5. In the teams configuration menu select "Integrations"
6. click "Add Integration" in the top right corner
6. Click "Add Integration" in the top right corner
7. Select "API" integration
8. Give your integration a name, copy the "API key" and safe it somewhere for later
9. Make sure the checkboxes for "Create and Update Access" and "enable" are selected, disable the other checkboxes to remove unnecessary permissions
10. Click "Safe Integration" at the bottom
11. Check your browser for the correct server apiURL. If it is "app.opsgenie.com" then use the US/international api url `api.opsgenie.com` in the next step, otherwise use `api.eu.opsgenie.com` (European API).
12. You are finished with configuring opsgenie. Now you need to configure argocd-notifications. Use the apiUrl, the team name and the apiKey to configure the Opsgenie integration in the `argocd-notifications-secret` secret.
9. Click "Edit" in the integration settings
10. Make sure the checkbox for "Create and Update Access" is selected, disable the other checkboxes to remove unnecessary permissions
11. Click "Save" at the bottom
12. Click "Turn on integration" in the top right corner
13. Check your browser for the correct server apiURL. If it is "app.opsgenie.com" then use the US/international api url `api.opsgenie.com` in the next step, otherwise use `api.eu.opsgenie.com` (European API).
14. You are finished with configuring Opsgenie. Now you need to configure argocd-notifications. Use the apiUrl, the team name and the apiKey to configure the Opsgenie integration in the `argocd-notifications-secret` secret.
15. You can find the example `argocd-notifications-cm` configuration at the below.

| **Option** | **Required** | **Type** | **Description** | **Example** |
| ------------- | ------------ | -------- | -------------------------------------------------------------------------------------------------------- | -------------------------------- |
| `description` | True | `string` | Description field of the alert that is generally used to provide a detailed information about the alert. | `Hello from Argo CD!` |
| `priority` | False | `string` | Priority level of the alert. Possible values are P1, P2, P3, P4 and P5. Default value is P3. | `P1` |
| `alias` | False | `string` | Client-defined identifier of the alert, that is also the key element of Alert De-Duplication. | `Life is too short for no alias` |
| `note` | False | `string` | Additional note that will be added while creating the alert. | `Error from Argo CD!` |

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: <config-map-name>
name: argocd-notifications-cm
data:
service.opsgenie: |
apiUrl: <api-url>
apiKeys:
<your-team>: <integration-api-key>
template.opsgenie: |
message: |
[Argo CD] Application {{.app.metadata.name}} has a problem.
opsgenie:
description: |
Application: {{.app.metadata.name}}
Health Status: {{.app.status.health.status}}
Operation State Phase: {{.app.status.operationState.phase}}
Sync Status: {{.app.status.sync.status}}
priority: P1
alias: {{.app.metadata.name}}
note: Error from Argo CD!
trigger.on-a-problem: |
- description: Application has a problem.
send:
- opsgenie
when: app.status.health.status == 'Degraded' or app.status.operationState.phase in ['Error', 'Failed'] or app.status.sync.status == 'Unknown'
```
16. Add annotation in application yaml file to enable notifications for specific Argo CD app.
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscribe.on-a-problem.opsgenie: <your-team>
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package application
package reporter

import (
"fmt"
Expand Down
5 changes: 0 additions & 5 deletions event_reporter/reporter/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ func (b *broadcasterHandler) notify(event *appv1.ApplicationWatchEvent) {
subscribers = append(subscribers, b.subscribers...)
b.lock.Unlock()

if !b.featureManager.ShouldReporterRun() {
log.Infof("filtering application '%s', event reporting is turned off and old one is in use", event.Application.Name)
return
}

if b.filter != nil {
result, expectedShard := b.filter(&event.Application)
if !result {
Expand Down
27 changes: 0 additions & 27 deletions event_reporter/reporter/feature_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,12 @@ package reporter

import (
settings_util "github.com/argoproj/argo-cd/v2/util/settings"
log "github.com/sirupsen/logrus"
"time"
)

type FeatureManager struct {
settingsMgr *settings_util.SettingsManager
shouldRun bool
}

func NewFeatureManager(settingsMgr *settings_util.SettingsManager) *FeatureManager {
return &FeatureManager{settingsMgr: settingsMgr}
}

func (f *FeatureManager) setShouldRun() {
reporterVersion, err := f.settingsMgr.GetCodefreshReporterVersion()
if err != nil {
log.Warnf("Failed to get reporter version: %v", err)
f.shouldRun = false
return
}
f.shouldRun = reporterVersion == string(settings_util.CodefreshV2ReporterVersion)
}

func (f *FeatureManager) Watch() {
f.setShouldRun()
// nolint:staticcheck
tick := time.Tick(5 * time.Second)
for {
<-tick
f.setShouldRun()
}
}

func (f *FeatureManager) ShouldReporterRun() bool {
return f.shouldRun
}
1 change: 0 additions & 1 deletion event_reporter/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func (a *EventReporterServer) healthCheck(r *http.Request) error {
// Init starts informers used by the API server
func (a *EventReporterServer) Init(ctx context.Context) {
go a.appInformer.Run(ctx.Done())
go a.featureManager.Watch()
svcSet := newEventReporterServiceSet(a)
a.serviceSet = svcSet
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ require (
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fvbommel/sortorder v1.0.1 // indirect
github.com/ghodss/yaml v1.0.0
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
Expand Down
Loading
Loading