Skip to content

Commit

Permalink
Merge pull request #2826 from rewantsoni/fix-server
Browse files Browse the repository at this point in the history
fix panic in provider server while onboarding
  • Loading branch information
openshift-merge-bot[bot] authored Oct 1, 2024
2 parents 3b8151e + 2bb7cd9 commit b1c7177
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"encoding/json"
"encoding/pem"
"fmt"
"k8s.io/utils/ptr"
"math"
"net"
"slices"
Expand Down Expand Up @@ -119,14 +120,15 @@ func (s *OCSProviderServer) OnboardConsumer(ctx context.Context, req *pb.Onboard
klog.Errorf("failed to validate onboarding ticket for consumer %q. %v", req.ConsumerName, err)
return nil, status.Errorf(codes.InvalidArgument, "onboarding ticket is not valid. %v", err)
}
storageQuotaInGiB := ptr.Deref(onboardingTicket.StorageQuotaInGiB, 0)

if onboardingTicket.SubjectRole != services.ClientRole {
err := fmt.Errorf("unsupported ticket role for consumer %q, found %s, expected %s", req.ConsumerName, onboardingTicket.SubjectRole, services.ClientRole)
klog.Error(err)
return nil, status.Error(codes.InvalidArgument, err.Error())
}

storageConsumerUUID, err := s.consumerManager.Create(ctx, req, int(*onboardingTicket.StorageQuotaInGiB))
storageConsumerUUID, err := s.consumerManager.Create(ctx, req, int(storageQuotaInGiB))
if err != nil {
if !kerrors.IsAlreadyExists(err) && err != errTicketAlreadyExists {
return nil, status.Errorf(codes.Internal, "failed to create storageConsumer %q. %v", req.ConsumerName, err)
Expand Down

0 comments on commit b1c7177

Please sign in to comment.