Skip to content

Commit a43a579

Browse files
committed
Merge remote-tracking branch 'upstream/main' into AddPDB
2 parents 588db3d + d68bb75 commit a43a579

File tree

12 files changed

+686
-4
lines changed

12 files changed

+686
-4
lines changed

cmd/agent-sandbox-controller/main.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ import (
2222
// to ensure that exec-entrypoint and run can make use of them.
2323
_ "k8s.io/client-go/plugin/pkg/client/auth"
2424

25+
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2526
ctrl "sigs.k8s.io/controller-runtime"
2627
"sigs.k8s.io/controller-runtime/pkg/healthz"
2728
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2829

2930
"sigs.k8s.io/agent-sandbox/controllers"
31+
extensionsv1alpha1 "sigs.k8s.io/agent-sandbox/extensions/api/v1alpha1"
32+
extensionscontrollers "sigs.k8s.io/agent-sandbox/extensions/controllers"
3033
//+kubebuilder:scaffold:imports
3134
)
3235

@@ -38,11 +41,13 @@ func main() {
3841
var metricsAddr string
3942
var enableLeaderElection bool
4043
var probeAddr string
44+
var extensions bool
4145
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
4246
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
4347
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
4448
"Enable leader election for controller manager. "+
4549
"Enabling this will ensure there is only one active controller manager.")
50+
flag.BoolVar(&extensions, "extensions", false, "Enable extensions controllers.")
4651
opts := zap.Options{
4752
Development: true,
4853
}
@@ -51,8 +56,13 @@ func main() {
5156

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

59+
scheme := controllers.Scheme
60+
if extensions {
61+
utilruntime.Must(extensionsv1alpha1.AddToScheme(scheme))
62+
}
63+
5464
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
55-
Scheme: controllers.Scheme,
65+
Scheme: scheme,
5666
HealthProbeBindAddress: probeAddr,
5767
LeaderElection: enableLeaderElection,
5868
LeaderElectionID: "a3317529.x-k8s.io",
@@ -75,6 +85,15 @@ func main() {
7585
setupLog.Error(err, "unable to create controller", "controller", "SandboxPolicy")
7686
os.Exit(1)
7787
}
88+
if extensions {
89+
if err = (&extensionscontrollers.SandboxClaimReconciler{
90+
Client: mgr.GetClient(),
91+
Scheme: mgr.GetScheme(),
92+
}).SetupWithManager(mgr); err != nil {
93+
setupLog.Error(err, "unable to create controller", "controller", "SandboxClaim")
94+
os.Exit(1)
95+
}
96+
}
7897
//+kubebuilder:scaffold:builder
7998

8099
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {

codegen.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ package agentsandbox
1919
// Generate CRDs and RBAC rules
2020
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml crd:maxDescLen=0 paths="./..." output:crd:dir=k8s/crds output:rbac:dir=k8s
2121
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths="./extensions/..." output:crd:dir=k8s/crds output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
22+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths=./api/... output:crd:dir=k8s/crds
23+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen object crd:maxDescLen=0 paths=./extensions/... output:crd:dir=k8s/crds
24+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen paths=./controllers/... output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller,fileName=rbac.generated.yaml
25+
//go:generate go tool -modfile=tools.mod sigs.k8s.io/controller-tools/cmd/controller-gen paths=./extensions/controllers/... output:rbac:dir=k8s rbac:roleName=agent-sandbox-controller-extensions,fileName=extensions-rbac.generated.yaml

controllers/sandbox_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ type SandboxReconciler struct {
6262

6363
//+kubebuilder:rbac:groups=agents.x-k8s.io,resources=sandboxes,verbs=get;list;watch;create;update;patch;delete
6464
//+kubebuilder:rbac:groups=agents.x-k8s.io,resources=sandboxes/status,verbs=get;update;patch
65-
6665
//+kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
6766
//+kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
6867
//+kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete

dev/tools/test-unit

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ from shared import utils
2222
def main():
2323
""" invokes unit tests and outputs a junit results file """
2424
repo_root = utils.get_repo_root()
25+
# get the list of packages using go list ./...
26+
go_list_cmd = ["go", "list", "./..."]
27+
go_list_output = subprocess.check_output(go_list_cmd, cwd=repo_root, text=True)
28+
packages = go_list_output.strip().split('\n')
29+
30+
# Filter out the e2e packages
31+
filtered_packages = [pkg for pkg in packages if not "test/e2e" in pkg]
32+
2533
result = subprocess.run(utils.go_tool_args(
2634
"gotestsum", f"--junitfile={repo_root}/bin/unit-junit.xml",
27-
"--", "./controllers/...",
35+
"--", *filtered_packages
2836
), cwd=repo_root)
2937

3038
return result.returncode

extensions/api/v1alpha1/sandboxclaim_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ type SandboxClaimSpec struct {
5353

5454
// SandboxClaimStatus defines the observed state of Sandbox.
5555
type SandboxClaimStatus struct {
56+
// Conditions represent the latest available observations of a Sandbox's current state.
57+
// +optional
58+
Conditions []metav1.Condition `json:"conditions,omitempty" protobuf:"bytes,1,rep,name=conditions"`
59+
60+
SandboxStatus SandboxStatus `json:"sandbox,omitempty" protobuf:"bytes,2,opt,name=sandboxStatus"`
61+
}
62+
63+
type SandboxStatus struct {
64+
// SandboxName is the name of the Sandbox created from this claim
65+
// +optional
66+
Name string `json:"Name,omitempty"`
5667
}
5768

5869
// +kubebuilder:object:root=true

extensions/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)