You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/02/03 01:24:29 UTC

[GitHub] [apisix-dashboard] imjoey commented on a change in pull request #1408: feat: support return the manager api's git hash and version

imjoey commented on a change in pull request #1408:
URL: https://github.com/apache/apisix-dashboard/pull/1408#discussion_r569036244



##########
File path: api/internal/handler/tool/tool.go
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+package tool
+
+import (
+	"github.com/apisix/manager-api/internal/handler"
+	"github.com/apisix/manager-api/internal/utils"
+	"github.com/gin-gonic/gin"
+	"github.com/shiningrush/droplet"
+	wgin "github.com/shiningrush/droplet/wrapper/gin"
+)
+
+type Handler struct {
+}
+
+type InfoOutput struct {
+	Hash    string `json:"commit_hash"`
+	Version string `json:"version"`
+}
+
+func NewHandler() (handler.RouteRegister, error) {
+	return &Handler{}, nil
+}
+
+func (h *Handler) ApplyRoute(r *gin.Engine) {
+	r.GET("/info", wgin.Wraps(h.Info))

Review comment:
       I would prefer `/version` for now.
   Just FYI, `version` indicates the details about the distribution of manager-api binary, such as `OS`, `Arch`, `Go version`, `API version` and etc. `info` indicates the status and metrics of the running manager-api binary, such as `connections`, `memory usage` and etc. 
   
   Please see the output `docker version` and `docker info` for examples. Maybe we could follow that. 😄 
   
   ```
   ➜  apisix-dashboard git:(master) docker version
   Client: Docker Engine - Community
    Cloud integration: 1.0.7
    Version:           20.10.2
    API version:       1.41
    Go version:        go1.13.15
    Git commit:        2291f61
    Built:             Mon Dec 28 16:12:42 2020
    OS/Arch:           darwin/amd64
    Context:           default
    Experimental:      true
   
   Server: Docker Engine - Community
    Engine:
     Version:          20.10.2
     API version:      1.41 (minimum version 1.12)
     Go version:       go1.13.15
     Git commit:       8891c58
     Built:            Mon Dec 28 16:15:28 2020
     OS/Arch:          linux/amd64
     Experimental:     false
    containerd:
     Version:          1.4.3
     GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
    runc:
     Version:          1.0.0-rc92
     GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
    docker-init:
     Version:          0.19.0
     GitCommit:        de40ad0
   ```
   
   ```
   ➜  apisix-dashboard git:(master) docker info
   Client:
    Context:    default
    Debug Mode: false
    Plugins:
     app: Docker App (Docker Inc., v0.9.1-beta3)
     buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
     scan: Docker Scan (Docker Inc., v0.5.0)
   
   Server:
    Containers: 9
     Running: 8
     Paused: 0
     Stopped: 1
    Images: 36
    Server Version: 20.10.2
    Storage Driver: overlay2
     Backing Filesystem: extfs
     Supports d_type: true
     Native Overlay Diff: true
    Logging Driver: json-file
    Cgroup Driver: cgroupfs
    Cgroup Version: 1
    Plugins:
     Volume: local
     Network: bridge host ipvlan macvlan null overlay
     Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
    Swarm: inactive
    Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
    Default Runtime: runc
    Init Binary: docker-init
    containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
    runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
    init version: de40ad0
    Security Options:
     seccomp
      Profile: default
    Kernel Version: 4.19.121-linuxkit
    Operating System: Docker Desktop
    OSType: linux
    Architecture: x86_64
    CPUs: 6
    Total Memory: 1.943GiB
    Name: docker-desktop
    ID: E2J3:HRSM:RBMG:UQ4R:ASEK:GBXM:G5FG:KYI4:WZPM:SDQI:L7GF:EYFJ
    Docker Root Dir: /var/lib/docker
    Debug Mode: false
    HTTP Proxy: gateway.docker.internal:3128
    HTTPS Proxy: gateway.docker.internal:3129
    Registry: https://index.docker.io/v1/
    Labels:
    Experimental: false
    Insecure Registries:
     127.0.0.0/8
    Live Restore Enabled: false
   ```

##########
File path: api/internal/handler/tool/tool.go
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+package tool
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/shiningrush/droplet"
+	wgin "github.com/shiningrush/droplet/wrapper/gin"
+
+	"github.com/apisix/manager-api/internal/handler"
+	"github.com/apisix/manager-api/internal/utils"
+)
+
+type Handler struct {
+}
+
+type InfoOutput struct {
+	Hash    string `json:"commit_hash"`
+	Version string `json:"version"`
+}
+
+func NewHandler() (handler.RouteRegister, error) {
+	return &Handler{}, nil
+}
+
+func (h *Handler) ApplyRoute(r *gin.Engine) {
+	r.GET("/info", wgin.Wraps(h.Info))
+}
+
+func (h *Handler) Info(c droplet.Context) (interface{}, error) {
+	hash, version := utils.GetHashAndVersion()
+	return &InfoOutput{
+		Hash:    hash,
+		Version: version,

Review comment:
       AFAIK, manager-api and web have the same version, which is also the version of apisix-dashboard. Will the versions of manager-api and web be shown to users, respectively?  Thanks.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org