Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update otelhttp and dependencies #143

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions cmd/network-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"os"

"github.com/rancher/wrangler/pkg/leader"
"github.com/rancher/wrangler/pkg/signals"
"github.com/rancher/wrangler/v3/pkg/leader"
"github.com/rancher/wrangler/v3/pkg/signals"
"github.com/urfave/cli"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
Expand Down
7 changes: 5 additions & 2 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
ctlcniv1 "github.com/harvester/harvester/pkg/generated/controllers/k8s.cni.cncf.io/v1"
ctlkubevirt "github.com/harvester/harvester/pkg/generated/controllers/kubevirt.io"
ctlkubevirtv1 "github.com/harvester/harvester/pkg/generated/controllers/kubevirt.io/v1"
"github.com/harvester/harvester/pkg/indexeres"
"github.com/harvester/webhook/pkg/config"
"github.com/harvester/webhook/pkg/server"
ctlcore "github.com/rancher/wrangler/pkg/generated/controllers/core"
Expand Down Expand Up @@ -133,6 +132,10 @@ func run(ctx context.Context, cfg *rest.Config, options *config.Options) error {
return nil
}

const (
VMIByNetworkIndex = "vm.harvesterhci.io/vmi-by-network"
)

type caches struct {
nadCache ctlcniv1.NetworkAttachmentDefinitionCache
vmiCache ctlkubevirtv1.VirtualMachineInstanceCache
Expand Down Expand Up @@ -163,7 +166,7 @@ func newCaches(ctx context.Context, cfg *rest.Config, threadiness int) (*caches,
nodeCache: coreFactory.Core().V1().Node().Cache(),
}
// Indexer must be added before starting the informer, otherwise panic `cannot add indexers to running index` happens
c.vmiCache.AddIndexer(indexeres.VMByNetworkIndex, vmiByNetwork)
c.vmiCache.AddIndexer(VMIByNetworkIndex, vmiByNetwork)

if err := start.All(ctx, threadiness, starters...); err != nil {
return nil, err
Expand Down
286 changes: 130 additions & 156 deletions go.mod

Large diffs are not rendered by default.

1,590 changes: 594 additions & 996 deletions go.sum

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pkg/config/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"github.com/harvester/harvester/pkg/util/crd"
cniv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
"github.com/rancher/lasso/pkg/controller"
wcrd "github.com/rancher/wrangler/pkg/crd"
ctlapps "github.com/rancher/wrangler/pkg/generated/controllers/apps"
ctlbatch "github.com/rancher/wrangler/pkg/generated/controllers/batch"
ctlcore "github.com/rancher/wrangler/pkg/generated/controllers/core"
"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/schemes"
"github.com/rancher/wrangler/pkg/start"
wcrd "github.com/rancher/wrangler/v3/pkg/crd"
ctlapps "github.com/rancher/wrangler/v3/pkg/generated/controllers/apps"
ctlbatch "github.com/rancher/wrangler/v3/pkg/generated/controllers/batch"
ctlcore "github.com/rancher/wrangler/v3/pkg/generated/controllers/core"
"github.com/rancher/wrangler/v3/pkg/generic"
"github.com/rancher/wrangler/v3/pkg/schemes"
"github.com/rancher/wrangler/v3/pkg/start"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/agent/linkmonitor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

ctlcorev1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
ctlcorev1 "github.com/rancher/wrangler/v3/pkg/generated/controllers/core/v1"
"github.com/vishvananda/netlink"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog/v2"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/agent/vlanconfig/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"

ctlcniv1 "github.com/harvester/harvester/pkg/generated/controllers/k8s.cni.cncf.io/v1"
ctlcorev1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
ctlcorev1 "github.com/rancher/wrangler/v3/pkg/generated/controllers/core/v1"
"github.com/vishvananda/netlink"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/manager/nad/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/go-ping/ping"
ctlcniv1 "github.com/harvester/harvester/pkg/generated/controllers/k8s.cni.cncf.io/v1"
cniv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
ctlbatchv1 "github.com/rancher/wrangler/pkg/generated/controllers/batch/v1"
ctlbatchv1 "github.com/rancher/wrangler/v3/pkg/generated/controllers/batch/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions pkg/utils/vmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,30 @@ import (

mapset "github.com/deckarep/golang-set/v2"
ctlkubevirtv1 "github.com/harvester/harvester/pkg/generated/controllers/kubevirt.io/v1"
"github.com/harvester/harvester/pkg/indexeres"
nadv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
kubevirtv1 "kubevirt.io/api/core/v1"
)

const (
VMIByNetworkIndex = "vm.harvesterhci.io/vmi-by-network"
)

type VmiGetter struct {
VmiCache ctlkubevirtv1.VirtualMachineInstanceCache
}

// WhoUseNad requires adding network indexer to the vmi cache before invoking it
func (v *VmiGetter) WhoUseNad(nad *nadv1.NetworkAttachmentDefinition, nodesFilter mapset.Set[string]) ([]*kubevirtv1.VirtualMachineInstance, error) {
v.VmiCache.AddIndexer(VMIByNetworkIndex, vmiByNetwork)
// multus network name can be <networkName> or <namespace>/<networkName>
// ref: https://github.com/kubevirt/client-go/blob/148fa0d1c7e83b7a56606a7ca92394ba6768c9ac/api/v1/schema.go#L1436-L1439
networkName := fmt.Sprintf("%s/%s", nad.Namespace, nad.Name)
vmis, err := v.VmiCache.GetByIndex(indexeres.VMByNetworkIndex, networkName)
vmis, err := v.VmiCache.GetByIndex(VMIByNetworkIndex, networkName)
if err != nil {
return nil, err
}

vmisTmp, err := v.VmiCache.GetByIndex(indexeres.VMByNetworkIndex, nad.Name)
vmisTmp, err := v.VmiCache.GetByIndex(VMIByNetworkIndex, nad.Name)
if err != nil {
return nil, err
}
Expand All @@ -49,3 +53,15 @@ func (v *VmiGetter) WhoUseNad(nad *nadv1.NetworkAttachmentDefinition, nodesFilte

return afterFilter, nil
}

func vmiByNetwork(obj *kubevirtv1.VirtualMachineInstance) ([]string, error) {
networks := obj.Spec.Networks
networkNameList := make([]string, 0, len(networks))
for _, network := range networks {
if network.NetworkSource.Multus == nil {
continue
}
networkNameList = append(networkNameList, network.NetworkSource.Multus.NetworkName)
}
return networkNameList, nil
}
15 changes: 0 additions & 15 deletions vendor/emperror.dev/errors/.editorconfig

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/emperror.dev/errors/.fossa.yml

This file was deleted.

17 changes: 0 additions & 17 deletions vendor/emperror.dev/errors/.gitignore

This file was deleted.

28 changes: 0 additions & 28 deletions vendor/emperror.dev/errors/.golangci.yml

This file was deleted.

117 changes: 0 additions & 117 deletions vendor/emperror.dev/errors/CHANGELOG.md

This file was deleted.

19 changes: 0 additions & 19 deletions vendor/emperror.dev/errors/LICENSE

This file was deleted.

Loading
Loading