retina icon indicating copy to clipboard operation
retina copied to clipboard

Fix #237: Use Prometheus type Counter instead of Gauge for forward module's packet and byte counters

Open andreev-io opened this issue 1 year ago • 6 comments

Description

Replace gauges used for the forward module with counters.

Related Issue

https://github.com/microsoft/retina/issues/237

Checklist

  • [ ] I have read the contributing documentation.
  • [ ] I signed and signed-off the commits (git commit -S -s ...). See this documentation on signing commits.
  • [ ] I have correctly attributed the author(s) of the code.
  • [ ] I have tested the changes locally.
  • [ ] I have followed the project's style guidelines.
  • [ ] I have updated the documentation, if necessary.
  • [ ] I have added tests, if applicable.

Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes made.

Additional Notes

Add any additional notes or context about the pull request here.


Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.

andreev-io avatar Apr 08 '24 12:04 andreev-io

Hey folks! What's the right way to build this locally? I'm on a Mac but can spin up a VM as needed.

andreev-io avatar Apr 08 '24 13:04 andreev-io

Hey folks! What's the right way to build this locally? I'm on a Mac but can spin up a VM as needed.

Do you want to build images? You can use the Makefile, eg make retina-image

rbtr avatar Apr 08 '24 14:04 rbtr

@microsoft-github-policy-service agree company="ClickHouse"

andreev-io avatar Apr 08 '24 15:04 andreev-io

@rbtr Likely an issue on my end, but perhaps you've seen these before?

Error from building retina-image:

➜  retina-fork git:(ilya/l4-protocol) ✗ make retina-image
echo "Building for linux/amd64"
Building for linux/amd64
for target in init agent; do \
                echo "Building for $target"; \
                if [ "$target" = "init" ]; then \
                        image_name=andreev-io/retina/retina-init; \
                else \
                        image_name=andreev-io/retina/retina-agent; \
                fi; \
                /Library/Developer/CommandLineTools/usr/bin/make container-docker \
                                PLATFORM=linux/amd64 \
                                DOCKERFILE=controller/Dockerfile.controller \
                                REGISTRY=ghcr.io \
                                IMAGE=$image_name \
                                VERSION=3edcd38 \
                                TAG=3edcd38-linux-amd64 \
                                APP_INSIGHTS_ID="" \
                                CONTEXT_DIR=/Users/ilyaandreev/Documents/GitHub/retina-fork \
                                TARGET=$target; \
        done
Building for init
if docker buildx inspect retina > /dev/null 2>&1; then \
                echo "Buildx instance retina already exists."; \
        else \
                echo "Creating buildx instance retina..."; \
                docker buildx create --name retina --use --platform $(echo "linux/amd64 linux/arm64 windows/amd64" | tr ' ' ','); \
                docker buildx use retina; \
                echo "Buildx instance retina created."; \
        fi;
Buildx instance retina already exists.
os=$(echo linux/amd64 | cut -d'/' -f1); \
        arch=$(echo linux/amd64 | cut -d'/' -f2); \
        image_name=$(basename andreev-io/retina/retina-init); \
        image_metadata_filename="image-metadata-$image_name-3edcd38-linux-amd64.json"; \
        touch $image_metadata_filename; \
        echo "Building $image_name for $os/$arch "; \
        docker buildx build \
                 \
                --platform linux/amd64 \
                --metadata-file=$image_metadata_filename \
                -f controller/Dockerfile.controller \
                --build-arg VERSION=3edcd38  \
                --build-arg GOOS=$os \
                --build-arg GOARCH=$arch \
                --build-arg APP_INSIGHTS_ID= \
                --target=init \
                -t ghcr.io/andreev-io/retina/retina-init:3edcd38-linux-amd64 \
                /Users/ilyaandreev/Documents/GitHub/retina-fork
Building retina-init for linux/amd64 
[+] Building 7.3s (1/1) FINISHED                                                                                                                                                             docker-container:retina
 => ERROR [internal] booting buildkit                                                                                                                                                                           7.3s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                              7.3s
 => => creating container buildx_buildkit_retina0                                                                                                                                                               0.0s
