Skip to content

Commit b0a53a2

Browse files
committed
Error info
1 parent 26469e1 commit b0a53a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+136
-107
lines changed

docs/arch.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ In this document, examples will refer to both the [OpenStorage SDK Mock](install
1414
and Portworx drivers.
1515

1616
OpenStorage API calls are ment to be idempotent to ensure consistency across calls, unless
17-
otherwise specified.
17+
otherwise specified.
18+
19+
## Error Handling
20+
All API calls use the [standard gRPC status](https://github.com/grpc/grpc/blob/master/src/proto/grpc/status/status.proto).

docs/installing.md

+36-24
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,33 @@ sources. Here is a full example:
1515
package main
1616

1717
import (
18-
"context"
19-
"fmt"
20-
"os"
21-
22-
"github.com/libopenstorage/openstorage/api"
23-
"google.golang.org/grpc"
18+
"context"
19+
"fmt"
20+
"os"
21+
22+
"github.com/libopenstorage/openstorage/api"
23+
"google.golang.org/grpc"
24+
"google.golang.org/grpc/codes"
25+
"google.golang.org/grpc/status"
2426
)
2527

2628
func main() {
27-
conn, err := grpc.Dial("localhost:9100", grpc.WithInsecure())
28-
if err != nil {
29-
fmt.Println(err)
30-
os.Exit(1)
31-
}
32-
33-
c := api.NewOpenStorageClusterClient(conn)
34-
r, err := c.Enumerate(context.Background(), &api.ClusterEnumerateRequest{})
35-
if err != nil {
36-
fmt.Println(err)
37-
os.Exit(1)
38-
}
39-
fmt.Println(r)
29+
conn, err := grpc.Dial("localhost:9100", grpc.WithInsecure())
30+
if err != nil {
31+
fmt.Printf("Error: %v\n", err)
32+
os.Exit(1)
33+
}
34+
35+
c := api.NewOpenStorageClusterClient(conn)
36+
r, err := c.Enumerate(context.Background(), &api.ClusterEnumerateRequest{})
37+
if err != nil {
38+
serverError, _ := status.FromError(err)
39+
fmt.Printf("Error, code=%v, msg=%v\n",
40+
serverError.Code(),
41+
serverError.Message())
42+
os.Exit(uint32(serverError.Code()))
43+
}
44+
fmt.Println(r)
4045
}
4146
```
4247

@@ -52,7 +57,6 @@ You will need the files `api*.py` copied to your path. Here is a full example:
5257
# pip install grpcio grpcio-tools
5358
#
5459
# Then copy the api*.py files to the directory as your client
55-
#
5660
# More info: https://grpc.io/docs/quickstart/python.html
5761
#
5862
import grpc
@@ -64,12 +68,20 @@ channel = grpc.insecure_channel('localhost:9100')
6468
client = api_pb2_grpc.OpenStorageClusterStub(channel)
6569

6670
# Get cluster information
67-
en_resp = client.Enumerate(api_pb2.ClusterEnumerateRequest())
68-
print en_resp
71+
try:
72+
en_resp = client.Enumerate(api_pb2.ClusterEnumerateRequest())
73+
except grpc.RpcError as e:
74+
print('Enumerate failed: code={0} msg={1}'.format(e.code(), e.details()))
75+
else:
76+
print(en_resp)
6977

7078
# Get node info
71-
n_resp = client.Inspect(api_pb2.ClusterInspectRequest(node_id=en_resp.cluster.nodes[0].id))
72-
print n_resp
79+
try:
80+
n_resp = client.Inspect(api_pb2.ClusterInspectRequest(node_id=en_resp.cluster.nodes[0].id))
81+
except grpc.RpcError as e:
82+
print('Inspect failed: code={0} msg={1}'.format(e.code(), e.details()))
83+
else:
84+
print(n_resp)
7385
```
7486

7587
We may some day provide a python `pip` package, but do not have one at the moment.

w/Code.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
11381138
<script>
11391139
var gitbook = gitbook || [];
11401140
gitbook.push(function() {
1141-
gitbook.page.hasChanged({"page":{"title":"_Website tests","level":"3.1","depth":1,"next":{"title":"_WebTest","level":"3.1.1","depth":2,"path":"More.md","ref":"More.md","articles":[]},"previous":{"title":"enumerate","level":"2.3.5.10.3","depth":4,"path":"volumes/backups/scheds/enumerate.md","ref":"volumes/backups/scheds/enumerate.md","articles":[]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"Code.md","mtime":"2018-03-28T18:16:34.603Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T15:47:35.701Z"},"basePath":".","book":{"language":""}});
1141+
gitbook.page.hasChanged({"page":{"title":"_Website tests","level":"3.1","depth":1,"next":{"title":"_WebTest","level":"3.1.1","depth":2,"path":"More.md","ref":"More.md","articles":[]},"previous":{"title":"enumerate","level":"2.3.5.10.3","depth":4,"path":"volumes/backups/scheds/enumerate.md","ref":"volumes/backups/scheds/enumerate.md","articles":[]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"Code.md","mtime":"2018-03-28T18:16:34.603Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T16:12:40.384Z"},"basePath":".","book":{"language":""}});
11421142
});
11431143
</script>
11441144
</div>

w/Last.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
11111111
<script>
11121112
var gitbook = gitbook || [];
11131113
gitbook.push(function() {
1114-
gitbook.page.hasChanged({"page":{"title":"Last","level":"3.1.2","depth":2,"previous":{"title":"_WebTest","level":"3.1.1","depth":2,"path":"More.md","ref":"More.md","articles":[]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"Last.md","mtime":"2018-03-28T18:16:34.603Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T15:47:35.701Z"},"basePath":".","book":{"language":""}});
1114+
gitbook.page.hasChanged({"page":{"title":"Last","level":"3.1.2","depth":2,"previous":{"title":"_WebTest","level":"3.1.1","depth":2,"path":"More.md","ref":"More.md","articles":[]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"Last.md","mtime":"2018-03-28T18:16:34.603Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T16:12:40.384Z"},"basePath":".","book":{"language":""}});
11151115
});
11161116
</script>
11171117
</div>

w/More.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
11281128
<script>
11291129
var gitbook = gitbook || [];
11301130
gitbook.push(function() {
1131-
gitbook.page.hasChanged({"page":{"title":"_WebTest","level":"3.1.1","depth":2,"next":{"title":"Last","level":"3.1.2","depth":2,"path":"Last.md","ref":"Last.md","articles":[]},"previous":{"title":"_Website tests","level":"3.1","depth":1,"path":"Code.md","ref":"Code.md","articles":[{"title":"_WebTest","level":"3.1.1","depth":2,"path":"More.md","ref":"More.md","articles":[]},{"title":"Last","level":"3.1.2","depth":2,"path":"Last.md","ref":"Last.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"More.md","mtime":"2018-03-28T18:16:34.603Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T15:47:35.701Z"},"basePath":".","book":{"language":""}});
1131+
gitbook.page.hasChanged({"page":{"title":"_WebTest","level":"3.1.1","depth":2,"next":{"title":"Last","level":"3.1.2","depth":2,"path":"Last.md","ref":"Last.md","articles":[]},"previous":{"title":"_Website tests","level":"3.1","depth":1,"path":"Code.md","ref":"Code.md","articles":[{"title":"_WebTest","level":"3.1.1","depth":2,"path":"More.md","ref":"More.md","articles":[]},{"title":"Last","level":"3.1.2","depth":2,"path":"Last.md","ref":"Last.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"More.md","mtime":"2018-03-28T18:16:34.603Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T16:12:40.384Z"},"basePath":".","book":{"language":""}});
11321132
});
11331133
</script>
11341134
</div>

w/arch.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,8 @@ <h2 id="overview">Overview</h2>
10831083
and Portworx drivers.</p>
10841084
<p>OpenStorage API calls are ment to be idempotent to ensure consistency across calls, unless
10851085
otherwise specified.</p>
1086+
<h2 id="error-handling">Error Handling</h2>
1087+
<p>All API calls use the <a href="https://github.com/grpc/grpc/blob/master/src/proto/grpc/status/status.proto" target="_blank">standard gRPC status</a>.</p>
10861088

10871089

10881090
</section>
@@ -1126,7 +1128,7 @@ <h1 class="search-results-title">No results matching "<span class='search-query'
11261128
<script>
11271129
var gitbook = gitbook || [];
11281130
gitbook.push(function() {
1129-
gitbook.page.hasChanged({"page":{"title":"Architecture","level":"1.3","depth":1,"next":{"title":"Installing","level":"1.4","depth":1,"path":"installing.md","ref":"installing.md","articles":[]},"previous":{"title":"Status","level":"1.2","depth":1,"path":"status.md","ref":"status.md","articles":[]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"arch.md","mtime":"2018-04-30T15:34:06.207Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T15:47:35.701Z"},"basePath":".","book":{"language":""}});
1131+
gitbook.page.hasChanged({"page":{"title":"Architecture","level":"1.3","depth":1,"next":{"title":"Installing","level":"1.4","depth":1,"path":"installing.md","ref":"installing.md","articles":[]},"previous":{"title":"Status","level":"1.2","depth":1,"path":"status.md","ref":"status.md","articles":[]},"dir":"ltr"},"config":{"plugins":["codetabs","toggle-chapters","toggle-headers","edit-link","prism","github","page-toc","-highlight","-sharing"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/libopenstorage/openstorage/"},"search":{},"page-toc":{"position":"before-first","selector":".markdown-section h1, .markdown-section h2","showByDefault":true},"codetabs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"toggle-headers":{},"fontsettings":{"theme":"white","family":"sans","size":2},"edit-link":{"label":"Edit this page","base":"https://github.com/libopenstorage/libopenstorage.github.io/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"toggle-chapters":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"OpenStorage API","gitbook":">=3.2.1"},"file":{"path":"arch.md","mtime":"2018-04-30T15:51:52.891Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-04-30T16:12:40.384Z"},"basePath":".","book":{"language":""}});
11301132
});
11311133
</script>
11321134
</div>

0 commit comments

Comments
 (0)