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 dependencies #8

Merged
merged 3 commits into from
May 29, 2024
Merged
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
  •  
  •  
  •  
47 changes: 34 additions & 13 deletions cmd/bpfman-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,30 @@ package main

import (
"context"
"crypto/tls"
"flag"
"fmt"
"os"

"go.uber.org/zap/zapcore"
_ "k8s.io/client-go/plugin/pkg/client/auth"
bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagent "github.com/bpfman/bpfman-operator/controllers/bpfman-agent"

"github.com/bpfman/bpfman-operator/internal/conn"
gobpfman "github.com/bpfman/bpfman/clients/gobpfman/v1"

"go.uber.org/zap/zapcore"
"google.golang.org/grpc/credentials/insecure"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagent "github.com/bpfman/bpfman-operator/controllers/bpfman-agent"

"github.com/bpfman/bpfman-operator/internal/conn"
gobpfman "github.com/bpfman/bpfman/clients/gobpfman/v1"
v1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
//+kubebuilder:scaffold:imports
)

Expand All @@ -59,8 +61,11 @@ func main() {
var metricsAddr string
var probeAddr string
var opts zap.Options
var enableHTTP2 bool

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8174", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8175", "The address the probe endpoint binds to.")
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
flag.Parse()

// Get the Log level for bpfman deployment where this pod is running
Expand All @@ -85,16 +90,32 @@ func main() {
}
}

disableHTTP2 := func(c *tls.Config) {
if enableHTTP2 {
return
}
c.NextProtos = []string{"http/1.1"}
}

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddr,
TLSOpts: []func(*tls.Config){disableHTTP2},
},
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
TLSOpts: []func(*tls.Config){disableHTTP2},
}),
HealthProbeBindAddress: probeAddr,
LeaderElection: false,
// Specify that Secrets's should not be cached.
ClientDisableCacheFor: []client.Object{&v1.Secret{}},
Client: client.Options{Cache: &client.CacheOptions{
DisableFor: []client.Object{&v1.Secret{}},
},
},
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
35 changes: 26 additions & 9 deletions cmd/bpfman-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ limitations under the License.
package main

import (
"crypto/tls"
"flag"
"os"

"go.uber.org/zap/zapcore"
_ "k8s.io/client-go/plugin/pkg/client/auth"
bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanoperator "github.com/bpfman/bpfman-operator/controllers/bpfman-operator"
"github.com/bpfman/bpfman-operator/internal"

"go.uber.org/zap/zapcore"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanoperator "github.com/bpfman/bpfman-operator/controllers/bpfman-operator"
"github.com/bpfman/bpfman-operator/internal"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
//+kubebuilder:scaffold:imports
)

Expand All @@ -52,11 +54,13 @@ func main() {
var enableLeaderElection bool
var probeAddr string
var opts zap.Options
var enableHTTP2 bool
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8174", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8175", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
flag.Parse()

// Get the Log level for bpfman deployment where this pod is running
Expand All @@ -81,12 +85,25 @@ func main() {
}
}

disableHTTP2 := func(c *tls.Config) {
if enableHTTP2 {
return
}
c.NextProtos = []string{"http/1.1"}
}

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddr,
TLSOpts: []func(*tls.Config){disableHTTP2},
},
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
TLSOpts: []func(*tls.Config){disableHTTP2},
}),
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "8730d955.bpfman.io",
Expand Down
2 changes: 1 addition & 1 deletion controllers/bpfman-agent/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func (r *ReconcilerCommon) updateStatus(ctx context.Context, bpfProgram *bpfmani
meta.SetStatusCondition(&bpfProgram.Status.Conditions, cond.Condition())

r.Logger.V(1).Info("Updating bpfProgram condition", "bpfProgram", bpfProgram.Name, "condition", cond.Condition().Type)
if err := r.Status().Update(ctx, bpfProgram); err != nil {
if err := r.Update(ctx, bpfProgram); err != nil {
r.Logger.Error(err, "failed to set bpfProgram object status")
}

Expand Down
3 changes: 1 addition & 2 deletions controllers/bpfman-agent/fentry-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"
)

//+kubebuilder:rbac:groups=bpfman.io,resources=fentryprograms,verbs=get;list;watch
Expand Down Expand Up @@ -98,7 +97,7 @@
// make the FentryProgram no longer select the Node. Additionally only
// care about node events specific to our node
Watches(
&source.Kind{Type: &v1.Node{}},
&v1.Node{},

Check warning on line 100 in controllers/bpfman-agent/fentry-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/fentry-program.go#L100

Added line #L100 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(predicate.LabelChangedPredicate{}, nodePredicate(r.NodeName))),
).
Expand Down
3 changes: 1 addition & 2 deletions controllers/bpfman-agent/fexit-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"
)

//+kubebuilder:rbac:groups=bpfman.io,resources=fexitprograms,verbs=get;list;watch
Expand Down Expand Up @@ -98,7 +97,7 @@
// make the FexitProgram no longer select the Node. Additionally only
// care about node events specific to our node
Watches(
&source.Kind{Type: &v1.Node{}},
&v1.Node{},

Check warning on line 100 in controllers/bpfman-agent/fexit-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/fexit-program.go#L100

Added line #L100 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(predicate.LabelChangedPredicate{}, nodePredicate(r.NodeName))),
).
Expand Down
3 changes: 1 addition & 2 deletions controllers/bpfman-agent/kprobe-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"
)

