Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
naughtyGitCat authored Sep 1, 2023
2 parents 1cdf1a6 + 4aca88d commit d2fb77d
Show file tree
Hide file tree
Showing 66 changed files with 2,607 additions and 1,260 deletions.
59 changes: 28 additions & 31 deletions .github/check-license.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// mongodb_exporter
// Copyright (C) 2017 Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// http://www.apache.org/licenses/LICENSE-2.0
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build ignore
// +build ignore

// check-license checks that AGPL license header in all files matches header in this file.
// check-license checks that Apache 2.0 header in all files matches header in this file.
package main

import (
Expand All @@ -36,35 +35,33 @@ var (
copyrightText = `// mongodb_exporter
// Copyright (C) 2022 Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// http://www.apache.org/licenses/LICENSE-2.0
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
`

copyrightPattern = regexp.MustCompile(`^// mongodb_exporter
// Copyright \(C\) 20\d{2} Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// \(at your option\) any later version.
// Licensed under the Apache License, Version 2\.0 \(the "License"\);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// http://www\.apache\.org/licenses/LICENSE-2\.0
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
// See the License for the specific language governing permissions and
// limitations under the License\.
`)
)

Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ updates:
directory: "/tools"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
- [ ] Update jira ticket description if needed.
- [ ] Attach screenshots/console output to confirm new behavior to jira ticket, if applicable.

Once all checks pass and the code is ready for review, please add `pmm-review-exporters` team as the reviewer. That would assign people from the review team automatically. Report any issues on our [Forum](https://forums.percona.com) or [Discord](https://per.co.na/discord).
Once all checks pass and the code is ready for review, please add `pmm-review-exporters` team as the reviewer. That would assign people from the review team automatically. Report any issues on our [Forum](https://forums.percona.com).
56 changes: 8 additions & 48 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Go
on:
schedule:
# run every Sunday
- cron: "0 13 * * 0"
- cron: '0 13 * * 0'
push:
branches:
- main
Expand All @@ -19,67 +19,27 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version:
- 1.17.x
image:
- mongo:4.2
- mongo:4.4
- mongo:5.0
- percona/percona-server-mongodb:4.2
- percona/percona-server-mongodb:4.4
- percona/percona-server-mongodb:5.0
os: [ubuntu-latest]
may-fail: [false]

include:
# test only one image on tip to detect major Go changes earlier
# without wasting too much time on CI
- go-version: tip
image: mongo:4.4
os: ubuntu-latest
may-fail: true

continue-on-error: ${{ matrix.may-fail }}
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:
- name: Set up Go release
if: matrix.go-version != 'tip'
uses: percona-platform/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Set up Go tip
if: matrix.go-version == 'tip'
run: |
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
cd $HOME/gotip/src
./make.bash
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH
- name: Check out code into the Go module directory
uses: percona-platform/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Initialize dependencies and linters
run: |
make init
- name: Diff
if: startsWith( ${{ matrix.go-version }}, '1.17')
run: |
make format
git diff --exit-code
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: ${{ github.workspace }}/go.mod

- name: Test
run: |
TEST_MONGODB_IMAGE=${{ matrix.image }} make test-cluster
make test-race
make test-cluster-clean
- name: Run checks/linters
run: |
# use GITHUB_TOKEN because only it has access to GitHub Checks API
bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
make check-license
42 changes: 42 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint

on:
schedule:
# run every Sunday
- cron: '0 13 * * 0'
push:
branches:
- main
- release-0.1x
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:

jobs:
lint:
name: Lint Check

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: ${{ github.workspace }}/go.mod

- name: Initialize dependencies and linters
run: make init

- name: Diff
run: |
make format
git diff --exit-code
- name: Run checks/linters
run: |
# use GITHUB_TOKEN because only it has access to GitHub Checks API
bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
make check-license
36 changes: 16 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,43 @@ on:
- v*
# manually trigger the release
workflow_dispatch:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: percona-platform/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Set up Go
uses: percona-platform/setup-go@v2

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.17
-
name: Login to Docker Hub
uses: percona-platform/login-action@v2
go-version-file: ${{ github.workspace }}/go.mod

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Login to GitHub Container Registry
uses: percona-platform/login-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

-
name: Set up Docker Buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

-
name: Run GoReleaser
uses: percona-platform/goreleaser-action@v3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ bin
build
dist
mongodb_exporter
.DS_Store
11 changes: 11 additions & 0 deletions .golangci-required.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---
linters-settings:
# prevent import of "errors" instead of "github.com/pkg/errors"
depguard:
rules:
# Name of a rule.
main:
# Packages that are not allowed where the value is a suggestion.
deny:
- pkg: "errors"
desc: Should be replaced by github.com/pkg/errors package

# The most valuable linters; they are required to pass for PR to be merged.
linters:
disable-all: true
Expand Down
19 changes: 11 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
linters-settings:
# prevent import of "errors" instead of "github.com/pkg/errors"
depguard:
list-type: blacklist
include-go-root: true
packages:
- errors
rules:
# Name of a rule.
main:
# Packages that are not allowed where the value is a suggestion.
deny:
- pkg: "errors"
desc: Should be replaced by github.com/pkg/errors package

lll:
line-length: 140
Expand All @@ -31,10 +34,10 @@ linters:
- wsl
- exhaustivestruct
- varnamelen
- maligned //deprecated
- scopelint //deprecated
- golint //deprecated
- interfacer //deprecated
- maligned #deprecated
- scopelint #deprecated
- golint #deprecated
- interfacer #deprecated
issues:
exclude-use-default: false
exclude:
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ nfpms:
type: "config|noreplace"
- src: .scripts/default/mongodb_exporter.example
dst: /etc/default/mongodb_exporter.example
- src: LICENSE
dst: /usr/share/doc/mongodb_exporter/LICENSE
4 changes: 2 additions & 2 deletions .scripts/systemd/mongodb_exporter.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ After=network.target
[Service]
Type=simple

User=pmm
Group=pmm
User=mongodb_exporter
Group=nogroup

EnvironmentFile=-/etc/default/mongodb_exporter
ExecStart=/usr/bin/mongodb_exporter $OPTIONS
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
Release 0.39.0

- Fixed issue with connection to authenticated MongoDB Arbiter
- Update dependencies

Release 0.38.0

- Fixed setting auth options for connection to MongoDB

Release 0.37.0

- Disable creating metric mongodb_mongod_storage_engine when it's not possible to retrieve (for example for mongos type of instance)
- Update dependencies

Release 0.36.0

- Added security metrics with info about encryption
- Fixed fetching build info for mongos instance
- Fix metric mongodb_mongos_sharding_balancer_enabled

Release 0.35.0

- Added to metrics info about running MongoDB version and Mongo vendor
- Removed unused collector

Release 0.34.0

- Add logger with level
Expand Down
Loading

0 comments on commit d2fb77d

Please sign in to comment.