-
Notifications
You must be signed in to change notification settings - Fork 24
Inttest #330
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
Draft
thesrinath
wants to merge
6
commits into
openconfig:main
Choose a base branch
from
thesrinath:inttest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Inttest #330
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d4f5d71
Initial changes for bringing up sut components within monax and KIND
thesrinath fdbdda9
Fix lint errors in dhcp/sutserver/sutserver.go and server/tests/monax…
thesrinath fde5787
Fix dependencies and add SUT state management
thesrinath 6306783
Update go.mod and go.sum for new sutserver and sutstate packages
thesrinath 5cdf115
Initial monax sut changes
thesrinath 6d454a6
Update go.mod
thesrinath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| FROM golang:1.26 AS builder | ||
| WORKDIR /app | ||
| COPY bootz/go.mod bootz/go.sum ./ | ||
| # Map local monax repository so go mod download can resolve the replace directive inside Docker. | ||
| COPY monax /monax | ||
| RUN go mod download | ||
| COPY bootz . | ||
| RUN CGO_ENABLED=0 GOOS=linux go build -o /bootz-sut ./server/sut | ||
| RUN mkdir -p /www_dir | ||
| RUN mkdir -p server/sut | ||
|
|
||
| FROM gcr.io/distroless/static-debian12:latest | ||
| WORKDIR /app | ||
| COPY --from=builder /bootz-sut /app/bootz-sut | ||
| COPY --from=builder /www_dir /www | ||
| COPY --from=builder /app/server/sut /app/server/sut | ||
| COPY bootz/testdata /app/testdata | ||
| # Set WORKDIR to /app/server/sut so relative paths in flags (../../testdata) resolve to /app/testdata. | ||
| WORKDIR /app/server/sut | ||
| # DHCP needs to run as root. | ||
| USER root | ||
| HEALTHCHECK --interval=5s --timeout=2s --start-period=3s --retries=3 \ | ||
| CMD ["/app/bootz-sut", "--healthcheck"] | ||
| ENTRYPOINT ["/app/bootz-sut"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: bootz-dhcp | ||
| labels: | ||
| app: bootz-dhcp | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: bootz-dhcp | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: bootz-dhcp | ||
| spec: | ||
| containers: | ||
| - image: bootz-dhcp | ||
| name: bootz-dhcp | ||
| args: | ||
| - -i=eth0 | ||
| - -records=4c:5d:3c:ef:de:60,10.0.0.2/24,10.0.0.1 | ||
| - -dns=8.8.8.8 | ||
| - -bootz_urls=http://bootz-server:8080 | ||
| - -sut_addr=:4001 | ||
| ports: | ||
| - containerPort: 67 | ||
| protocol: UDP | ||
| name: dhcp | ||
| - containerPort: 4001 | ||
| protocol: TCP | ||
| name: grpc | ||
| securityContext: | ||
| runAsUser: 0 | ||
| capabilities: | ||
| add: | ||
| - NET_ADMIN | ||
| imagePullPolicy: Never |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # proto-file: proto/monax.proto | ||
| # proto-message: monax.Library | ||
|
|
||
| components: { | ||
| id: "DHCP" | ||
| kind: "kubernetes" | ||
| provided_interfaces: { | ||
| name: "dhcp" | ||
| dhcp: { | ||
| service_name: "bootz-dhcp" | ||
| } | ||
| } | ||
| provided_interfaces: { | ||
| name: "grpc" | ||
| grpc: { | ||
| service_name: "bootz.DHCPService" | ||
| } | ||
| } | ||
| parameters: { | ||
| [type.googleapis.com/monax.kubernetes.KubernetesComponentParameters] { | ||
| deployment_path: "deployment.yaml" | ||
| service_path: "service.yaml" | ||
| wait_for_deployment_timeout_sec: 60 | ||
| wait_for_service_timeout_sec: 60 | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: bootz-dhcp | ||
| spec: | ||
| ports: | ||
| - name: dhcp | ||
| port: 67 | ||
| protocol: UDP | ||
| targetPort: 67 | ||
| - name: grpc | ||
| port: 4001 | ||
| protocol: TCP | ||
| targetPort: 4001 | ||
| selector: | ||
| app: bootz-dhcp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package sutserver | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net" | ||
| "net/netip" | ||
|
|
||
| log "github.com/golang/glog" | ||
| "github.com/openconfig/bootz/dhcp/plugins/slease" | ||
| pb "github.com/openconfig/bootz/server/tests/proto/sut" | ||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/reflection" | ||
| ) | ||
|
|
||
| type Server struct { | ||
| pb.UnimplementedDHCPServiceServer | ||
| grpcServer *grpc.Server | ||
| } | ||
|
|
||
| func New() *Server { | ||
| return &Server{} | ||
| } | ||
|
|
||
| // Start starts the DHCP SUT gRPC server. | ||
| func (s *Server) Start(addr string) error { | ||
| lis, err := net.Listen("tcp", addr) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| s.grpcServer = grpc.NewServer() | ||
| pb.RegisterDHCPServiceServer(s.grpcServer, s) | ||
| reflection.Register(s.grpcServer) | ||
| log.Infof("Starting DHCP SUT gRPC server on %s", addr) | ||
| go func() { | ||
| if err := s.grpcServer.Serve(lis); err != nil { | ||
| log.Errorf("DHCP SUT gRPC server failed: %v", err) | ||
| } | ||
| }() | ||
| return nil | ||
| } | ||
|
|
||
| // Stop stops the DHCP SUT gRPC server. | ||
| func (s *Server) Stop() { | ||
| if s.grpcServer != nil { | ||
| s.grpcServer.GracefulStop() | ||
| } | ||
| } | ||
|
|
||
| // CreateLease creates a DHCP lease dynamically. | ||
| func (s *Server) CreateLease(ctx context.Context, req *pb.CreateLeaseRequest) (*pb.CreateLeaseResponse, error) { | ||
| ip, err := netip.ParseAddr(req.GetIpAddress()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| gw := net.ParseIP(req.GetGateway()) | ||
| if gw == nil { | ||
| return nil, fmt.Errorf("invalid gateway: %s", req.GetGateway()) | ||
| } | ||
|
|
||
| mask := net.CIDRMask(int(req.GetMaskLen()), ip.BitLen()) | ||
|
|
||
| for _, mac := range req.GetMacAddresses() { | ||
| slease.AddRecord4(mac, net.ParseIP(req.GetIpAddress()), mask, gw) | ||
| } | ||
|
|
||
| return &pb.CreateLeaseResponse{}, nil | ||
| } | ||
|
|
||
| // RemoveLease removes a DHCP lease dynamically. | ||
| func (s *Server) RemoveLease(ctx context.Context, req *pb.RemoveLeaseRequest) (*pb.RemoveLeaseResponse, error) { | ||
| for _, mac := range req.GetMacAddresses() { | ||
| slease.RemoveRecord4(mac) | ||
| } | ||
| return &pb.RemoveLeaseResponse{}, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
net.CIDRMaskreturnsnilif the mask length is invalid (e.g., negative or greater than the bit length). Ifmaskisnil, passing it toslease.AddRecord4can cause panics or unexpected behavior in the DHCP server. Please validate thatmaskis notnilbefore proceeding.