//+kubebuilder:rbac:groups=bpfman.io,resources=kprobeprograms,verbs=get;list;watch
Expand Down Expand Up @@ -98,7 +97,7 @@
// make the KprobeProgram no longer select the Node. Additionally only
// care about node events specific to our node
Watches(
&source.Kind{Type: &v1.Node{}},
&v1.Node{},

Check warning on line 100 in controllers/bpfman-agent/kprobe-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/kprobe-program.go#L100

Added line #L100 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(predicate.LabelChangedPredicate{}, nodePredicate(r.NodeName))),
).
Expand Down
10 changes: 4 additions & 6 deletions controllers/bpfman-agent/tc-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@

"k8s.io/apimachinery/pkg/types"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"
"github.com/bpfman/bpfman-operator/internal"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"
"github.com/bpfman/bpfman-operator/internal"

gobpfman "github.com/bpfman/bpfman/clients/gobpfman/v1"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -145,7 +143,7 @@
// make the TcProgram no longer select the Node. Additionally only
// care about events specific to our node
Watches(
&source.Kind{Type: &v1.Node{}},
&v1.Node{},

Check warning on line 146 in controllers/bpfman-agent/tc-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/tc-program.go#L146

Added line #L146 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(predicate.LabelChangedPredicate{}, nodePredicate(r.NodeName))),
).
Expand Down
8 changes: 3 additions & 5 deletions controllers/bpfman-agent/tracepoint-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@

"k8s.io/apimachinery/pkg/types"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"

internal "github.com/bpfman/bpfman-operator/internal"
gobpfman "github.com/bpfman/bpfman/clients/gobpfman/v1"
Expand Down Expand Up @@ -100,7 +98,7 @@
// make the TracepointProgram no longer select the Node. Additionally only
// care about node events specific to our node
Watches(
&source.Kind{Type: &v1.Node{}},
&v1.Node{},

Check warning on line 101 in controllers/bpfman-agent/tracepoint-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/tracepoint-program.go#L101

Added line #L101 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(predicate.LabelChangedPredicate{}, nodePredicate(r.NodeName))),
).
Expand Down
10 changes: 4 additions & 6 deletions controllers/bpfman-agent/uprobe-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@

"k8s.io/apimachinery/pkg/types"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"

internal "github.com/bpfman/bpfman-operator/internal"
gobpfman "github.com/bpfman/bpfman/clients/gobpfman/v1"
Expand Down Expand Up @@ -102,13 +100,13 @@
// for when uprobes are attached inside containers. In both cases, only
// care about events specific to our node
Watches(
&source.Kind{Type: &v1.Node{}},
&v1.Node{},

Check warning on line 103 in controllers/bpfman-agent/uprobe-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/uprobe-program.go#L103

Added line #L103 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(predicate.LabelChangedPredicate{}, nodePredicate(r.NodeName))),
).
// Watch for changes in Pod resources in case we are using a container selector.
Watches(
&source.Kind{Type: &v1.Pod{}},
&v1.Pod{},

Check warning on line 109 in controllers/bpfman-agent/uprobe-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/uprobe-program.go#L109

Added line #L109 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(podOnNodePredicate(r.NodeName)),
).
Expand Down
10 changes: 4 additions & 6 deletions controllers/bpfman-agent/xdp-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
"context"
"fmt"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"
internal "github.com/bpfman/bpfman-operator/internal"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
bpfmanagentinternal "github.com/bpfman/bpfman-operator/controllers/bpfman-agent/internal"
internal "github.com/bpfman/bpfman-operator/internal"

gobpfman "github.com/bpfman/bpfman/clients/gobpfman/v1"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -129,7 +127,7 @@
// make the XdpProgram no longer select the Node. Additionally only
// care about node events specific to our node
Watches(
&source.Kind{Type: &v1.Node{}},
&v1.Node{},

Check warning on line 130 in controllers/bpfman-agent/xdp-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/xdp-program.go#L130

Added line #L130 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(predicate.LabelChangedPredicate{}, nodePredicate(r.NodeName))),
).
Expand Down
2 changes: 1 addition & 1 deletion controllers/bpfman-operator/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (r *ReconcilerCommon) updateCondition(ctx context.Context, obj client.Objec

meta.SetStatusCondition(conditions, cond.Condition(message))

if err := r.Status().Update(ctx, obj); err != nil {
if err := r.Update(ctx, obj); err != nil {
r.Logger.V(1).Info("failed to set *Program object status...requeuing")
return ctrl.Result{Requeue: true, RequeueAfter: retryDurationOperator}, nil
}
Expand Down
8 changes: 3 additions & 5 deletions controllers/bpfman-operator/fentry-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
"github.com/bpfman/bpfman-operator/internal"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
"github.com/bpfman/bpfman-operator/internal"
)

//+kubebuilder:rbac:groups=bpfman.io,resources=fentryprograms,verbs=get;list;watch;create;update;patch;delete
Expand All @@ -55,7 +53,7 @@
For(&bpfmaniov1alpha1.FentryProgram{}).
// Watch bpfPrograms which are owned by FentryPrograms
Watches(
&source.Kind{Type: &bpfmaniov1alpha1.BpfProgram{}},
&bpfmaniov1alpha1.BpfProgram{},

Check warning on line 56 in controllers/bpfman-operator/fentry-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-operator/fentry-program.go#L56

Added line #L56 was not covered by tests
&handler.EnqueueRequestForObject{},
builder.WithPredicates(predicate.And(statusChangedPredicate(), internal.BpfProgramTypePredicate(internal.FentryString))),
).
Expand Down
Loading
Loading