------
 > [internal] booting buildkit:
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
ERROR: Error response from daemon: No such image: moby/buildkit:buildx-stable-1
make[1]: *** [container-docker] Error 1
Building for agent
if docker buildx inspect retina > /dev/null 2>&1; then \
                echo "Buildx instance retina already exists."; \
        else \
                echo "Creating buildx instance retina..."; \
                docker buildx create --name retina --use --platform $(echo "linux/amd64 linux/arm64 windows/amd64" | tr ' ' ','); \
                docker buildx use retina; \
                echo "Buildx instance retina created."; \
        fi;
Buildx instance retina already exists.
os=$(echo linux/amd64 | cut -d'/' -f1); \
        arch=$(echo linux/amd64 | cut -d'/' -f2); \
        image_name=$(basename andreev-io/retina/retina-agent); \
        image_metadata_filename="image-metadata-$image_name-3edcd38-linux-amd64.json"; \
        touch $image_metadata_filename; \
        echo "Building $image_name for $os/$arch "; \
        docker buildx build \
                 \
                --platform linux/amd64 \
                --metadata-file=$image_metadata_filename \
                -f controller/Dockerfile.controller \
                --build-arg VERSION=3edcd38  \
                --build-arg GOOS=$os \
                --build-arg GOARCH=$arch \
                --build-arg APP_INSIGHTS_ID= \
                --target=agent \
                -t ghcr.io/andreev-io/retina/retina-agent:3edcd38-linux-amd64 \
                /Users/ilyaandreev/Documents/GitHub/retina-fork
Building retina-agent for linux/amd64 
[+] Building 6.9s (1/1) FINISHED                                                                                                                                                             docker-container:retina
 => ERROR [internal] booting buildkit                                                                                                                                                                           6.9s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                              6.9s
 => => creating container buildx_buildkit_retina0                                                                                                                                                               0.0s
------
 > [internal] booting buildkit:
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
ERROR: Error response from daemon: No such image: moby/buildkit:buildx-stable-1
make[1]: *** [container-docker] Error 1
make: *** [retina-image] Error 2

Error from building retina-binary: Do I need a go.work file for this?

➜  retina-fork git:(ilya/l4-protocol) ✗ make retina-binary
export CGO_ENABLED=0 && \
        go generate ./... && \
        go build -v -o /Users/ilyaandreev/Documents/GitHub/retina-fork/output/linux_amd64/retina/retina -gcflags="-dwarflocationlists=true" -ldflags "-X main.version=3edcd38 -X main.applicationInsightsID=""" /Users/ilyaandreev/Documents/GitHub/retina-fork/controller/main.go
package command-line-arguments
        imports github.com/microsoft/retina/pkg/managers/controllermanager
        imports github.com/microsoft/retina/pkg/managers/pluginmanager
        imports github.com/microsoft/retina/pkg/plugin/registry: build constraints exclude all Go files in /Users/ilyaandreev/Documents/GitHub/retina-fork/pkg/plugin/registry
make: *** [retina-binary] Error 1

andreev-io avatar Apr 08 '24 15:04 andreev-io

imports github.com/microsoft/retina/pkg/plugin/registry: build constraints exclude all Go files in /Users/ilyaandreev/Documents/GitHub/retina-fork/pkg/plugin/registry

This problem with compiling the binary is likely due to your host platform not being supported by this package (only Linux and Windows build constraints are supported): image

Does anything change if you set env vars for GOOS=linux, GOARCH=amd64? I don't have access to a Mac to test but @vakalapa is going to be checking another issue and might be able to test this also.

No such image: moby/buildkit:buildx-stable-1

This one I am more confused about, as that is a Moby infra image that should definitely exist...not sure how to fix this 🤔

WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load

Is resolved by adding a BULIDX_ACTION such as make retina-image BUILDX_ACTION=--load

rbtr avatar Apr 08 '24 16:04 rbtr

This PR will be closed in 7 days due to inactivity.

github-actions[bot] avatar May 23 '24 00:05 github-actions[bot]

Pull request closed due to inactivity.

github-actions[bot] avatar May 30 '24 00:05 github-actions[bot]

This PR will be closed in 7 days due to inactivity.

github-actions[bot] avatar Jun 30 '24 00:06 github-actions[bot]

Pull request closed due to inactivity.

github-actions[bot] avatar Jul 07 '24 00:07 github-actions[bot]