Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
feature:implement supernode status switch
Browse files Browse the repository at this point in the history
Signed-off-by: yunfeiyangbuaa <[email protected]>
  • Loading branch information
starnop authored and yunfeiyanggzq committed Jul 26, 2019
1 parent 9033f63 commit 5479f3b
Show file tree
Hide file tree
Showing 31 changed files with 585 additions and 337 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
name: use markdown-link-check(https://github.com/tcort/markdown-link-check) to check links in markdown files
command: |
set +e
curl -OfsSL https://raw.githubusercontent.com/dragonflyoss/dragonfly-scripts/master/config/markdown-link-check-scripts.json
for name in $(find . -name \*.md | grep -v CHANGELOG); do
if [ -f $name ]; then
markdown-link-check -q $name;
markdown-link-check -q -v -c ./markdown-link-check-scripts.json $name;
if [ $? -ne 0 ]; then
code=1
fi
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file lists all contributors having contributed to this project.
# For how it is generated, see command "git log --format='%aN <%aE>' | sort -uf".

Alan <[email protected]>
alan <[email protected]>
Alibaba OSS <[email protected]>
aliwaredoc <[email protected]>
Allen Sun <[email protected]>
Expand Down
50 changes: 32 additions & 18 deletions apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ definitions:
tells whether it is a call from dfdaemon. dfdaemon is a long running
process which works for container engines. It translates the image
pulling request into raw requests into those dfget recognizes.
callSystem:
type: "string"
description: |
This attribute represents where the dfget requests come from. Dfget will pass
this field to supernode and supernode can do some checking and filtering via
black/white list mechanism to guarantee security, or some other purposes like debugging.
minLength: 1

PeerCreateRequest:
type: "object"
Expand Down Expand Up @@ -840,9 +847,9 @@ definitions:
callSystem:
type: "string"
description: |
This field is for debugging. When caller of dfget is using it to files, he can pass callSystem
name to dfget. When this field is passing to supernode, supernode has ability to filter them via
some black/white list to guarantee security, or some other purposes.
This attribute represents where the dfget requests come from. Dfget will pass
this field to supernode and supernode can do some checking and filtering via
black/white list mechanism to guarantee security, or some other purposes like debugging.
minLength: 1
filter:
type: "array"
Expand All @@ -859,6 +866,10 @@ definitions:
description: |
PeerID is used to uniquely identifies a peer which will be used to create a dfgetTask.
The value must be the value in the response after registering a peer.
supernodeIP:
type: "string"
description: "IP address of supernode which the peer connects to"


TaskCreateResponse:
type: "object"
Expand Down Expand Up @@ -954,20 +965,7 @@ definitions:
from source server as user's wish.
additionalProperties:
type: "string"
dfdaemon:
type: "boolean"
description: |
tells whether it is a call from dfdaemon. dfdaemon is a long running
process which works for container engines. It translates the image
pulling request into raw requests into those dfget recganises.
callSystem:
type: "string"
description: |
This field is for debugging. When caller of dfget is using it to files, he can pass callSystem
name to dfget. When this field is passing to supernode, supernode has ability to filter them via
some black/white list to guarantee security, or some other purposes.
minLength: 1


TaskUpdateRequest:
type: "object"
description: "request used to update task attributes."
Expand Down Expand Up @@ -1162,7 +1160,23 @@ definitions:
PeerID uniquely identifies a peer, and the cID uniquely identifies a
download task belonging to a peer. One peer can initiate multiple download tasks,
which means that one peer corresponds to multiple cIDs.
supernodeIP:
type: "string"
description: "IP address of supernode which the peer connects to"
dfdaemon:
type: "boolean"
description: |
tells whether it is a call from dfdaemon. dfdaemon is a long running
process which works for container engines. It translates the image
pulling request into raw requests into those dfget recganises.
callSystem:
type: "string"
description: |
This attribute represents where the dfget requests come from. Dfget will pass
this field to supernode and supernode can do some checking and filtering via
black/white list mechanism to guarantee security, or some other purposes like debugging.
minLength: 1

ErrorResponse:
type: "object"
description: |
Expand Down
33 changes: 33 additions & 0 deletions apis/types/df_get_task.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions apis/types/task_create_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions apis/types/task_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions apis/types/task_register_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions common/constants/dfget_super_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,17 @@ const (
ClientErrorFileNotExist = "FILE_NOT_EXIST"
ClientErrorFileMd5NotMatch = "FILE_MD5_NOT_MATCH"
)

/*the code of supernode ha status*/
const (
//SupernodeUseHaFalse means the supernode don't use ha
SupernodeUseHaFalse = 900
//SupernodeUseHaInit means supernode use ha and the status is init
SupernodeUseHaInit = 901
//SupernodeUseHaInit means supernode use ha and the status is standby
SupernodeUseHaStandby = 902
//SupernodeUseHaInit means supernode use ha and the status is active
SupernodeUseHaActive = 903
//SupernodeUseHaInit means supernode use ha and give up active status
SupernodeUsehakill = 904
)
2 changes: 1 addition & 1 deletion dfdaemon/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var fs = afero.NewOsFs()
//
// proxies:
// # proxy all http image layer download requests with dfget
// - regx: blobs/sha256:.*
// - regx: blobs/sha256.*
// # change http requests to some-registry to https and proxy them with dfget
// - regx: some-registry/
// use_https: true
Expand Down
2 changes: 1 addition & 1 deletion dfdaemon/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (ts *configTestSuite) TestProxyNew() {

func (ts *configTestSuite) TestProxyMatch() {
r := ts.Require()
p, err := NewProxy("blobs/sha256:.*", false, false)
p, err := NewProxy("blobs/sha256.*", false, false)
r.Nil(err)
r.NotNil(p)

Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Develop Guide helps (potential) developers/contributors to understand the thoery

### Design Doc

[Design Doc](./design) is content all about deisgn of Dragonfly. It includes all things taken into consideration at the very beginning, the architecture designed for all components in Dragonfly, the interactive workflow between components, all APIs in Dragonfly and some technical things else.
[Design Doc](./design) is content all about design of Dragonfly. It includes all things taken into consideration at the very beginning, the architecture designed for all components in Dragonfly, the interactive workflow between components, all APIs in Dragonfly and some technical things else.

### Test Guide

Expand Down
2 changes: 2 additions & 0 deletions docs/api_reference/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ A download process initiated by dfget or other clients.
|**peerID** <br>*optional*|PeerID uniquely identifies a peer, and the cID uniquely identifies a <br>download task belonging to a peer. One peer can initiate multiple download tasks, <br>which means that one peer corresponds to multiple cIDs.|string|
|**pieceSize** <br>*optional*|The size of pieces which is calculated as per the following strategy<br>1. If file's total size is less than 200MB, then the piece size is 4MB by default.<br>2. Otherwise, it equals to the smaller value between totalSize/100MB + 2 MB and 15MB.|integer (int32)|
|**status** <br>*optional*|The status of Dfget download process.|enum (WAITING, RUNNING, FAILED, SUCCESS)|
|**supernodeIP** <br>*optional*|IP address of supernode which the peer connects to|string|
|**taskId** <br>*optional*||string|


Expand Down Expand Up @@ -834,6 +835,7 @@ The returned information from supernode.
|**path** <br>*optional*|path is used in one peer A for uploading functionality. When peer B hopes<br>to get piece C from peer A, B must provide a URL for piece C.<br>Then when creating a task in supernode, peer A must provide this URL in request.|string|
|**peerID** <br>*optional*|PeerID is used to uniquely identifies a peer which will be used to create a dfgetTask.<br>The value must be the value in the response after registering a peer.|string|
|**rawURL** <br>*optional*|The is the resource's URL which user uses dfget to download. The location of URL can be anywhere, LAN or WAN.<br>For image distribution, this is image layer's URL in image registry.<br>The resource url is provided by command line parameter.|string|
|**supernodeIP** <br>*optional*|IP address of supernode which the peer connects to|string|
|**taskURL** <br>*optional*|taskURL is generated from rawURL. rawURL may contains some queries or parameter, dfget will filter some queries via<br>--filter parameter of dfget. The usage of it is that different rawURL may generate the same taskID.|string|


Expand Down
15 changes: 12 additions & 3 deletions docs/quick_start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All steps in this document are done on the same machine using the docker contain
## Step 1: Deploy Dragonfly Server (SuperNode)

```bash
docker run -d --name supernode --restart=always -p 8001:8001 -p 8002:8002 dragonflyoss/supernode:0.4.1
docker run -d --name supernode --restart=always -p 8001:8001 -p 8002:8002 -v /home/admin/supernode:/home/admin/supernode dragonflyoss/supernode:0.4.2
```

**NOTE**:
Expand All @@ -22,12 +22,12 @@ docker run -d --name supernode --restart=always -p 8001:8001 -p 8002:8002 dragon

```bash
SUPERNODE_IP=`docker inspect supernode -f '{{.NetworkSettings.Networks.bridge.IPAddress}}'`
docker run -d --name dfclient -p 65001:65001 dragonflyoss/dfclient:0.4.1 --registry https://index.docker.io --node $SUPERNODE_IP
docker run -d --name dfclient --restart=always -p 65001:65001 -v $HOME/.small-dragonfly:/root/.small-dragonfly dragonflyoss/dfclient:0.4.2 --registry https://index.docker.io --node $SUPERNODE_IP
```

**NOTE**:

- The `--registry` parameter specifies the mirrored image registry address, and `https://index.docker.io` is the address of official image registry, you can also set it to the others.
- The `--registry` parameter specifies the mirrored image registry address, and `https://index.docker.io` is the address of official image registry, you can also set it to the other **non-https image registries**.
- The `--node` parameter specifies the supernode's ip address. Here we use `docker inspect` to get the ip of supernode container. Since the supernode container exposes its ports, you can specify this parameter to node ip address as well.

## Step 3. Configure Docker Daemon
Expand Down Expand Up @@ -75,3 +75,12 @@ If the output of command above has content like
```

then Dragonfly is proved to work successfully.

## SEE ALSO

- [multi machines deployment](../user_guide/multi_machines_deployment.md) - experience Dragonfly on multiple machines
- [install server](../user_guide/install_server.md) - how to install the Dragonfly server
- [install client](../user_guide/install_client.md) - how to install the Dragonfly dfclient
- [docker proxy](../user_guide/docker_proxy.md) - make Dragonfly as HTTP proxy for docker daemon
- [proxy](../user_guide/proxy.md) - config proxy
- [download files](../user_guide/download_files.md) - download files with Dragonfly
2 changes: 1 addition & 1 deletion docs/user_guide/docker_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To use dfdaemon as HTTP proxy, first you need to add a proxy rule in

```yaml
proxies:
- regx: blobs/sha256:.*
- regx: blobs/sha256.*
```
This will proxy all requests for image layers with dfget.
Expand Down
Loading

0 comments on commit 5479f3b

Please sign in to comment.