Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: redhat-best-practices-for-k8s/graphsolver-examples
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: redhat-cne/graphsolver-examples
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 6 commits
  • 15 files changed
  • 2 contributors

Commits on Aug 21, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    edcdavid David Elie-Dit-Cosaque
    Copy the full SHA
    6756068 View commit details
  2. Add Github action

    edcdavid committed Aug 21, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    edcdavid David Elie-Dit-Cosaque
    Copy the full SHA
    18ddd56 View commit details
  3. Merge pull request #1 from edcdavid/add-ci-test-rename

    Add ci test and rename organization
    edcdavid authored Aug 21, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    44b30f4 View commit details
  4. Add go vet target and fix CI

    edcdavid committed Aug 21, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    edcdavid David Elie-Dit-Cosaque
    Copy the full SHA
    ec6aee2 View commit details
  5. Merge pull request #2 from edcdavid/add-go-vet

    Add go vet target
    edcdavid authored Aug 21, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    320804a View commit details

Commits on Aug 28, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    344cb27 View commit details
Showing with 237 additions and 106 deletions.
  1. +2 −0 .checkmake
  2. +82 −0 .github/workflows/pre-main.yaml
  3. +6 −1 Makefile
  4. +2 −2 examples/basic/basic.go
  5. +1 −1 examples/basic/go.mod
  6. +28 −25 go.mod
  7. +46 −68 go.sum
  8. +7 −0 kind-config.yaml
  9. +1 −1 pkg/export/export.go
  10. +1 −1 pkg/export/go.mod
  11. +1 −1 pkg/lib/go.mod
  12. +2 −2 pkg/lib/lib.go
  13. +25 −0 scripts/test.sh
  14. +4 −4 simplegraphsolver.go
  15. +29 −0 test/expected.txt
2 changes: 2 additions & 0 deletions .checkmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[maxbodylength]
disabled = true
82 changes: 82 additions & 0 deletions .github/workflows/pre-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Test Incoming Changes

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read

env:
TERM: xterm-color
CM_BIN: /usr/local/bin/checkmake
CM_URL_LINUX: https://github.com/mrtazz/checkmake/releases/download/0.2.2/checkmake-0.2.2.linux.amd64 # yamllint disable-line

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

jobs:
lint-and-test:
name: Run Linters, Vet and unit tests
runs-on: ubuntu-22.04
env:
SHELL: /bin/bash

steps:
- name: Set up Go 1.22
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.22.5

- name: Disable default go problem matcher
run: echo "::remove-matcher owner=go::"

- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.sha }}

- name: Extract dependent Pull Requests
uses: depends-on/depends-on-action@9e8a61fce18b15281e831f1bba0e14c71d1e1f46 # main
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install checkmake
run: |
curl --location --output $CM_BIN --silent $CM_URL_LINUX
chmod +x $CM_BIN
- name: Install Shfmt
uses: mfinelli/setup-shfmt@031e887e39d899d773a7e9b6dd6472c2c23ff50d # v3.0.1

- name: Golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
version: v1.59
args: --timeout 10m0s

- name: Checkmake
run: checkmake --config=.checkmake Makefile

- name: Shfmt
run: shfmt -d scripts

- name: ShellCheck
uses: ludeeus/action-shellcheck@00b27aa7cb85167568cb48a3838b75f4265f2bca # master

- name: Go vet
run: make vet

- name: Run Build
run: make build
env:
SHELL: /bin/bash

- name: Run Tests
run: make test
env:
SHELL: /bin/bash
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.PHONY: all clean test build
lint:
golangci-lint run
# Install golangci-lint
@@ -13,4 +14,8 @@ lint-all:
$(MAKE) lint -C .
$(MAKE) lint -C ./pkg/lib
$(MAKE) lint -C ./pkg/export
$(MAKE) lint -C ./examples/basic
$(MAKE) lint -C ./examples/basic
vet:
go vet ${GO_PACKAGES}
test:
./scripts/test.sh
4 changes: 2 additions & 2 deletions examples/basic/basic.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
l2lib "github.com/redhat-best-practices-for-k8s/l2discovery/l2lib/pkg/export"
"github.com/redhat-best-practices-for-k8s/simplegraphsolver/pkg/lib"
l2lib "github.com/redhat-cne/l2discovery/l2lib/pkg/export"
"github.com/redhat-cne/simplegraphsolver/pkg/lib"
)

