Skip to content

Commit

Permalink
Merge branch 'upstream/master' into github/master
Browse files Browse the repository at this point in the history
* upstream/master:
  fix: change default CSP value (apache#2601)
  fix: ant-table unable to request (apache#2641)
  fix: plugin_config missing on service exist (apache#2657)
  feat: add etcd store auto re-initialize (apache#2650)
  feat: add login filter of OpenID-Connect (apache#2608)
  feat:Configure plug-ins to support this feature (apache#2647)
  feat: Adding a Loading state to buttons (apache#2630)
  feat: dashboard support windows (apache#2619)
  Feat: add tip and preset model for plugin editor, improve e2e stability (apache#2581)
  docs: add Slack invitation link badge (apache#2617)

# Conflicts:
#	.github/workflows/backend-cli-test.yml
#	Dockerfile
#	api/test/shell/cli_test.sh
#	web/src/components/Footer/index.tsx
#	web/src/components/RightContent/index.tsx
#	web/src/pages/ServerInfo/List.tsx
  • Loading branch information
hongbinhsu committed Nov 7, 2022
2 parents 98a924c + 8dcadce commit d6d38f3
Show file tree
Hide file tree
Showing 187 changed files with 2,876 additions and 1,034 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/backend-cli-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
etcd: [3.5.2]
services:
etcd:
image: bitnami/etcd:${{ matrix.etcd }}
ports:
- 2379:2379
- 2380:2380
env:
ALLOW_NONE_AUTHENTICATION: yes
etcd: [3.4.20]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: setup go
uses: actions/setup-go@v3
with:
go-version: '1.19'

- name: cache etcd
id: cache-etcd
uses: actions/cache@v3
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/backend-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: "1.18"
go-version: "1.19"

- uses: docker/setup-buildx-action@v2

Expand All @@ -44,6 +44,8 @@ jobs:
sed -i '[email protected]@0.0.0.0/0@' ./api/conf/conf.yaml
sed -i '/172.16.238.10:2379/a\ - 172.16.238.11:2379' ./api/conf/conf.yaml
sed -i '/172.16.238.10:2379/a\ - 172.16.238.12:2379' ./api/conf/conf.yaml
sed -i '[email protected]/0:[email protected]:9000@' ./api/conf/conf.yaml
- name: download file Dockerfile-apisix
working-directory: ./api/test/docker
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: '1.15'
go-version: '1.19'

- uses: actions/cache@v3
with:
Expand Down
36 changes: 14 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ========================================================================
# Commercial licenses
# ========================================================================
# Copyright (c) 2022 Shanghai UPTech Co., Ltd. all rights reserved
# ========================================================================
FROM alpine:latest as pre-build

ARG GATEMAN_VERSION=master

COPY . /usr/local/gateman
ARG APISIX_DASHBOARD_VERSION=master

RUN set -x \
&& apk add --no-cache --virtual .builddeps git \
&& cd /usr/local/gateman && git clean -Xdf \
&& git clone https://github.com/apache/apisix-dashboard.git -b ${APISIX_DASHBOARD_VERSION} /usr/local/apisix-dashboard \
&& cd /usr/local/apisix-dashboard && git clean -Xdf \
&& rm -f ./.githash && git log --pretty=format:"%h" -1 > ./.githash

# RUN rm -f .git .github .vscode docs output web/node_modules

FROM golang:1.15 as api-builder
FROM golang:1.19 as api-builder

ARG ENABLE_PROXY=false

WORKDIR /usr/local/gateman
WORKDIR /usr/local/apisix-dashboard

COPY --from=pre-build /usr/local/gateman .
COPY --from=pre-build /usr/local/apisix-dashboard .

RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w GOPROXY=https://goproxy.io,direct ; fi \
&& go env -w GO111MODULE=on \
&& CGO_ENABLED=0 ./api/build.sh

FROM node:14-alpine as fe-builder
FROM node:16-alpine as fe-builder

ARG ENABLE_PROXY=false

WORKDIR /usr/local/gateman
WORKDIR /usr/local/apisix-dashboard

COPY --from=pre-build /usr/local/gateman .
COPY --from=pre-build /usr/local/apisix-dashboard .

WORKDIR /usr/local/gateman/web
WORKDIR /usr/local/apisix-dashboard/web

RUN if [ "$ENABLE_PROXY" = "true" ] ; then yarn config set registry https://registry.npmmirror.com/ ; fi \
&& yarn install \
Expand All @@ -64,14 +56,14 @@ ARG ENABLE_PROXY=false

RUN if [ "$ENABLE_PROXY" = "true" ] ; then sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; fi

WORKDIR /usr/local/gateman
WORKDIR /usr/local/apisix-dashboard

COPY --from=api-builder /usr/local/gateman/output/ ./
COPY --from=api-builder /usr/local/apisix-dashboard/output/ ./

COPY --from=fe-builder /usr/local/gateman/output/ ./
COPY --from=fe-builder /usr/local/apisix-dashboard/output/ ./

RUN mkdir logs

EXPOSE 9000

CMD [ "/usr/local/gateman/manager-api" ]
CMD [ "/usr/local/apisix-dashboard/manager-api" ]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/apache/apisix-dashboard)](https://goreportcard.com/report/github.com/apache/apisix-dashboard)
[![DockerHub](https://img.shields.io/docker/pulls/apache/apisix-dashboard.svg)](https://hub.docker.com/r/apache/apisix-dashboard)
[![Cypress.io](https://img.shields.io/badge/tested%20with-Cypress-04C38E.svg)](https://www.cypress.io/)
[![Slack](https://badgen.net/badge/Slack/Join%20Apache%20APISIX?icon=slack)](https://apisix.apache.org/slack)

<p align="center">
<a href="https://apisix.apache.org/">Website</a> •
Expand Down
64 changes: 64 additions & 0 deletions api/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@
package cmd

import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"time"

"github.com/spf13/cobra"

"github.com/apisix/manager-api/internal/conf"
"github.com/apisix/manager-api/internal/core/server"
"github.com/apisix/manager-api/internal/core/storage"
"github.com/apisix/manager-api/internal/core/store"
"github.com/apisix/manager-api/internal/log"
)

Expand Down Expand Up @@ -66,13 +70,17 @@ func manageAPI() error {
errSig := make(chan error, 5)
s.Start(errSig)

// start etcd connection checker
stopEtcdConnectionChecker := etcdConnectionChecker()

// Signal received to the process externally.
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)

select {
case sig := <-quit:
log.Infof("The Manager API server receive %s and start shutting down", sig.String())
stopEtcdConnectionChecker()
s.Stop()
log.Infof("See you next time!")
case err := <-errSig:
Expand All @@ -81,3 +89,59 @@ func manageAPI() error {
}
return nil
}

func etcdConnectionChecker() context.CancelFunc {
ctx, cancel := context.WithCancel(context.TODO())
unavailableTimes := 0

go func() {
etcdClient := storage.GenEtcdStorage().GetClient()
for {
select {
case <-time.Tick(10 * time.Second):
sCtx, sCancel := context.WithTimeout(ctx, 5*time.Second)
err := etcdClient.Sync(sCtx)
sCancel()
if err != nil {
unavailableTimes++
log.Errorf("etcd connection loss detected, times: %d", unavailableTimes)
continue
}

// After multiple failures, the connection is restored
if unavailableTimes >= 1 {
log.Warnf("etcd connection recovered, but after several connection losses, reinitializing stores, times: %d", unavailableTimes)
unavailableTimes = 0

// When this happens, force a full re-initialization of the store
store.RangeStore(func(key store.HubKey, store *store.GenericStore) bool {
log.Warnf("etcd store reinitializing: resource: %s", key)
if err := store.Init(); err != nil {
log.Errorf("etcd store reinitialize failed: resource: %s, error: %s", key, err)
}
return true
})
} else {
log.Info("etcd connection is fine")
}
case <-ctx.Done():
return
}
}
}()

// Timed re-initialization when etcd watch actively exits
go func() {
for {
select {
case <-time.Tick(2 * time.Minute):
err := store.ReInit()
if err != nil {
log.Errorf("resource re-initialize failed, err: %v", err)
}
}
}
}()

return cancel
}
14 changes: 8 additions & 6 deletions api/conf/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ conf:
# access_control_allow_headers: "Authorization"
# access_control-allow_methods: "*"
# x_frame_options: "deny"
# content_security_policy: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; frame-src xx.xx.xx.xx:3000" # You can set frame-src to provide content for your grafana panel.
# content_security_policy: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; frame-src xx.xx.xx.xx:3000" # You can set frame-src to provide content for your grafana panel.

authentication:
secret:
Expand All @@ -82,11 +82,13 @@ authentication:

oidc:
expire_time: 3600
app_name: authing
client_id:
client_secret:
scope: oidc
redirect_uri: oidc/callback
client_id: dashboard
client_secret: dashboard
auth_url: http://172.17.0.1:8080/auth/realms/master/protocol/openid-connect/auth
token_url: http://172.17.0.1:8080/auth/realms/master/protocol/openid-connect/token
user_info_url: http://172.17.0.1:8080/auth/realms/master/protocol/openid-connect/userinfo
redirect_url: http://127.0.0.1:9000/apisix/admin/oidc/callback
scope: openid

plugins: # plugin list (sorted in alphabetical order)
- api-breaker
Expand Down
32 changes: 8 additions & 24 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,30 @@ module github.com/apisix/manager-api

go 1.15

replace google.golang.org/grpc => google.golang.org/grpc v1.26.0

replace github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5

require (
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.25+incompatible // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/coreos/go-oidc/v3 v3.3.0
github.com/evanphx/json-patch/v5 v5.1.0
github.com/getkin/kin-openapi v0.33.0
github.com/gin-contrib/gzip v0.0.3
github.com/gin-contrib/static v0.0.0-20200916080430-d45d9a37d28e
github.com/gin-gonic/gin v1.6.3
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/gorilla/sessions v1.2.1
github.com/juliangruber/go-intersect v1.1.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.8.0 // indirect
github.com/satori/go.uuid v1.2.0
github.com/shiningrush/droplet v0.2.6-0.20210127040147-53817015cd1b
github.com/shiningrush/droplet/wrapper/gin v0.2.1
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/sony/sonyflake v1.0.0
github.com/spf13/cobra v0.0.3
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1
github.com/tidwall/gjson v1.6.7
github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966 // indirect
github.com/xeipuuv/gojsonschema v1.2.0
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
go.etcd.io/etcd v3.3.25+incompatible
go.etcd.io/etcd/client/pkg/v3 v3.5.5
go.etcd.io/etcd/client/v3 v3.5.5
go.uber.org/zap v1.17.0
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094
)
Loading

0 comments on commit d6d38f3

Please sign in to comment.