Skip to content

Commit

Permalink
misc: minor fixed + add golang report to README
Browse files Browse the repository at this point in the history
Signed-off-by: Benedict Schlueter <[email protected]>
  • Loading branch information
benschlueter committed Oct 16, 2024
1 parent eec6bf5 commit dc883e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Delegatio

Delegatio is a framework that can be used to manage homework of classes (i.e. system security). The aim is to provide a infrastructure to let students work on problems independent of their hardware.
<p>
<a href="https://goreportcard.com/report/github.com/benschlueter/delegatio"><img src="https://goreportcard.com/badge/github.com/benschlueter/delegatio" alt="Go Report"></a>
</p>

Delegatio is a framework that can be used to manage homework of classes (i.e. system security). The aim is to provide a infrastructure to let students work on problems independent of their hardware.

# Installation
```bash
pacman -S libvirt qemu-full go mkosi make cmake
pacman -S libvirt qemu-full go mkosi make cmake
```
`systemd 253` or newer is required to build the images, otherwise a local systemd tree is needed [mkosi issue](https://github.com/systemd/mkosi/issues/1290)

Expand All @@ -17,7 +21,7 @@ make
```

# Run
Before we start the program we have create a kubernetes persistent storage. The easiest way to do that is through NFS.
Before we start the program we have create a kubernetes persistent storage. The easiest way to do that is through NFS.
First create a shared dir and make is user accessible.
```bash
sudo mkdir /mnt/myshareddir
Expand All @@ -39,7 +43,7 @@ Connecting is possible by sshing into the daemon, either on the kubernetes nodes
```bash
ssh testchallenge2@localhost -p 2200 -i ~/.ssh/id_rsa
```
You must provide your public keys in `./internal/config/global.go` (will be changed to read a config file soon)
You must provide your public keys in `./internal/config/global.go` (will be changed to read a config file soon)

## Limitations
Currently we only support one ControlPlane, thus we only have one KubeAPIServer. It might be possible that under high load (many port forward requests) the container is not capable of handing everything. However, we need to test it with some 100 users.
Expand Down
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func registerSignalHandler(ctx context.Context, log *zap.Logger) (context.Contex

func main() {
var imageLocation string
flag.StringVar(&imageLocation, "path", "", "path to the image to measure (required)")
flag.StringVar(&imageLocation, "path", "", "path to the image to load (required)")
flag.Parse()
zapconf := zap.NewDevelopmentConfig()
log, err := zapconf.Build()
Expand Down
18 changes: 9 additions & 9 deletions grader/gradeapi/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"google.golang.org/grpc/status"
)

func (a *API) updatePointsUser(_ context.Context, points int, user string) error {
a.logger.Info("updating points for user", zap.String("user", user), zap.Int("points", points))
func (a *API) updatePointsUser(_ context.Context, points int, uuid string, exerciseID int) error {
a.logger.Info("updating points", zap.String("uuid", uuid), zap.Int("points", points), zap.Int("exercise", exerciseID))
// ToDO: Update points for user and add database connection / container
return nil
}
Expand All @@ -47,8 +47,8 @@ func (a *API) RequestGrading(ctx context.Context, in *gradeproto.RequestGradingR
if err != nil {
a.logger.Error("failed to create graders", zap.Error(err))
}

switch id := in.GetExerciseId(); id {
exerciseID := in.GetExerciseId()
switch exerciseID {
case 1:
a.logger.Info("received grading request for id 1")
points, log, err = grader.GradeExerciseType1(ctx, in.GetSolution(), 1)
Expand All @@ -59,24 +59,24 @@ func (a *API) RequestGrading(ctx context.Context, in *gradeproto.RequestGradingR
a.logger.Info("received grading request for id 2")
}

if err := a.updatePointsUser(ctx, points, uuid); err != nil {
if err := a.updatePointsUser(ctx, points, uuid, exerciseID); err != nil {

Check failure on line 62 in grader/gradeapi/request.go

View workflow job for this annotation

GitHub Actions / test

cannot use exerciseID (variable of type int32) as int value in argument to a.updatePointsUser

Check failure on line 62 in grader/gradeapi/request.go

View workflow job for this annotation

GitHub Actions / golangci

cannot use exerciseID (variable of type int32) as int value in argument to a.updatePointsUser (typecheck)
return nil, status.Error(codes.Internal, "failed to update points")
}

return &gradeproto.RequestGradingResponse{Points: int32(points), Log: log}, nil
}

func (a *API) checkSignature(_ context.Context, UUID string, signature, solution []byte) error {
a.logger.Info("checking signature", zap.String("studentID", UUID))
exists, err := a.data().UUIDExists(UUID)
func (a *API) checkSignature(_ context.Context, uuid string, signature, solution []byte) error {
a.logger.Info("checking signature", zap.String("studentID", uuid))
exists, err := a.data().UUIDExists(uuid)
if err != nil {
return err
}
if !exists {
return status.Error(codes.NotFound, "user not found")
}
var userData config.UserInformation
if err := a.data().GetUUIDData(UUID, &userData); err != nil {
if err := a.data().GetUUIDData(uuid, &userData); err != nil {
return status.Error(codes.FailedPrecondition, "failed to get user data")
}
a.logger.Info("got user data", zap.String("publicKey", string(userData.PubKey)))
Expand Down

0 comments on commit dc883e5

Please sign in to comment.