Skip to content

Commit

Permalink
Merge pull request #57 from uselagoon/admin-tenant-defaults
Browse files Browse the repository at this point in the history
fix: ensure the admin_tenant has global index patterns
  • Loading branch information
smlx authored Jun 2, 2023
2 parents e4c13d0 + fd364ea commit 3fbc029
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=180s
# temporarily pin the linter version until
# https://github.com/golangci/golangci-lint/issues/3862 is fixed
version: v1.52.2
commitlint:
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 4 additions & 2 deletions internal/sync/indexpatterns.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
indexNameInvalid = regexp.MustCompile(`[^a-z0-9]+`)
// specialTenants are not associated with a Lagoon group and receive just the
// globalIndexPatterns
specialTenants = []string{"global_tenant"}
specialTenants = []string{"global_tenant", "admin_tenant"}
)

// hashPrefix returns an Opensearch-index-name-sanitized copy of given a string
Expand Down Expand Up @@ -87,7 +87,9 @@ func calculateIndexPatternDiff(log *zap.Logger,
// calculate index patterns to delete
toDelete := map[string]map[string][]string{}
for index, patterns := range existing {
// ignore any custom index patterns created in the admin_tenant
// do not delete any custom index patterns created in the admin_tenant
// these are sometimes useful for administrators, and aren't visible to
// customers (they don't have access to the admin_tenant)
if index == hashPrefix("admin_tenant") {
continue
}
Expand Down
12 changes: 12 additions & 0 deletions internal/sync/indexpatterns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ func TestGenerateIndexPatterns(t *testing.T) {
`lagoon-logs-*`: true,
`router-logs-*`: true,
},
"admin_tenant": {
`application-logs-*`: true,
`container-logs-*`: true,
`lagoon-logs-*`: true,
`router-logs-*`: true,
},
},
},
"high-level test legacy group index patterns": {
Expand Down Expand Up @@ -480,6 +486,12 @@ func TestGenerateIndexPatterns(t *testing.T) {
`lagoon-logs-*`: true,
`router-logs-*`: true,
},
"admin_tenant": {
`application-logs-*`: true,
`container-logs-*`: true,
`lagoon-logs-*`: true,
`router-logs-*`: true,
},
},
},
}
Expand Down

0 comments on commit 3fbc029

Please sign in to comment.