-
Notifications
You must be signed in to change notification settings - Fork 56
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
GNOI Implementation of OS.Activate #351
base: master
Are you sure you want to change the base?
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
Files not reviewed (2)
- sonic_service_client/dbus_client_test.go: Evaluated as low risk
- common_utils/context.go: Evaluated as low risk
Comments suppressed due to low confidence (3)
gnoi_client/os/os.go:35
- [nitpick] The error message could be more descriptive. Consider changing it to 'Failed to unmarshal JSON: ' + err.Error()'.
panic(err.Error())
gnoi_client/os/os.go:39
- [nitpick] The error message could be more descriptive. Consider changing it to 'Failed to activate OS: ' + err.Error()'.
panic(err.Error())
gnoi_client/os/os.go:43
- [nitpick] The error message could be more descriptive. Consider changing it to 'Failed to marshal response: ' + err.Error()'.
panic(err.Error())
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (3)
- gnoi_client/os/verify.go: Evaluated as low risk
- common_utils/context.go: Evaluated as low risk
- gnoi_client/gnoi_client.go: Evaluated as low risk
image := req.GetVersion() | ||
log.Infof("Requested to activate image %s", image) | ||
|
||
dbus, err := ssc.NewDbusClient() |
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.
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.
Done.
} | ||
|
||
var resp gnoi_os_pb.ActivateResponse | ||
err = dbus.ActivateImage(image) |
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.
The logic checking for "not" and "exist" in err.Error() is fragile. It relies on string matching rather than structured error handling, which may break if error messages change.
Suggestion: If dbus.ActivateImage(image) provides structured error types, check against those instead of relying on string searches.
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.
I did try to do this previously but sonic-installer set-next-boot does not provide proper error code (it just return 1 instead, arguably it should return 2 (ENOENT)). The error code is propagated through DBUS and then to GNMI so I have to rely on the message.
I will add a check here and correct this in both host-services and sonic-installer script.
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.
I understand the sonic-installer set-next-boot command line just returned string, what I meant is actual place where calls command line then it did wrap over there.
admin@vslab1:~$ sudo sonic-installer set-next-boot foo
Error: Image does not exist
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.
Doing it in sonic-net/sonic-host-services#210, add a check for errno here. We can still keep the message check in an "either-or" condition just to be doubly safe.
}, | ||
} | ||
} | ||
return &resp, nil |
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.
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.
I don't think this is a server error. See https://github.com/openconfig/gnoi/blob/main/os/os.proto#L372, this is an application level error instead of server error.
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.
But this is server side handling? And since the err is not nil, you did wrap the response, how would the client of this server handle the error, only relying on response?
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.
Okay, I saw the gnoi_client just handles response. Do you think is there any other caller?
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.
This function is a grpc internal server implementation, so the only caller is grpc server. If we return error, that means the grpc handler cannot proceed because we encountered an internal error. "Image not found" is not that and based on the server definition in openconfig, we should report that directly to the client, instead of making it a server failure. Whatever clients want to do with the response error is up to the client.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -56,6 +56,8 @@ func main() { | |||
switch *config.Rpc { | |||
case "Verify": | |||
gnoi_os.Verify(conn, ctx) | |||
case "Activate": |
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.
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.
gnmi_server/gnoi.go
Outdated
@@ -161,6 +161,56 @@ func (srv *OSServer) Verify(ctx context.Context, req *gnoi_os_pb.VerifyRequest) | |||
return resp, nil | |||
} | |||
|
|||
func (srv *OSServer) Activate(ctx context.Context, req *gnoi_os_pb.ActivateRequest) (*gnoi_os_pb.ActivateResponse, error) { | |||
_, err := authenticate(srv.config, ctx, false) |
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.
Need RW permission
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.
Done.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Why I did it
Support OS.Activate for GNOI.
How I did it
Implement OS.Activate.
How to verify it
On physical switch:
Which release branch to backport (provide reason below if selected)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)