type testGraph struct {
2 changes: 1 addition & 1 deletion examples/basic/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/redhat-best-practices-for-k8s/simplegraphsolver/examples/basic
module github.com/redhat-cne/simplegraphsolver/examples/basic

go 1.22.5

53 changes: 28 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
module github.com/redhat-best-practices-for-k8s/l2discovery-examples
module github.com/redhat-cne/l2discovery-examples

go 1.22.5
go 1.22.0

replace k8s.io/client-go => k8s.io/client-go v0.29.7
replace (
k8s.io/api v0.31.0 => k8s.io/api v0.29.0
k8s.io/apimachinery => k8s.io/apimachinery v0.29.0
k8s.io/client-go => k8s.io/client-go v0.29.0
)

require (
github.com/openshift/ptp-operator v0.0.0-20240719170405-a3502a34dbd8
github.com/redhat-best-practices-for-k8s/graphsolver-lib v0.0.5
github.com/redhat-best-practices-for-k8s/l2discovery-lib v0.0.10
github.com/openshift/ptp-operator v0.0.0-20240820132422-340fb8f46533
github.com/redhat-cne/graphsolver-lib v0.0.5
github.com/redhat-cne/l2discovery-lib v0.0.14
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -47,35 +51,34 @@ require (
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/redhat-best-practices-for-k8s/graphsolver-exports v0.0.2 // indirect
github.com/redhat-best-practices-for-k8s/l2discovery-exports v0.0.5 // indirect
github.com/redhat-best-practices-for-k8s/privileged-daemonset v1.0.31 // indirect
github.com/redhat-cne/graphsolver-exports v0.0.2 // indirect
github.com/redhat-cne/l2discovery-exports v0.0.4 // indirect
github.com/redhat-cne/privileged-daemonset v1.0.34 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/yourbasic/graph v0.0.0-20210606180040-8ecfec1c2869 // indirect
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.30.3 // indirect
k8s.io/api v0.31.0 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/apimachinery v0.30.3 // indirect
k8s.io/client-go v0.30.3 // indirect
k8s.io/apimachinery v0.31.0 // indirect
k8s.io/client-go v0.31.0 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
k8s.io/utils v0.0.0-20240821151609-f90d01438635 // indirect
sigs.k8s.io/controller-runtime v0.16.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
114 changes: 46 additions & 68 deletions go.sum

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
2 changes: 1 addition & 1 deletion pkg/export/export.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package export

import (
l2lib "github.com/redhat-best-practices-for-k8s/l2discovery/l2lib/pkg/export"
l2lib "github.com/redhat-cne/l2discovery/l2lib/pkg/export"
)

type SolverConfig interface {
2 changes: 1 addition & 1 deletion pkg/export/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/redhat-best-practices-for-k8s/simplegraphsolver/pkg/export
module github.com/redhat-cne/simplegraphsolver/pkg/export

go 1.22.5
2 changes: 1 addition & 1 deletion pkg/lib/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/redhat-best-practices-for-k8s/simplegraphsolver/pkg/lib
module github.com/redhat-cne/simplegraphsolver/pkg/lib

go 1.22.5
4 changes: 2 additions & 2 deletions pkg/lib/lib.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package lib

import (
l2lib "github.com/redhat-best-practices-for-k8s/l2discovery/l2lib/pkg/export"
"github.com/redhat-best-practices-for-k8s/simplegraphsolver/pkg/export"
l2lib "github.com/redhat-cne/l2discovery/l2lib/pkg/export"
"github.com/redhat-cne/simplegraphsolver/pkg/export"
"github.com/sirupsen/logrus"
)

25 changes: 25 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -o nounset -o pipefail

# Creates kind cluster
cat >kind-config.yaml <<EOF
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF

go mod vendor
make build

kind delete cluster --name test-cluster || true
kind create cluster --name test-cluster --config kind-config.yaml

export KUBECONFIG=~/.kube/config

./simplegraphsolver 2>&1 | sed 's/veth[a-zA-Z0-9]\+/veth/g' | sed 's/time="[^"]*" //' >test/actual.txt

diff test/actual.txt test/expected.txt
8 changes: 4 additions & 4 deletions simplegraphsolver.go
Original file line number Diff line number Diff line change
@@ -2,15 +2,15 @@ package main

import (
"github.com/openshift/ptp-operator/test/pkg/client"
lib "github.com/redhat-best-practices-for-k8s/graphsolver-lib"
l2lib "github.com/redhat-best-practices-for-k8s/l2discovery-lib"
lib "github.com/redhat-cne/graphsolver-lib"
l2lib "github.com/redhat-cne/l2discovery-lib"
)

// Runs Solver to find optimal configurations
func main() {
const (
// problem/scenario name
findOCProblemName = "OC"
findOCProblemName = "interfaces connected via a LAN"

// unique id for each tag, e.g. solution role
tagSlave = 0
@@ -24,7 +24,7 @@ func main() {
l2lib.GlobalL2DiscoveryConfig.SetL2Client(client.Client, client.Client.Config)

// Collect L2 info
config, err := l2lib.GlobalL2DiscoveryConfig.GetL2DiscoveryConfig(true)
config, err := l2lib.GlobalL2DiscoveryConfig.GetL2DiscoveryConfig(false, true, true, "quay.io/redhat-cne/l2discovery:latest")
if err != nil {
return
}
29 changes: 29 additions & 0 deletions test/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
level=info msg="Will skip the following interfaces in every nodes: []"
level=info msg="LANs connectivity map: [[0 4 5] [1] [2] [3]]"
level=info msg="List All NICS (node name: interface)"
level=info msg="0 test-cluster-control-plane : eth0"
level=info msg="1 test-cluster-control-plane : veth"
level=info msg="2 test-cluster-control-plane : veth"
level=info msg="3 test-cluster-control-plane : veth"
level=info msg="4 test-cluster-worker : eth0"
level=info msg="5 test-cluster-worker2 : eth0"
level=info msg="NIC num: 6"
level=info msg="Solutions for interfaces connected via a LAN problem"
level=info msg="p0= test-cluster-control-plane : eth0"
level=info msg="p1= test-cluster-worker : eth0"
level=info msg=---
level=info msg="p0= test-cluster-control-plane : eth0"
level=info msg="p1= test-cluster-worker2 : eth0"
level=info msg=---
level=info msg="p0= test-cluster-worker : eth0"
level=info msg="p1= test-cluster-control-plane : eth0"
level=info msg=---
level=info msg="p0= test-cluster-worker : eth0"
level=info msg="p1= test-cluster-worker2 : eth0"
level=info msg=---
level=info msg="p0= test-cluster-worker2 : eth0"
level=info msg="p1= test-cluster-worker : eth0"
level=info msg=---
level=info msg="p0= test-cluster-worker2 : eth0"
level=info msg="p1= test-cluster-control-plane : eth0"
level=info msg=---