diff --git a/api/manager/docs.go b/api/manager/docs.go index 40b37edbd6e..55c5213a1c0 100644 --- a/api/manager/docs.go +++ b/api/manager/docs.go @@ -1933,630 +1933,6 @@ const docTemplate = `{ } } }, - "/security-groups": { - "get": { - "description": "Get SecurityGroups", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Get SecurityGroups", - "parameters": [ - { - "type": "integer", - "default": 0, - "description": "current page", - "name": "page", - "in": "query", - "required": true - }, - { - "maximum": 50, - "minimum": 2, - "type": "integer", - "default": 10, - "description": "return max item count, default 10, max 50", - "name": "per_page", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "post": { - "description": "Create by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Create SecurityGroup", - "parameters": [ - { - "description": "SecurityGroup", - "name": "SecurityGroup", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.CreateSecurityGroupRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}": { - "get": { - "description": "Get SecurityGroup by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Get SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "patch": { - "description": "Update by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Update SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "SecurityGroup", - "name": "SecurityGroup", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.UpdateSecurityGroupRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}/scheduler-clusters/{scheduler_cluster_id}": { - "put": { - "description": "Add Scheduler to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Add Scheduler to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "scheduler cluster id", - "name": "scheduler_cluster_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}/security-rules/{security_rule_id}": { - "put": { - "description": "Add SecurityRule to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Add SecurityRule to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "security rule id", - "name": "security_rule_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "delete": { - "description": "Destroy SecurityRule to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Destroy SecurityRule to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "security rule id", - "name": "security_rule_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}/seed-peer-clusters/{seed_peer_cluster_id}": { - "put": { - "description": "Add SeedPeer to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Add SeedPeer to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "seed peer cluster id", - "name": "seed_peer_cluster_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-rules": { - "get": { - "description": "Get SecurityRules", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Get SecurityRules", - "parameters": [ - { - "type": "integer", - "default": 0, - "description": "current page", - "name": "page", - "in": "query", - "required": true - }, - { - "maximum": 50, - "minimum": 2, - "type": "integer", - "default": 10, - "description": "return max item count, default 10, max 50", - "name": "per_page", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "post": { - "description": "Create by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Create SecurityRule", - "parameters": [ - { - "description": "SecurityRule", - "name": "SecurityRule", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.CreateSecurityRuleRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-rules/{id}": { - "get": { - "description": "Get SecurityRule by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Get SecurityRule", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "patch": { - "description": "Update by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Update SecurityRule", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "SecurityRule", - "name": "SecurityRule", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.UpdateSecurityRuleRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/securityGroups/{id}": { - "delete": { - "description": "Destroy by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Destroy SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/securityRules/{id}": { - "delete": { - "description": "Destroy by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Destroy SecurityRule", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, "/seed-peer-clusters": { "get": { "description": "Get SeedPeerClusters", @@ -3728,9 +3104,6 @@ const docTemplate = `{ "scopes": { "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.JSONMap" }, - "security_group_id": { - "type": "integer" - }, "seed_peer_clusters": { "type": "array", "items": { @@ -3742,64 +3115,6 @@ const docTemplate = `{ } } }, - "d7y_io_dragonfly_v2_manager_models.SecurityGroup": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "security_rules": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "updated_at": { - "type": "string" - } - } - }, - "d7y_io_dragonfly_v2_manager_models.SecurityRule": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "domain": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "proxy_domain": { - "type": "string" - }, - "security_groups": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "updated_at": { - "type": "string" - } - } - }, "d7y_io_dragonfly_v2_manager_models.SeedPeer": { "type": "object", "properties": { @@ -4124,9 +3439,6 @@ const docTemplate = `{ "scopes": { "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.SchedulerClusterScopes" }, - "security_group_id": { - "type": "integer" - }, "seed_peer_cluster_id": { "type": "integer" } @@ -4167,41 +3479,6 @@ const docTemplate = `{ } } }, - "d7y_io_dragonfly_v2_manager_types.CreateSecurityGroupRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "bio": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "d7y_io_dragonfly_v2_manager_types.CreateSecurityRuleRequest": { - "type": "object", - "required": [ - "domain", - "name" - ], - "properties": { - "bio": { - "type": "string" - }, - "domain": { - "type": "string" - }, - "name": { - "type": "string" - }, - "proxy_domain": { - "type": "string" - } - } - }, "d7y_io_dragonfly_v2_manager_types.CreateSeedPeerClusterRequest": { "type": "object", "required": [ @@ -4583,9 +3860,6 @@ const docTemplate = `{ "scopes": { "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.SchedulerClusterScopes" }, - "security_group_id": { - "type": "integer" - }, "seed_peer_cluster_id": { "type": "integer" } @@ -4620,34 +3894,6 @@ const docTemplate = `{ } } }, - "d7y_io_dragonfly_v2_manager_types.UpdateSecurityGroupRequest": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "d7y_io_dragonfly_v2_manager_types.UpdateSecurityRuleRequest": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "domain": { - "type": "string" - }, - "name": { - "type": "string" - }, - "proxy_domain": { - "type": "string" - } - } - }, "d7y_io_dragonfly_v2_manager_types.UpdateSeedPeerClusterRequest": { "type": "object", "properties": { diff --git a/api/manager/swagger.json b/api/manager/swagger.json index c99ea56c5cd..0ede8d643e8 100644 --- a/api/manager/swagger.json +++ b/api/manager/swagger.json @@ -1927,630 +1927,6 @@ } } }, - "/security-groups": { - "get": { - "description": "Get SecurityGroups", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Get SecurityGroups", - "parameters": [ - { - "type": "integer", - "default": 0, - "description": "current page", - "name": "page", - "in": "query", - "required": true - }, - { - "maximum": 50, - "minimum": 2, - "type": "integer", - "default": 10, - "description": "return max item count, default 10, max 50", - "name": "per_page", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "post": { - "description": "Create by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Create SecurityGroup", - "parameters": [ - { - "description": "SecurityGroup", - "name": "SecurityGroup", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.CreateSecurityGroupRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}": { - "get": { - "description": "Get SecurityGroup by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Get SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "patch": { - "description": "Update by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Update SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "SecurityGroup", - "name": "SecurityGroup", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.UpdateSecurityGroupRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}/scheduler-clusters/{scheduler_cluster_id}": { - "put": { - "description": "Add Scheduler to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Add Scheduler to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "scheduler cluster id", - "name": "scheduler_cluster_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}/security-rules/{security_rule_id}": { - "put": { - "description": "Add SecurityRule to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Add SecurityRule to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "security rule id", - "name": "security_rule_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "delete": { - "description": "Destroy SecurityRule to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Destroy SecurityRule to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "security rule id", - "name": "security_rule_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-groups/{id}/seed-peer-clusters/{seed_peer_cluster_id}": { - "put": { - "description": "Add SeedPeer to SecurityGroup", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Add SeedPeer to SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "seed peer cluster id", - "name": "seed_peer_cluster_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-rules": { - "get": { - "description": "Get SecurityRules", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Get SecurityRules", - "parameters": [ - { - "type": "integer", - "default": 0, - "description": "current page", - "name": "page", - "in": "query", - "required": true - }, - { - "maximum": 50, - "minimum": 2, - "type": "integer", - "default": 10, - "description": "return max item count, default 10, max 50", - "name": "per_page", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "post": { - "description": "Create by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Create SecurityRule", - "parameters": [ - { - "description": "SecurityRule", - "name": "SecurityRule", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.CreateSecurityRuleRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/security-rules/{id}": { - "get": { - "description": "Get SecurityRule by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Get SecurityRule", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - }, - "patch": { - "description": "Update by json config", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Update SecurityRule", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "SecurityRule", - "name": "SecurityRule", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.UpdateSecurityRuleRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/securityGroups/{id}": { - "delete": { - "description": "Destroy by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityGroup" - ], - "summary": "Destroy SecurityGroup", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, - "/securityRules/{id}": { - "delete": { - "description": "Destroy by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "SecurityRule" - ], - "summary": "Destroy SecurityRule", - "parameters": [ - { - "type": "string", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - }, - "500": { - "description": "Internal Server Error" - } - } - } - }, "/seed-peer-clusters": { "get": { "description": "Get SeedPeerClusters", @@ -3722,9 +3098,6 @@ "scopes": { "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.JSONMap" }, - "security_group_id": { - "type": "integer" - }, "seed_peer_clusters": { "type": "array", "items": { @@ -3736,64 +3109,6 @@ } } }, - "d7y_io_dragonfly_v2_manager_models.SecurityGroup": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "security_rules": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule" - } - }, - "updated_at": { - "type": "string" - } - } - }, - "d7y_io_dragonfly_v2_manager_models.SecurityRule": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "domain": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "proxy_domain": { - "type": "string" - }, - "security_groups": { - "type": "array", - "items": { - "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup" - } - }, - "updated_at": { - "type": "string" - } - } - }, "d7y_io_dragonfly_v2_manager_models.SeedPeer": { "type": "object", "properties": { @@ -4118,9 +3433,6 @@ "scopes": { "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.SchedulerClusterScopes" }, - "security_group_id": { - "type": "integer" - }, "seed_peer_cluster_id": { "type": "integer" } @@ -4161,41 +3473,6 @@ } } }, - "d7y_io_dragonfly_v2_manager_types.CreateSecurityGroupRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "bio": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "d7y_io_dragonfly_v2_manager_types.CreateSecurityRuleRequest": { - "type": "object", - "required": [ - "domain", - "name" - ], - "properties": { - "bio": { - "type": "string" - }, - "domain": { - "type": "string" - }, - "name": { - "type": "string" - }, - "proxy_domain": { - "type": "string" - } - } - }, "d7y_io_dragonfly_v2_manager_types.CreateSeedPeerClusterRequest": { "type": "object", "required": [ @@ -4577,9 +3854,6 @@ "scopes": { "$ref": "#/definitions/d7y_io_dragonfly_v2_manager_types.SchedulerClusterScopes" }, - "security_group_id": { - "type": "integer" - }, "seed_peer_cluster_id": { "type": "integer" } @@ -4614,34 +3888,6 @@ } } }, - "d7y_io_dragonfly_v2_manager_types.UpdateSecurityGroupRequest": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "d7y_io_dragonfly_v2_manager_types.UpdateSecurityRuleRequest": { - "type": "object", - "properties": { - "bio": { - "type": "string" - }, - "domain": { - "type": "string" - }, - "name": { - "type": "string" - }, - "proxy_domain": { - "type": "string" - } - } - }, "d7y_io_dragonfly_v2_manager_types.UpdateSeedPeerClusterRequest": { "type": "object", "properties": { diff --git a/api/manager/swagger.yaml b/api/manager/swagger.yaml index 3dedb086fcb..77d4fa19c72 100644 --- a/api/manager/swagger.yaml +++ b/api/manager/swagger.yaml @@ -140,8 +140,6 @@ definitions: type: string scopes: $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.JSONMap' - security_group_id: - type: integer seed_peer_clusters: items: $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SeedPeerCluster' @@ -149,44 +147,6 @@ definitions: updated_at: type: string type: object - d7y_io_dragonfly_v2_manager_models.SecurityGroup: - properties: - bio: - type: string - created_at: - type: string - id: - type: integer - name: - type: string - security_rules: - items: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule' - type: array - updated_at: - type: string - type: object - d7y_io_dragonfly_v2_manager_models.SecurityRule: - properties: - bio: - type: string - created_at: - type: string - domain: - type: string - id: - type: integer - name: - type: string - proxy_domain: - type: string - security_groups: - items: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup' - type: array - updated_at: - type: string - type: object d7y_io_dragonfly_v2_manager_models.SeedPeer: properties: created_at: @@ -401,8 +361,6 @@ definitions: type: string scopes: $ref: '#/definitions/d7y_io_dragonfly_v2_manager_types.SchedulerClusterScopes' - security_group_id: - type: integer seed_peer_cluster_id: type: integer required: @@ -434,29 +392,6 @@ definitions: - port - scheduler_cluster_id type: object - d7y_io_dragonfly_v2_manager_types.CreateSecurityGroupRequest: - properties: - bio: - type: string - name: - type: string - required: - - name - type: object - d7y_io_dragonfly_v2_manager_types.CreateSecurityRuleRequest: - properties: - bio: - type: string - domain: - type: string - name: - type: string - proxy_domain: - type: string - required: - - domain - - name - type: object d7y_io_dragonfly_v2_manager_types.CreateSeedPeerClusterRequest: properties: bio: @@ -718,8 +653,6 @@ definitions: type: string scopes: $ref: '#/definitions/d7y_io_dragonfly_v2_manager_types.SchedulerClusterScopes' - security_group_id: - type: integer seed_peer_cluster_id: type: integer type: object @@ -742,24 +675,6 @@ definitions: scheduler_id: type: integer type: object - d7y_io_dragonfly_v2_manager_types.UpdateSecurityGroupRequest: - properties: - bio: - type: string - name: - type: string - type: object - d7y_io_dragonfly_v2_manager_types.UpdateSecurityRuleRequest: - properties: - bio: - type: string - domain: - type: string - name: - type: string - proxy_domain: - type: string - type: object d7y_io_dragonfly_v2_manager_types.UpdateSeedPeerClusterRequest: properties: bio: @@ -2101,423 +2016,6 @@ paths: summary: Update Scheduler tags: - Scheduler - /security-groups: - get: - consumes: - - application/json - description: Get SecurityGroups - parameters: - - default: 0 - description: current page - in: query - name: page - required: true - type: integer - - default: 10 - description: return max item count, default 10, max 50 - in: query - maximum: 50 - minimum: 2 - name: per_page - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup' - type: array - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Get SecurityGroups - tags: - - SecurityGroup - post: - consumes: - - application/json - description: Create by json config - parameters: - - description: SecurityGroup - in: body - name: SecurityGroup - required: true - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_types.CreateSecurityGroupRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup' - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Create SecurityGroup - tags: - - SecurityGroup - /security-groups/{id}: - get: - consumes: - - application/json - description: Get SecurityGroup by id - parameters: - - description: id - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup' - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Get SecurityGroup - tags: - - SecurityGroup - patch: - consumes: - - application/json - description: Update by json config - parameters: - - description: id - in: path - name: id - required: true - type: string - - description: SecurityGroup - in: body - name: SecurityGroup - required: true - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_types.UpdateSecurityGroupRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityGroup' - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Update SecurityGroup - tags: - - SecurityGroup - /security-groups/{id}/scheduler-clusters/{scheduler_cluster_id}: - put: - consumes: - - application/json - description: Add Scheduler to SecurityGroup - parameters: - - description: id - in: path - name: id - required: true - type: string - - description: scheduler cluster id - in: path - name: scheduler_cluster_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Add Scheduler to SecurityGroup - tags: - - SecurityGroup - /security-groups/{id}/security-rules/{security_rule_id}: - delete: - consumes: - - application/json - description: Destroy SecurityRule to SecurityGroup - parameters: - - description: id - in: path - name: id - required: true - type: string - - description: security rule id - in: path - name: security_rule_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Destroy SecurityRule to SecurityGroup - tags: - - SecurityGroup - put: - consumes: - - application/json - description: Add SecurityRule to SecurityGroup - parameters: - - description: id - in: path - name: id - required: true - type: string - - description: security rule id - in: path - name: security_rule_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Add SecurityRule to SecurityGroup - tags: - - SecurityGroup - /security-groups/{id}/seed-peer-clusters/{seed_peer_cluster_id}: - put: - consumes: - - application/json - description: Add SeedPeer to SecurityGroup - parameters: - - description: id - in: path - name: id - required: true - type: string - - description: seed peer cluster id - in: path - name: seed_peer_cluster_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Add SeedPeer to SecurityGroup - tags: - - SecurityGroup - /security-rules: - get: - consumes: - - application/json - description: Get SecurityRules - parameters: - - default: 0 - description: current page - in: query - name: page - required: true - type: integer - - default: 10 - description: return max item count, default 10, max 50 - in: query - maximum: 50 - minimum: 2 - name: per_page - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule' - type: array - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Get SecurityRules - tags: - - SecurityRule - post: - consumes: - - application/json - description: Create by json config - parameters: - - description: SecurityRule - in: body - name: SecurityRule - required: true - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_types.CreateSecurityRuleRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule' - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Create SecurityRule - tags: - - SecurityRule - /security-rules/{id}: - get: - consumes: - - application/json - description: Get SecurityRule by id - parameters: - - description: id - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule' - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Get SecurityRule - tags: - - SecurityRule - patch: - consumes: - - application/json - description: Update by json config - parameters: - - description: id - in: path - name: id - required: true - type: string - - description: SecurityRule - in: body - name: SecurityRule - required: true - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_types.UpdateSecurityRuleRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/d7y_io_dragonfly_v2_manager_models.SecurityRule' - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Update SecurityRule - tags: - - SecurityRule - /securityGroups/{id}: - delete: - consumes: - - application/json - description: Destroy by id - parameters: - - description: id - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Destroy SecurityGroup - tags: - - SecurityGroup - /securityRules/{id}: - delete: - consumes: - - application/json - description: Destroy by id - parameters: - - description: id - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - "400": - description: Bad Request - "404": - description: Not Found - "500": - description: Internal Server Error - summary: Destroy SecurityRule - tags: - - SecurityRule /seed-peer-clusters: get: consumes: diff --git a/build/package/nfpm/config/dfget.yaml b/build/package/nfpm/config/dfget.yaml index 68def3e87df..304fa0160dc 100644 --- a/build/package/nfpm/config/dfget.yaml +++ b/build/package/nfpm/config/dfget.yaml @@ -39,7 +39,6 @@ host: # geographical location and network topology location: "" idc: "" - securityDomain: "" # download service option download: diff --git a/client/config/dynconfig_manager.go b/client/config/dynconfig_manager.go index 3b4da12cbfd..41e91271adc 100644 --- a/client/config/dynconfig_manager.go +++ b/client/config/dynconfig_manager.go @@ -279,9 +279,8 @@ func (mc *managerClient) Get() (any, error) { Version: version.GitVersion, Commit: version.GitCommit, HostInfo: map[string]string{ - searcher.ConditionSecurityDomain: mc.config.Host.SecurityDomain, - searcher.ConditionIDC: mc.config.Host.IDC, - searcher.ConditionLocation: mc.config.Host.Location, + searcher.ConditionIDC: mc.config.Host.IDC, + searcher.ConditionLocation: mc.config.Host.Location, }, }) if err != nil { diff --git a/client/config/peerhost.go b/client/config/peerhost.go index d69fb354776..fd2f9848d92 100644 --- a/client/config/peerhost.go +++ b/client/config/peerhost.go @@ -281,8 +281,6 @@ type KeepAliveOption struct { } type HostOption struct { - // SecurityDomain is the security domain - SecurityDomain string `mapstructure:"securityDomain" yaml:"securityDomain"` // IDC for scheduler IDC string `mapstructure:"idc" yaml:"idc"` // Location for scheduler diff --git a/client/config/peerhost_darwin.go b/client/config/peerhost_darwin.go index 650e6bc726e..ae2abbd6122 100644 --- a/client/config/peerhost_darwin.go +++ b/client/config/peerhost_darwin.go @@ -50,10 +50,9 @@ var peerHostConfig = func() *DaemonOption { ScheduleTimeout: util.Duration{Duration: DefaultScheduleTimeout}, }, Host: HostOption{ - Hostname: fqdn.FQDNHostname, - SecurityDomain: "", - Location: "", - IDC: "", + Hostname: fqdn.FQDNHostname, + Location: "", + IDC: "", }, Download: DownloadOption{ CalculateDigest: true, diff --git a/client/config/peerhost_linux.go b/client/config/peerhost_linux.go index 133eab7b9b9..11285a543a8 100644 --- a/client/config/peerhost_linux.go +++ b/client/config/peerhost_linux.go @@ -50,10 +50,9 @@ var peerHostConfig = func() *DaemonOption { ScheduleTimeout: util.Duration{Duration: DefaultScheduleTimeout}, }, Host: HostOption{ - Hostname: fqdn.FQDNHostname, - SecurityDomain: "", - Location: "", - IDC: "", + Hostname: fqdn.FQDNHostname, + Location: "", + IDC: "", }, Download: DownloadOption{ CalculateDigest: true, diff --git a/client/config/peerhost_test.go b/client/config/peerhost_test.go index cda34445b59..2437f460bb8 100644 --- a/client/config/peerhost_test.go +++ b/client/config/peerhost_test.go @@ -285,11 +285,10 @@ func TestPeerHostOption_Load(t *testing.T) { DisableAutoBackSource: true, }, Host: HostOption{ - Hostname: "d7y.io", - SecurityDomain: "d7y.io", - Location: "0.0.0.0", - IDC: "d7y", - AdvertiseIP: net.IPv4zero, + Hostname: "d7y.io", + Location: "0.0.0.0", + IDC: "d7y", + AdvertiseIP: net.IPv4zero, }, Download: DownloadOption{ TotalRateLimit: util.RateLimit{ diff --git a/client/config/testdata/config/daemon.yaml b/client/config/testdata/config/daemon.yaml index 2d366d63f4b..ddb06692bab 100644 --- a/client/config/testdata/config/daemon.yaml +++ b/client/config/testdata/config/daemon.yaml @@ -36,7 +36,6 @@ host: advertiseIP: 0.0.0.0 location: 0.0.0.0 idc: d7y - securityDomain: d7y.io download: calculateDigest: true diff --git a/client/daemon/announcer/announcer.go b/client/daemon/announcer/announcer.go index 8b4d481f26b..c254d6a0e85 100644 --- a/client/daemon/announcer/announcer.go +++ b/client/daemon/announcer/announcer.go @@ -261,7 +261,6 @@ func (a *announcer) newAnnounceHostRequest() (*schedulerv1.AnnounceHostRequest, Network: &schedulerv1.Network{ TcpConnectionCount: uint32(len(tcpConnections)), UploadTcpConnectionCount: uint32(len(uploadTCPConnections)), - SecurityDomain: a.config.Host.SecurityDomain, Location: a.config.Host.Location, Idc: a.config.Host.IDC, }, diff --git a/client/daemon/daemon.go b/client/daemon/daemon.go index 5e577579fb0..3ac7c3d0dc9 100644 --- a/client/daemon/daemon.go +++ b/client/daemon/daemon.go @@ -127,14 +127,13 @@ func New(opt *config.DaemonOption, d dfpath.Dfpath) (Daemon, error) { } host := &schedulerv1.PeerHost{ - Id: idgen.HostIDV2(opt.Host.AdvertiseIP.String(), opt.Host.Hostname), - Ip: opt.Host.AdvertiseIP.String(), - RpcPort: int32(opt.Download.PeerGRPC.TCPListen.PortRange.Start), - DownPort: 0, - Hostname: opt.Host.Hostname, - SecurityDomain: opt.Host.SecurityDomain, - Location: opt.Host.Location, - Idc: opt.Host.IDC, + Id: idgen.HostIDV2(opt.Host.AdvertiseIP.String(), opt.Host.Hostname), + Ip: opt.Host.AdvertiseIP.String(), + RpcPort: int32(opt.Download.PeerGRPC.TCPListen.PortRange.Start), + DownPort: 0, + Hostname: opt.Host.Hostname, + Location: opt.Host.Location, + Idc: opt.Host.IDC, } var ( diff --git a/client/daemon/peer/peertask_conductor.go b/client/daemon/peer/peertask_conductor.go index bd47466baf8..93f066c1ffb 100644 --- a/client/daemon/peer/peertask_conductor.go +++ b/client/daemon/peer/peertask_conductor.go @@ -1387,7 +1387,6 @@ func (pt *peerTaskConductor) done() { TaskId: pt.GetTaskID(), PeerId: pt.GetPeerID(), SrcIp: pt.PeerHost.Ip, - SecurityDomain: pt.PeerHost.SecurityDomain, Idc: pt.PeerHost.Idc, Url: pt.request.Url, ContentLength: pt.GetContentLength(), @@ -1467,7 +1466,6 @@ func (pt *peerTaskConductor) fail() { TaskId: pt.GetTaskID(), PeerId: pt.GetPeerID(), SrcIp: pt.PeerHost.Ip, - SecurityDomain: pt.PeerHost.SecurityDomain, Idc: pt.PeerHost.Idc, Url: pt.request.Url, ContentLength: pt.GetContentLength(), diff --git a/deploy/docker-compose/template/dfget.template.yaml b/deploy/docker-compose/template/dfget.template.yaml index 13cc440d91c..445d42afeb6 100644 --- a/deploy/docker-compose/template/dfget.template.yaml +++ b/deploy/docker-compose/template/dfget.template.yaml @@ -74,8 +74,6 @@ host: location: "" # idc deployed by daemon idc: "" - # security domain deployed by daemon, network isolation between different security domains - securityDomain: "" # daemon hostname # hostname: "" diff --git a/deploy/docker-compose/template/seed-peer.template.yaml b/deploy/docker-compose/template/seed-peer.template.yaml index fc932ceb601..181e61d2da3 100644 --- a/deploy/docker-compose/template/seed-peer.template.yaml +++ b/deploy/docker-compose/template/seed-peer.template.yaml @@ -86,8 +86,6 @@ host: location: '' # IDC deployed by daemon. idc: '' - # Security domain deployed by daemon, network isolation between different security domains. - securityDomain: '' # Daemon hostname. # hostname: "" diff --git a/go.mod b/go.mod index 64d10f599aa..c58f8bbd59a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module d7y.io/dragonfly/v2 go 1.20 require ( - d7y.io/api v1.8.7 + d7y.io/api v1.8.8 github.com/RichardKnop/machinery v1.10.6 github.com/Showmax/go-fqdn v1.0.0 github.com/VividCortex/mysqlerr v1.0.0 diff --git a/go.sum b/go.sum index 6d2aef65783..6f058657752 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -d7y.io/api v1.8.7 h1:raANUY3biOBRfaaGo3dqWeGeKfbsEfNBL9YIXJEzG54= -d7y.io/api v1.8.7/go.mod h1:HIJMfhqiBHJ0yNVuOASQe6X0IVzOkxdLiWzcMM0xo2c= +d7y.io/api v1.8.8 h1:4JxGj+uvrqAYB3o8odxbcA6PySxuR4D6oOgAwqbq0HY= +d7y.io/api v1.8.8/go.mod h1:HIJMfhqiBHJ0yNVuOASQe6X0IVzOkxdLiWzcMM0xo2c= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= diff --git a/manager/database/database.go b/manager/database/database.go index bf0e6c5bdae..a79c135ece1 100644 --- a/manager/database/database.go +++ b/manager/database/database.go @@ -84,8 +84,6 @@ func migrate(db *gorm.DB) error { &models.SeedPeer{}, &models.SchedulerCluster{}, &models.Scheduler{}, - &models.SecurityRule{}, - &models.SecurityGroup{}, &models.User{}, &models.Oauth{}, &models.Config{}, diff --git a/manager/handlers/security_group.go b/manager/handlers/security_group.go deleted file mode 100644 index 2cba73f7129..00000000000 --- a/manager/handlers/security_group.go +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package handlers - -import ( - "net/http" - - "github.com/gin-gonic/gin" - - // nolint - _ "d7y.io/dragonfly/v2/manager/models" - "d7y.io/dragonfly/v2/manager/types" -) - -// @Summary Create SecurityGroup -// @Description Create by json config -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param SecurityGroup body types.CreateSecurityGroupRequest true "SecurityGroup" -// @Success 200 {object} models.SecurityGroup -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups [post] -func (h *Handlers) CreateSecurityGroup(ctx *gin.Context) { - var json types.CreateSecurityGroupRequest - if err := ctx.ShouldBindJSON(&json); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - securityGroup, err := h.service.CreateSecurityGroup(ctx.Request.Context(), json) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.JSON(http.StatusOK, securityGroup) -} - -// @Summary Destroy SecurityGroup -// @Description Destroy by id -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Success 200 -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /securityGroups/{id} [delete] -func (h *Handlers) DestroySecurityGroup(ctx *gin.Context) { - var params types.SecurityGroupParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - if err := h.service.DestroySecurityGroup(ctx.Request.Context(), params.ID); err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.Status(http.StatusOK) -} - -// @Summary Update SecurityGroup -// @Description Update by json config -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Param SecurityGroup body types.UpdateSecurityGroupRequest true "SecurityGroup" -// @Success 200 {object} models.SecurityGroup -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups/{id} [patch] -func (h *Handlers) UpdateSecurityGroup(ctx *gin.Context) { - var params types.SecurityGroupParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - var json types.UpdateSecurityGroupRequest - if err := ctx.ShouldBindJSON(&json); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - securityGroup, err := h.service.UpdateSecurityGroup(ctx.Request.Context(), params.ID, json) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.JSON(http.StatusOK, securityGroup) -} - -// @Summary Get SecurityGroup -// @Description Get SecurityGroup by id -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Success 200 {object} models.SecurityGroup -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups/{id} [get] -func (h *Handlers) GetSecurityGroup(ctx *gin.Context) { - var params types.SecurityGroupParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - securityGroup, err := h.service.GetSecurityGroup(ctx.Request.Context(), params.ID) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.JSON(http.StatusOK, securityGroup) -} - -// @Summary Get SecurityGroups -// @Description Get SecurityGroups -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param page query int true "current page" default(0) -// @Param per_page query int true "return max item count, default 10, max 50" default(10) minimum(2) maximum(50) -// @Success 200 {object} []models.SecurityGroup -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups [get] -func (h *Handlers) GetSecurityGroups(ctx *gin.Context) { - var query types.GetSecurityGroupsQuery - if err := ctx.ShouldBindQuery(&query); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - h.setPaginationDefault(&query.Page, &query.PerPage) - securityGroups, count, err := h.service.GetSecurityGroups(ctx.Request.Context(), query) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - h.setPaginationLinkHeader(ctx, query.Page, query.PerPage, int(count)) - ctx.JSON(http.StatusOK, securityGroups) -} - -// @Summary Add Scheduler to SecurityGroup -// @Description Add Scheduler to SecurityGroup -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Param scheduler_cluster_id path string true "scheduler cluster id" -// @Success 200 -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups/{id}/scheduler-clusters/{scheduler_cluster_id} [put] -func (h *Handlers) AddSchedulerClusterToSecurityGroup(ctx *gin.Context) { - var params types.AddSchedulerClusterToSecurityGroupParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - err := h.service.AddSchedulerClusterToSecurityGroup(ctx.Request.Context(), params.ID, params.SchedulerClusterID) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.Status(http.StatusOK) -} - -// @Summary Add SeedPeer to SecurityGroup -// @Description Add SeedPeer to SecurityGroup -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Param seed_peer_cluster_id path string true "seed peer cluster id" -// @Success 200 -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups/{id}/seed-peer-clusters/{seed_peer_cluster_id} [put] -func (h *Handlers) AddSeedPeerClusterToSecurityGroup(ctx *gin.Context) { - var params types.AddSeedPeerClusterToSecurityGroupParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - err := h.service.AddSeedPeerClusterToSecurityGroup(ctx.Request.Context(), params.ID, params.SeedPeerClusterID) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.Status(http.StatusOK) -} - -// @Summary Add SecurityRule to SecurityGroup -// @Description Add SecurityRule to SecurityGroup -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Param security_rule_id path string true "security rule id" -// @Success 200 -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups/{id}/security-rules/{security_rule_id} [put] -func (h *Handlers) AddSecurityRuleToSecurityGroup(ctx *gin.Context) { - var params types.AddSecurityRuleToSecurityGroupParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - err := h.service.AddSecurityRuleToSecurityGroup(ctx.Request.Context(), params.ID, params.SecurityRuleID) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.Status(http.StatusOK) -} - -// @Summary Destroy SecurityRule to SecurityGroup -// @Description Destroy SecurityRule to SecurityGroup -// @Tags SecurityGroup -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Param security_rule_id path string true "security rule id" -// @Success 200 -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-groups/{id}/security-rules/{security_rule_id} [delete] -func (h *Handlers) DestroySecurityRuleToSecurityGroup(ctx *gin.Context) { - var params types.AddSecurityRuleToSecurityGroupParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - err := h.service.DestroySecurityRuleToSecurityGroup(ctx.Request.Context(), params.ID, params.SecurityRuleID) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.Status(http.StatusOK) -} diff --git a/manager/handlers/security_rule.go b/manager/handlers/security_rule.go deleted file mode 100644 index b8453658294..00000000000 --- a/manager/handlers/security_rule.go +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package handlers - -import ( - "net/http" - - "github.com/gin-gonic/gin" - - // nolint - _ "d7y.io/dragonfly/v2/manager/models" - "d7y.io/dragonfly/v2/manager/types" -) - -// @Summary Create SecurityRule -// @Description Create by json config -// @Tags SecurityRule -// @Accept json -// @Produce json -// @Param SecurityRule body types.CreateSecurityRuleRequest true "SecurityRule" -// @Success 200 {object} models.SecurityRule -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-rules [post] -func (h *Handlers) CreateSecurityRule(ctx *gin.Context) { - var json types.CreateSecurityRuleRequest - if err := ctx.ShouldBindJSON(&json); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - securityRule, err := h.service.CreateSecurityRule(ctx.Request.Context(), json) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.JSON(http.StatusOK, securityRule) -} - -// @Summary Destroy SecurityRule -// @Description Destroy by id -// @Tags SecurityRule -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Success 200 -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /securityRules/{id} [delete] -func (h *Handlers) DestroySecurityRule(ctx *gin.Context) { - var params types.SecurityRuleParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - if err := h.service.DestroySecurityRule(ctx.Request.Context(), params.ID); err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.Status(http.StatusOK) -} - -// @Summary Update SecurityRule -// @Description Update by json config -// @Tags SecurityRule -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Param SecurityRule body types.UpdateSecurityRuleRequest true "SecurityRule" -// @Success 200 {object} models.SecurityRule -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-rules/{id} [patch] -func (h *Handlers) UpdateSecurityRule(ctx *gin.Context) { - var params types.SecurityRuleParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - var json types.UpdateSecurityRuleRequest - if err := ctx.ShouldBindJSON(&json); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - securityRule, err := h.service.UpdateSecurityRule(ctx.Request.Context(), params.ID, json) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.JSON(http.StatusOK, securityRule) -} - -// @Summary Get SecurityRule -// @Description Get SecurityRule by id -// @Tags SecurityRule -// @Accept json -// @Produce json -// @Param id path string true "id" -// @Success 200 {object} models.SecurityRule -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-rules/{id} [get] -func (h *Handlers) GetSecurityRule(ctx *gin.Context) { - var params types.SecurityRuleParams - if err := ctx.ShouldBindUri(¶ms); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - securityRule, err := h.service.GetSecurityRule(ctx.Request.Context(), params.ID) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - ctx.JSON(http.StatusOK, securityRule) -} - -// @Summary Get SecurityRules -// @Description Get SecurityRules -// @Tags SecurityRule -// @Accept json -// @Produce json -// @Param page query int true "current page" default(0) -// @Param per_page query int true "return max item count, default 10, max 50" default(10) minimum(2) maximum(50) -// @Success 200 {object} []models.SecurityRule -// @Failure 400 -// @Failure 404 -// @Failure 500 -// @Router /security-rules [get] -func (h *Handlers) GetSecurityRules(ctx *gin.Context) { - var query types.GetSecurityRulesQuery - if err := ctx.ShouldBindQuery(&query); err != nil { - ctx.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()}) - return - } - - h.setPaginationDefault(&query.Page, &query.PerPage) - securityRules, count, err := h.service.GetSecurityRules(ctx.Request.Context(), query) - if err != nil { - ctx.Error(err) // nolint: errcheck - return - } - - h.setPaginationLinkHeader(ctx, query.Page, query.PerPage, int(count)) - ctx.JSON(http.StatusOK, securityRules) -} diff --git a/manager/models/scheduler_cluster.go b/manager/models/scheduler_cluster.go index 95138cece9c..763f37131bc 100644 --- a/manager/models/scheduler_cluster.go +++ b/manager/models/scheduler_cluster.go @@ -26,7 +26,5 @@ type SchedulerCluster struct { IsDefault bool `gorm:"column:is_default;not null;default:false;comment:default scheduler cluster" json:"is_default"` SeedPeerClusters []SeedPeerCluster `gorm:"many2many:seed_peer_cluster_scheduler_cluster;" json:"seed_peer_clusters"` Schedulers []Scheduler `json:"-"` - SecurityGroupID uint `gorm:"comment:security group id" json:"security_group_id"` - SecurityGroup SecurityGroup `json:"-"` Jobs []Job `gorm:"many2many:job_scheduler_cluster;" json:"jobs"` } diff --git a/manager/models/security_group.go b/manager/models/security_group.go deleted file mode 100644 index 8c087ddcece..00000000000 --- a/manager/models/security_group.go +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package models - -type SecurityGroup struct { - BaseModel - Name string `gorm:"column:name;type:varchar(256);index:uk_security_group_name,unique;not null;comment:name" json:"name"` - BIO string `gorm:"column:bio;type:varchar(1024);comment:biography" json:"bio"` - SecurityRules []SecurityRule `gorm:"many2many:security_group_security_rule;" json:"security_rules"` - SchedulerClusters []SchedulerCluster `json:"-"` -} diff --git a/manager/models/security_rule.go b/manager/models/security_rule.go deleted file mode 100644 index 69d122c47fd..00000000000 --- a/manager/models/security_rule.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package models - -type SecurityRule struct { - BaseModel - Name string `gorm:"column:name;type:varchar(256);index:uk_security_rule_name,unique;not null;comment:name" json:"name"` - BIO string `gorm:"column:bio;type:varchar(1024);comment:biography" json:"bio"` - Domain string `gorm:"column:domain;type:varchar(256);index:uk_security_rule_domain,unique;not null;comment:domain" json:"domain"` - ProxyDomain string `gorm:"column:proxy_domain;type:varchar(1024);comment:proxy domain" json:"proxy_domain"` - SecurityGroups []SecurityGroup `gorm:"many2many:security_group_security_rule;" json:"security_groups"` -} diff --git a/manager/router/router.go b/manager/router/router.go index 3e3eb6f66f3..b8968d92e0f 100644 --- a/manager/router/router.go +++ b/manager/router/router.go @@ -169,26 +169,6 @@ func Init(cfg *config.Config, logDir string, service service.Service, enforcer * sp.GET(":id", h.GetSeedPeer) sp.GET("", h.GetSeedPeers) - // Security Rule - sr := apiv1.Group("/security-rules", jwt.MiddlewareFunc(), rbac) - sr.POST("", h.CreateSecurityRule) - sr.DELETE(":id", h.DestroySecurityRule) - sr.PATCH(":id", h.UpdateSecurityRule) - sr.GET(":id", h.GetSecurityRule) - sr.GET("", h.GetSecurityRules) - - // Security Group - sg := apiv1.Group("/security-groups", jwt.MiddlewareFunc(), rbac) - sg.POST("", h.CreateSecurityGroup) - sg.DELETE(":id", h.DestroySecurityGroup) - sg.PATCH(":id", h.UpdateSecurityGroup) - sg.GET(":id", h.GetSecurityGroup) - sg.GET("", h.GetSecurityGroups) - sg.PUT(":id/scheduler-clusters/:scheduler_cluster_id", h.AddSchedulerClusterToSecurityGroup) - sg.PUT(":id/seed-peer-clusters/:seed_peer_cluster_id", h.AddSeedPeerClusterToSecurityGroup) - sg.PUT(":id/security-rules/:security_rule_id", h.AddSecurityRuleToSecurityGroup) - sg.DELETE(":id/security-rules/:security_rule_id", h.DestroySecurityRuleToSecurityGroup) - // Bucket bucket := apiv1.Group("/buckets", jwt.MiddlewareFunc(), rbac) bucket.POST("", h.CreateBucket) diff --git a/manager/rpcserver/manager_server_v1.go b/manager/rpcserver/manager_server_v1.go index 2b1adaea896..c642ad9d857 100644 --- a/manager/rpcserver/manager_server_v1.go +++ b/manager/rpcserver/manager_server_v1.go @@ -495,7 +495,7 @@ func (s *managerServerV1) ListSchedulers(ctx context.Context, req *managerv1.Lis // Cache miss and search scheduler cluster. var schedulerClusters []models.SchedulerCluster - if err := s.db.WithContext(ctx).Preload("SecurityGroup.SecurityRules").Preload("SeedPeerClusters.SeedPeers", "state = ?", "active"). + if err := s.db.WithContext(ctx).Preload("SeedPeerClusters.SeedPeers", "state = ?", "active"). Preload("Schedulers", "state = ?", "active").Find(&schedulerClusters).Error; err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/manager/rpcserver/manager_server_v2.go b/manager/rpcserver/manager_server_v2.go index 57e9602e3e5..410c04bdb1c 100644 --- a/manager/rpcserver/manager_server_v2.go +++ b/manager/rpcserver/manager_server_v2.go @@ -495,7 +495,7 @@ func (s *managerServerV2) ListSchedulers(ctx context.Context, req *managerv2.Lis // Cache miss and search scheduler cluster. var schedulerClusters []models.SchedulerCluster - if err := s.db.WithContext(ctx).Preload("SecurityGroup.SecurityRules").Preload("SeedPeerClusters.SeedPeers", "state = ?", "active").Preload("Schedulers", "state = ?", "active").Find(&schedulerClusters).Error; err != nil { + if err := s.db.WithContext(ctx).Preload("SeedPeerClusters.SeedPeers", "state = ?", "active").Preload("Schedulers", "state = ?", "active").Find(&schedulerClusters).Error; err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/manager/searcher/searcher.go b/manager/searcher/searcher.go index d116a2dbafe..bbb243c5c71 100644 --- a/manager/searcher/searcher.go +++ b/manager/searcher/searcher.go @@ -37,9 +37,6 @@ import ( ) const ( - // Condition security domain key. - ConditionSecurityDomain = "security_domain" - // Condition IDC key. ConditionIDC = "idc" @@ -48,20 +45,17 @@ const ( ) const ( - // securityDomainAffinityWeight is security domain affinity weight. - securityDomainAffinityWeight float64 = 0.4 - // cidrAffinityWeight is CIDR affinity weight. - cidrAffinityWeight float64 = 0.3 + cidrAffinityWeight float64 = 0.4 // idcAffinityWeight is IDC affinity weight. - idcAffinityWeight float64 = 0.15 + idcAffinityWeight float64 = 0.35 // locationAffinityWeight is location affinity weight. - locationAffinityWeight = 0.1 + locationAffinityWeight = 0.24 // clusterTypeWeight is cluster type weight. - clusterTypeWeight float64 = 0.05 + clusterTypeWeight float64 = 0.01 ) const ( @@ -141,39 +135,13 @@ func (s *searcher) FindSchedulerClusters(ctx context.Context, schedulerClusters // Filter the scheduler clusters that dfdaemon can be used. func FilterSchedulerClusters(conditions map[string]string, schedulerClusters []models.SchedulerCluster) []models.SchedulerCluster { var clusters []models.SchedulerCluster - securityDomain := conditions[ConditionSecurityDomain] for _, schedulerCluster := range schedulerClusters { // There are no active schedulers in the scheduler cluster if len(schedulerCluster.Schedulers) == 0 { continue } - // Dfdaemon security_domain does not exist, matching all scheduler clusters - if securityDomain == "" { - clusters = append(clusters, schedulerCluster) - continue - } - - // Scheduler cluster is default, matching all dfdaemons - if schedulerCluster.IsDefault { - clusters = append(clusters, schedulerCluster) - continue - } - - // Scheduler cluster SecurityRules does not exist, matching all dfdaemons - if len(schedulerCluster.SecurityGroup.SecurityRules) == 0 { - clusters = append(clusters, schedulerCluster) - continue - } - - // If security_domain exists for dfdaemon and - // scheduler cluster SecurityRules also exists, - // then security_domain and SecurityRules are equal to match. - for _, securityRule := range schedulerCluster.SecurityGroup.SecurityRules { - if strings.EqualFold(securityRule.Domain, securityDomain) { - clusters = append(clusters, schedulerCluster) - } - } + clusters = append(clusters, schedulerCluster) } return clusters @@ -181,26 +149,12 @@ func FilterSchedulerClusters(conditions map[string]string, schedulerClusters []m // Evaluate the degree of matching between scheduler cluster and dfdaemon. func Evaluate(ip, hostname string, conditions map[string]string, scopes Scopes, cluster models.SchedulerCluster, log *zap.SugaredLogger) float64 { - return securityDomainAffinityWeight*calculateSecurityDomainAffinityScore(conditions[ConditionSecurityDomain], cluster.SecurityGroup.SecurityRules) + - cidrAffinityWeight*calculateCIDRAffinityScore(ip, scopes.CIDRs, log) + + return cidrAffinityWeight*calculateCIDRAffinityScore(ip, scopes.CIDRs, log) + idcAffinityWeight*calculateIDCAffinityScore(conditions[ConditionIDC], scopes.IDC) + locationAffinityWeight*calculateMultiElementAffinityScore(conditions[ConditionLocation], scopes.Location) + clusterTypeWeight*calculateClusterTypeScore(cluster) } -// calculateSecurityDomainAffinityScore 0.0~1.0 larger and better. -func calculateSecurityDomainAffinityScore(securityDomain string, securityRules []models.SecurityRule) float64 { - if securityDomain == "" { - return minScore - } - - if len(securityRules) == 0 { - return minScore - } - - return maxScore -} - // calculateCIDRAffinityScore 0.0~1.0 larger and better. func calculateCIDRAffinityScore(ip string, cidrs []string, log *zap.SugaredLogger) float64 { // Construct CIDR ranger. @@ -238,7 +192,7 @@ func calculateIDCAffinityScore(dst, src string) float64 { return minScore } - if strings.EqualFold(dst, src) { + if dst == src { return maxScore } @@ -247,7 +201,7 @@ func calculateIDCAffinityScore(dst, src string) float64 { // it gets the max score of idc. srcElements := strings.Split(src, types.AffinitySeparator) for _, srcElement := range srcElements { - if strings.EqualFold(dst, srcElement) { + if dst == srcElement { return maxScore } } @@ -261,7 +215,7 @@ func calculateMultiElementAffinityScore(dst, src string) float64 { return minScore } - if strings.EqualFold(dst, src) { + if dst == src { return maxScore } @@ -277,9 +231,10 @@ func calculateMultiElementAffinityScore(dst, src string) float64 { } for i := 0; i < elementLen; i++ { - if !strings.EqualFold(dstElements[i], srcElements[i]) { + if dstElements[i] != srcElements[i] { break } + score++ } diff --git a/manager/searcher/searcher_test.go b/manager/searcher/searcher_test.go index 69d63430dea..2297794a3b9 100644 --- a/manager/searcher/searcher_test.go +++ b/manager/searcher/searcher_test.go @@ -43,47 +43,11 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { assert.EqualError(err, "empty scheduler clusters") }, }, - { - name: "security_domain does not match", - schedulerClusters: []models.SchedulerCluster{ - { - Name: "foo", - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-2", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "foo", - State: "active", - }, - }, - }, - { - Name: "bar", - }, - }, - conditions: map[string]string{"security_domain": "domain-1"}, - expect: func(t *testing.T, data []models.SchedulerCluster, err error) { - assert := assert.New(t) - assert.Error(err) - }, - }, { name: "scheduler clusters have default cluster", schedulerClusters: []models.SchedulerCluster{ { Name: "foo", - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-2", - }, - }, - }, Schedulers: []models.Scheduler{ { Hostname: "foo", @@ -101,110 +65,12 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { }, IsDefault: true, }, - { - Name: "baz", - Schedulers: []models.Scheduler{ - { - Hostname: "baz", - State: "active", - }, - }, - }, }, - conditions: map[string]string{"security_domain": "domain-1"}, - expect: func(t *testing.T, data []models.SchedulerCluster, err error) { - assert := assert.New(t) - assert.Equal(data[0].Name, "bar") - assert.Equal(data[1].Name, "baz") - assert.Equal(len(data), 2) - }, - }, - { - name: "scheduler cluster SecurityRules does not exist", - schedulerClusters: []models.SchedulerCluster{ - { - Name: "foo", - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-2", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "foo", - State: "active", - }, - }, - }, - { - Name: "bar", - Schedulers: []models.Scheduler{ - { - Hostname: "bar", - State: "active", - }, - }, - }, - }, - conditions: map[string]string{"security_domain": "domain-1"}, + conditions: map[string]string{}, expect: func(t *testing.T, data []models.SchedulerCluster, err error) { assert := assert.New(t) assert.Equal(data[0].Name, "bar") - assert.Equal(len(data), 1) - }, - }, - { - name: "match according to security_domain condition", - schedulerClusters: []models.SchedulerCluster{ - { - Name: "foo", - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-2", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "foo", - State: "active", - }, - }, - }, - { - Name: "bar", - Schedulers: []models.Scheduler{ - { - Hostname: "bar", - State: "active", - }, - }, - }, - { - Name: "baz", - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-1", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "baz", - State: "active", - }, - }, - }, - }, - conditions: map[string]string{"security_domain": "domain-1"}, - expect: func(t *testing.T, data []models.SchedulerCluster, err error) { - assert := assert.New(t) - assert.Equal(data[0].Name, "baz") - assert.Equal(data[1].Name, "bar") + assert.Equal(data[1].Name, "foo") assert.Equal(len(data), 2) }, }, @@ -311,57 +177,14 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { }, }, { - name: "match according to location and idc condition", - schedulerClusters: []models.SchedulerCluster{ - { - Name: "foo", - Scopes: map[string]any{ - "location": "location-1|location-2", - "idc": "idc-1|idc-2", - }, - Schedulers: []models.Scheduler{ - { - Hostname: "foo", - State: "active", - }, - }, - }, - { - Name: "bar", - Schedulers: []models.Scheduler{ - { - Hostname: "bar", - State: "active", - }, - }, - }, - }, - conditions: map[string]string{ - "location": "location-1", - "idc": "idc-1", - }, - expect: func(t *testing.T, data []models.SchedulerCluster, err error) { - assert := assert.New(t) - assert.Equal(data[0].Name, "foo") - assert.Equal(data[1].Name, "bar") - assert.Equal(len(data), 2) - }, - }, - { - name: "match according to security_domain and location conditions", + name: "match according to idc and location conditions", schedulerClusters: []models.SchedulerCluster{ { Name: "foo", Scopes: map[string]any{ + "idc": "idc-3", "location": "location-1", }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-1", - }, - }, - }, Schedulers: []models.Scheduler{ { Hostname: "foo", @@ -371,179 +194,9 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { }, { Name: "bar", - Schedulers: []models.Scheduler{ - { - Hostname: "bar", - State: "active", - }, - }, - }, - }, - conditions: map[string]string{ - "security_domain": "domain-1", - "location": "location-1", - }, - expect: func(t *testing.T, data []models.SchedulerCluster, err error) { - assert := assert.New(t) - assert.Equal(data[0].Name, "foo") - assert.Equal(data[1].Name, "bar") - assert.Equal(len(data), 2) - }, - }, - { - name: "match according to security_domain and idc conditions", - schedulerClusters: []models.SchedulerCluster{ - { - Name: "foo", - Scopes: map[string]any{ - "idc": "idc-1", - }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-1", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "foo", - State: "active", - }, - }, - }, - { - Name: "bar", - Schedulers: []models.Scheduler{ - { - Hostname: "bar", - State: "active", - }, - }, - }, - }, - conditions: map[string]string{ - "security_domain": "domain-1", - "idc": "idc-1", - }, - expect: func(t *testing.T, data []models.SchedulerCluster, err error) { - assert := assert.New(t) - assert.Equal(data[0].Name, "foo") - assert.Equal(data[1].Name, "bar") - assert.Equal(len(data), 2) - }, - }, - { - name: "match according to security_domain, idc and location conditions", - schedulerClusters: []models.SchedulerCluster{ - { - Name: "foo", Scopes: map[string]any{ "idc": "idc-1", - "location": "location-1", - }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-1", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "foo", - State: "active", - }, - }, - }, - { - Name: "bar", - Scopes: map[string]any{ - "idc": "idc-2", - "location": "location-1|location-2", - }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-1", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "bar", - State: "active", - }, - }, - }, - { - Name: "baz", - Scopes: map[string]any{ - "idc": "idc-2", - "location": "location-1", - }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-2", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "baz", - State: "active", - }, - }, - }, - }, - conditions: map[string]string{ - "security_domain": "domain-1", - "idc": "idc-1|idc-2", - "location": "location-1|location-2", - }, - expect: func(t *testing.T, data []models.SchedulerCluster, err error) { - assert := assert.New(t) - assert.Equal(data[0].Name, "bar") - assert.Equal(data[1].Name, "foo") - assert.Equal(len(data), 2) - }, - }, - { - name: "match according to all conditions", - schedulerClusters: []models.SchedulerCluster{ - { - Name: "foo", - Scopes: map[string]any{ - "idc": "idc-1", - "location": "location-2", - }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-1", - }, - }, - }, - Schedulers: []models.Scheduler{ - { - Hostname: "foo", - State: "active", - }, - }, - }, - { - Name: "bar", - Scopes: map[string]any{ - "idc": "idc-1", - "location": "location-1", - }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-1", - }, - }, + "location": "location-3", }, Schedulers: []models.Scheduler{ { @@ -568,8 +221,8 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { { Name: "bax", Scopes: map[string]any{ - "idc": "idc-1", - "location": "location-2", + "idc": "idc-3", + "location": "location-3", }, Schedulers: []models.Scheduler{ { @@ -585,13 +238,6 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { "idc": "idc-1", "location": "location-2", }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "domain-2", - }, - }, - }, Schedulers: []models.Scheduler{ { Hostname: "bac", @@ -601,17 +247,17 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { }, }, conditions: map[string]string{ - "security_domain": "domain-1", - "idc": "idc-1|idc-2", - "location": "location-1|location-2", + "idc": "idc-1", + "location": "location-1|location-2", }, expect: func(t *testing.T, data []models.SchedulerCluster, err error) { assert := assert.New(t) - assert.Equal(data[0].Name, "bar") - assert.Equal(data[1].Name, "foo") - assert.Equal(data[2].Name, "baz") - assert.Equal(data[3].Name, "bax") - assert.Equal(len(data), 4) + assert.Equal(data[0].Name, "baz") + assert.Equal(data[1].Name, "bar") + assert.Equal(data[2].Name, "bac") + assert.Equal(data[3].Name, "foo") + assert.Equal(data[4].Name, "bax") + assert.Equal(len(data), 5) }, }, { @@ -624,13 +270,6 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { "location": "LOCATION-2", "cidrs": []string{"128.168.1.0/24"}, }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "DOMAIN-1", - }, - }, - }, Schedulers: []models.Scheduler{ { Hostname: "foo", @@ -645,13 +284,6 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { "location": "LOCATION-1", "cidrs": []string{"128.168.1.0/24"}, }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "DOMAIN-1", - }, - }, - }, Schedulers: []models.Scheduler{ { Hostname: "bar", @@ -695,13 +327,6 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { "location": "LOCATION-2", "cidrs": []string{"128.168.1.0/24"}, }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "DOMAIN-2", - }, - }, - }, Schedulers: []models.Scheduler{ { Hostname: "bac", @@ -716,13 +341,21 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { "location": "LOCATION-2", "cidrs": []string{"128.168.1.0/24"}, }, - SecurityGroup: models.SecurityGroup{ - SecurityRules: []models.SecurityRule{ - { - Domain: "DOMAIN-2", - }, + Schedulers: []models.Scheduler{ + { + Hostname: "bae", + State: "active", }, }, + IsDefault: true, + }, + { + Name: "bat", + Scopes: map[string]any{ + "idc": "IDC-1", + "location": "LOCATION-2", + "cidrs": []string{"192.168.1.0/24"}, + }, Schedulers: []models.Scheduler{ { Hostname: "bae", @@ -733,18 +366,19 @@ func TestSearcher_FindSchedulerClusters(t *testing.T) { }, }, conditions: map[string]string{ - "security_domain": "domain-1", - "idc": "idc-1|idc-2", - "location": "location-1|location-2", + "idc": "idc-1", + "location": "location-1|location-2", }, expect: func(t *testing.T, data []models.SchedulerCluster, err error) { assert := assert.New(t) - assert.Equal(data[0].Name, "bae") - assert.Equal(data[1].Name, "bar") + assert.Equal(data[0].Name, "bax") + assert.Equal(data[1].Name, "bae") assert.Equal(data[2].Name, "foo") - assert.Equal(data[3].Name, "baz") - assert.Equal(data[4].Name, "bax") - assert.Equal(len(data), 5) + assert.Equal(data[3].Name, "bar") + assert.Equal(data[4].Name, "baz") + assert.Equal(data[5].Name, "bac") + assert.Equal(data[6].Name, "bat") + assert.Equal(len(data), 7) }, }, } diff --git a/manager/service/mocks/service_mock.go b/manager/service/mocks/service_mock.go index 6e6373fee46..cbb1d4420ca 100644 --- a/manager/service/mocks/service_mock.go +++ b/manager/service/mocks/service_mock.go @@ -69,20 +69,6 @@ func (mr *MockServiceMockRecorder) AddRoleForUser(arg0, arg1 interface{}) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddRoleForUser", reflect.TypeOf((*MockService)(nil).AddRoleForUser), arg0, arg1) } -// AddSchedulerClusterToSecurityGroup mocks base method. -func (m *MockService) AddSchedulerClusterToSecurityGroup(arg0 context.Context, arg1, arg2 uint) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddSchedulerClusterToSecurityGroup", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddSchedulerClusterToSecurityGroup indicates an expected call of AddSchedulerClusterToSecurityGroup. -func (mr *MockServiceMockRecorder) AddSchedulerClusterToSecurityGroup(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddSchedulerClusterToSecurityGroup", reflect.TypeOf((*MockService)(nil).AddSchedulerClusterToSecurityGroup), arg0, arg1, arg2) -} - // AddSchedulerClusterToSeedPeerCluster mocks base method. func (m *MockService) AddSchedulerClusterToSeedPeerCluster(arg0 context.Context, arg1, arg2 uint) error { m.ctrl.T.Helper() @@ -111,34 +97,6 @@ func (mr *MockServiceMockRecorder) AddSchedulerToSchedulerCluster(arg0, arg1, ar return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddSchedulerToSchedulerCluster", reflect.TypeOf((*MockService)(nil).AddSchedulerToSchedulerCluster), arg0, arg1, arg2) } -// AddSecurityRuleToSecurityGroup mocks base method. -func (m *MockService) AddSecurityRuleToSecurityGroup(arg0 context.Context, arg1, arg2 uint) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddSecurityRuleToSecurityGroup", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddSecurityRuleToSecurityGroup indicates an expected call of AddSecurityRuleToSecurityGroup. -func (mr *MockServiceMockRecorder) AddSecurityRuleToSecurityGroup(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddSecurityRuleToSecurityGroup", reflect.TypeOf((*MockService)(nil).AddSecurityRuleToSecurityGroup), arg0, arg1, arg2) -} - -// AddSeedPeerClusterToSecurityGroup mocks base method. -func (m *MockService) AddSeedPeerClusterToSecurityGroup(arg0 context.Context, arg1, arg2 uint) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddSeedPeerClusterToSecurityGroup", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddSeedPeerClusterToSecurityGroup indicates an expected call of AddSeedPeerClusterToSecurityGroup. -func (mr *MockServiceMockRecorder) AddSeedPeerClusterToSecurityGroup(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddSeedPeerClusterToSecurityGroup", reflect.TypeOf((*MockService)(nil).AddSeedPeerClusterToSecurityGroup), arg0, arg1, arg2) -} - // AddSeedPeerToSeedPeerCluster mocks base method. func (m *MockService) AddSeedPeerToSeedPeerCluster(arg0 context.Context, arg1, arg2 uint) error { m.ctrl.T.Helper() @@ -271,36 +229,6 @@ func (mr *MockServiceMockRecorder) CreateSchedulerCluster(arg0, arg1 interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSchedulerCluster", reflect.TypeOf((*MockService)(nil).CreateSchedulerCluster), arg0, arg1) } -// CreateSecurityGroup mocks base method. -func (m *MockService) CreateSecurityGroup(arg0 context.Context, arg1 types.CreateSecurityGroupRequest) (*models.SecurityGroup, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateSecurityGroup", arg0, arg1) - ret0, _ := ret[0].(*models.SecurityGroup) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateSecurityGroup indicates an expected call of CreateSecurityGroup. -func (mr *MockServiceMockRecorder) CreateSecurityGroup(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSecurityGroup", reflect.TypeOf((*MockService)(nil).CreateSecurityGroup), arg0, arg1) -} - -// CreateSecurityRule mocks base method. -func (m *MockService) CreateSecurityRule(arg0 context.Context, arg1 types.CreateSecurityRuleRequest) (*models.SecurityRule, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateSecurityRule", arg0, arg1) - ret0, _ := ret[0].(*models.SecurityRule) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateSecurityRule indicates an expected call of CreateSecurityRule. -func (mr *MockServiceMockRecorder) CreateSecurityRule(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSecurityRule", reflect.TypeOf((*MockService)(nil).CreateSecurityRule), arg0, arg1) -} - // CreateSeedPeer mocks base method. func (m *MockService) CreateSeedPeer(arg0 context.Context, arg1 types.CreateSeedPeerRequest) (*models.SeedPeer, error) { m.ctrl.T.Helper() @@ -489,48 +417,6 @@ func (mr *MockServiceMockRecorder) DestroySchedulerCluster(arg0, arg1 interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DestroySchedulerCluster", reflect.TypeOf((*MockService)(nil).DestroySchedulerCluster), arg0, arg1) } -// DestroySecurityGroup mocks base method. -func (m *MockService) DestroySecurityGroup(arg0 context.Context, arg1 uint) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DestroySecurityGroup", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// DestroySecurityGroup indicates an expected call of DestroySecurityGroup. -func (mr *MockServiceMockRecorder) DestroySecurityGroup(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DestroySecurityGroup", reflect.TypeOf((*MockService)(nil).DestroySecurityGroup), arg0, arg1) -} - -// DestroySecurityRule mocks base method. -func (m *MockService) DestroySecurityRule(arg0 context.Context, arg1 uint) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DestroySecurityRule", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// DestroySecurityRule indicates an expected call of DestroySecurityRule. -func (mr *MockServiceMockRecorder) DestroySecurityRule(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DestroySecurityRule", reflect.TypeOf((*MockService)(nil).DestroySecurityRule), arg0, arg1) -} - -// DestroySecurityRuleToSecurityGroup mocks base method. -func (m *MockService) DestroySecurityRuleToSecurityGroup(arg0 context.Context, arg1, arg2 uint) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DestroySecurityRuleToSecurityGroup", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// DestroySecurityRuleToSecurityGroup indicates an expected call of DestroySecurityRuleToSecurityGroup. -func (mr *MockServiceMockRecorder) DestroySecurityRuleToSecurityGroup(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DestroySecurityRuleToSecurityGroup", reflect.TypeOf((*MockService)(nil).DestroySecurityRuleToSecurityGroup), arg0, arg1, arg2) -} - // DestroySeedPeer mocks base method. func (m *MockService) DestroySeedPeer(arg0 context.Context, arg1 uint) error { m.ctrl.T.Helper() @@ -847,68 +733,6 @@ func (mr *MockServiceMockRecorder) GetSchedulers(arg0, arg1 interface{}) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSchedulers", reflect.TypeOf((*MockService)(nil).GetSchedulers), arg0, arg1) } -// GetSecurityGroup mocks base method. -func (m *MockService) GetSecurityGroup(arg0 context.Context, arg1 uint) (*models.SecurityGroup, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSecurityGroup", arg0, arg1) - ret0, _ := ret[0].(*models.SecurityGroup) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetSecurityGroup indicates an expected call of GetSecurityGroup. -func (mr *MockServiceMockRecorder) GetSecurityGroup(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSecurityGroup", reflect.TypeOf((*MockService)(nil).GetSecurityGroup), arg0, arg1) -} - -// GetSecurityGroups mocks base method. -func (m *MockService) GetSecurityGroups(arg0 context.Context, arg1 types.GetSecurityGroupsQuery) ([]models.SecurityGroup, int64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSecurityGroups", arg0, arg1) - ret0, _ := ret[0].([]models.SecurityGroup) - ret1, _ := ret[1].(int64) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetSecurityGroups indicates an expected call of GetSecurityGroups. -func (mr *MockServiceMockRecorder) GetSecurityGroups(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSecurityGroups", reflect.TypeOf((*MockService)(nil).GetSecurityGroups), arg0, arg1) -} - -// GetSecurityRule mocks base method. -func (m *MockService) GetSecurityRule(arg0 context.Context, arg1 uint) (*models.SecurityRule, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSecurityRule", arg0, arg1) - ret0, _ := ret[0].(*models.SecurityRule) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetSecurityRule indicates an expected call of GetSecurityRule. -func (mr *MockServiceMockRecorder) GetSecurityRule(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSecurityRule", reflect.TypeOf((*MockService)(nil).GetSecurityRule), arg0, arg1) -} - -// GetSecurityRules mocks base method. -func (m *MockService) GetSecurityRules(arg0 context.Context, arg1 types.GetSecurityRulesQuery) ([]models.SecurityRule, int64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSecurityRules", arg0, arg1) - ret0, _ := ret[0].([]models.SecurityRule) - ret1, _ := ret[1].(int64) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetSecurityRules indicates an expected call of GetSecurityRules. -func (mr *MockServiceMockRecorder) GetSecurityRules(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSecurityRules", reflect.TypeOf((*MockService)(nil).GetSecurityRules), arg0, arg1) -} - // GetSeedPeer mocks base method. func (m *MockService) GetSeedPeer(arg0 context.Context, arg1 uint) (*models.SeedPeer, error) { m.ctrl.T.Helper() @@ -1181,36 +1005,6 @@ func (mr *MockServiceMockRecorder) UpdateSchedulerCluster(arg0, arg1, arg2 inter return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSchedulerCluster", reflect.TypeOf((*MockService)(nil).UpdateSchedulerCluster), arg0, arg1, arg2) } -// UpdateSecurityGroup mocks base method. -func (m *MockService) UpdateSecurityGroup(arg0 context.Context, arg1 uint, arg2 types.UpdateSecurityGroupRequest) (*models.SecurityGroup, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateSecurityGroup", arg0, arg1, arg2) - ret0, _ := ret[0].(*models.SecurityGroup) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UpdateSecurityGroup indicates an expected call of UpdateSecurityGroup. -func (mr *MockServiceMockRecorder) UpdateSecurityGroup(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSecurityGroup", reflect.TypeOf((*MockService)(nil).UpdateSecurityGroup), arg0, arg1, arg2) -} - -// UpdateSecurityRule mocks base method. -func (m *MockService) UpdateSecurityRule(arg0 context.Context, arg1 uint, arg2 types.UpdateSecurityRuleRequest) (*models.SecurityRule, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateSecurityRule", arg0, arg1, arg2) - ret0, _ := ret[0].(*models.SecurityRule) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UpdateSecurityRule indicates an expected call of UpdateSecurityRule. -func (mr *MockServiceMockRecorder) UpdateSecurityRule(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSecurityRule", reflect.TypeOf((*MockService)(nil).UpdateSecurityRule), arg0, arg1, arg2) -} - // UpdateSeedPeer mocks base method. func (m *MockService) UpdateSeedPeer(arg0 context.Context, arg1 uint, arg2 types.UpdateSeedPeerRequest) (*models.SeedPeer, error) { m.ctrl.T.Helper() diff --git a/manager/service/scheduler_cluster.go b/manager/service/scheduler_cluster.go index 8a2e26c0fa9..3b7c5eb4059 100644 --- a/manager/service/scheduler_cluster.go +++ b/manager/service/scheduler_cluster.go @@ -60,12 +60,6 @@ func (s *service) CreateSchedulerCluster(ctx context.Context, json types.CreateS } } - if json.SecurityGroupID > 0 { - if err := s.AddSchedulerClusterToSecurityGroup(ctx, json.SecurityGroupID, schedulerCluster.ID); err != nil { - return nil, err - } - } - return &schedulerCluster, nil } @@ -139,18 +133,12 @@ func (s *service) UpdateSchedulerCluster(ctx context.Context, id uint, json type } } - if json.SecurityGroupID > 0 { - if err := s.AddSchedulerClusterToSecurityGroup(ctx, json.SecurityGroupID, schedulerCluster.ID); err != nil { - return nil, err - } - } - return &schedulerCluster, nil } func (s *service) GetSchedulerCluster(ctx context.Context, id uint) (*models.SchedulerCluster, error) { schedulerCluster := models.SchedulerCluster{} - if err := s.db.WithContext(ctx).Preload("SeedPeerClusters").Preload("SecurityGroup").First(&schedulerCluster, id).Error; err != nil { + if err := s.db.WithContext(ctx).Preload("SeedPeerClusters").First(&schedulerCluster, id).Error; err != nil { return nil, err } @@ -162,7 +150,7 @@ func (s *service) GetSchedulerClusters(ctx context.Context, q types.GetScheduler var schedulerClusters []models.SchedulerCluster if err := s.db.WithContext(ctx).Scopes(models.Paginate(q.Page, q.PerPage)).Where(&models.SchedulerCluster{ Name: q.Name, - }).Preload("SeedPeerClusters").Preload("SecurityGroup").Find(&schedulerClusters).Limit(-1).Offset(-1).Count(&count).Error; err != nil { + }).Preload("SeedPeerClusters").Find(&schedulerClusters).Limit(-1).Offset(-1).Count(&count).Error; err != nil { return nil, 0, err } diff --git a/manager/service/security_group.go b/manager/service/security_group.go deleted file mode 100644 index 6e55d8b25bf..00000000000 --- a/manager/service/security_group.go +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package service - -import ( - "context" - - "d7y.io/dragonfly/v2/manager/models" - "d7y.io/dragonfly/v2/manager/types" -) - -func (s *service) CreateSecurityGroup(ctx context.Context, json types.CreateSecurityGroupRequest) (*models.SecurityGroup, error) { - securityGroup := models.SecurityGroup{ - Name: json.Name, - BIO: json.BIO, - } - - if err := s.db.WithContext(ctx).Create(&securityGroup).Error; err != nil { - return nil, err - } - - return &securityGroup, nil -} - -func (s *service) DestroySecurityGroup(ctx context.Context, id uint) error { - securityGroup := models.SecurityGroup{} - if err := s.db.WithContext(ctx).First(&securityGroup, id).Error; err != nil { - return err - } - - if err := s.db.WithContext(ctx).Unscoped().Delete(&models.SecurityGroup{}, id).Error; err != nil { - return err - } - - return nil -} - -func (s *service) UpdateSecurityGroup(ctx context.Context, id uint, json types.UpdateSecurityGroupRequest) (*models.SecurityGroup, error) { - securityGroup := models.SecurityGroup{} - if err := s.db.WithContext(ctx).First(&securityGroup, id).Updates(models.SecurityGroup{ - Name: json.Name, - BIO: json.BIO, - }).Error; err != nil { - return nil, err - } - - return &securityGroup, nil -} - -func (s *service) GetSecurityGroup(ctx context.Context, id uint) (*models.SecurityGroup, error) { - securityGroup := models.SecurityGroup{} - if err := s.db.WithContext(ctx).Preload("SecurityRules").First(&securityGroup, id).Error; err != nil { - return nil, err - } - - return &securityGroup, nil -} - -func (s *service) GetSecurityGroups(ctx context.Context, q types.GetSecurityGroupsQuery) ([]models.SecurityGroup, int64, error) { - var count int64 - var securityGroups []models.SecurityGroup - if err := s.db.WithContext(ctx).Scopes(models.Paginate(q.Page, q.PerPage)).Where(&models.SecurityGroup{ - Name: q.Name, - }).Preload("SecurityRules").Find(&securityGroups).Limit(-1).Offset(-1).Count(&count).Error; err != nil { - return nil, 0, err - } - - return securityGroups, count, nil -} - -func (s *service) AddSchedulerClusterToSecurityGroup(ctx context.Context, id, schedulerClusterID uint) error { - securityGroup := models.SecurityGroup{} - if err := s.db.WithContext(ctx).First(&securityGroup, id).Error; err != nil { - return err - } - - schedulerCluster := models.SchedulerCluster{} - if err := s.db.WithContext(ctx).First(&schedulerCluster, schedulerClusterID).Error; err != nil { - return err - } - - if err := s.db.WithContext(ctx).Model(&securityGroup).Association("SchedulerClusters").Append(&schedulerCluster); err != nil { - return err - } - - return nil -} - -func (s *service) AddSeedPeerClusterToSecurityGroup(ctx context.Context, id, seedPeerClusterID uint) error { - securityGroup := models.SecurityGroup{} - if err := s.db.WithContext(ctx).First(&securityGroup, id).Error; err != nil { - return err - } - - seedPeerCluster := models.SeedPeerCluster{} - if err := s.db.WithContext(ctx).First(&seedPeerCluster, seedPeerClusterID).Error; err != nil { - return err - } - - if err := s.db.WithContext(ctx).Model(&securityGroup).Association("SeedPeerClusters").Append(&seedPeerCluster); err != nil { - return err - } - - return nil -} - -func (s *service) AddSecurityRuleToSecurityGroup(ctx context.Context, id, securityRuleID uint) error { - securityGroup := models.SecurityGroup{} - if err := s.db.WithContext(ctx).First(&securityGroup, id).Error; err != nil { - return err - } - - securityRule := models.SecurityRule{} - if err := s.db.WithContext(ctx).First(&securityRule, securityRuleID).Error; err != nil { - return err - } - - if err := s.db.WithContext(ctx).Model(&securityGroup).Association("SecurityRules").Append(&securityRule); err != nil { - return err - } - - return nil -} - -func (s *service) DestroySecurityRuleToSecurityGroup(ctx context.Context, id, securityRuleID uint) error { - securityGroup := models.SecurityGroup{} - if err := s.db.WithContext(ctx).First(&securityGroup, id).Error; err != nil { - return err - } - - securityRule := models.SecurityRule{} - if err := s.db.WithContext(ctx).First(&securityRule, securityRuleID).Error; err != nil { - return err - } - - if err := s.db.WithContext(ctx).Model(&securityGroup).Association("SecurityRules").Delete(&securityRule); err != nil { - return err - } - - return nil -} diff --git a/manager/service/security_rule.go b/manager/service/security_rule.go deleted file mode 100644 index cb9d4844dcf..00000000000 --- a/manager/service/security_rule.go +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package service - -import ( - "context" - - "d7y.io/dragonfly/v2/manager/models" - "d7y.io/dragonfly/v2/manager/types" -) - -func (s *service) CreateSecurityRule(ctx context.Context, json types.CreateSecurityRuleRequest) (*models.SecurityRule, error) { - securityRule := models.SecurityRule{ - Name: json.Name, - BIO: json.BIO, - Domain: json.Domain, - ProxyDomain: json.ProxyDomain, - } - - if err := s.db.WithContext(ctx).Create(&securityRule).Error; err != nil { - return nil, err - } - - return &securityRule, nil -} - -func (s *service) DestroySecurityRule(ctx context.Context, id uint) error { - securityRule := models.SecurityRule{} - if err := s.db.WithContext(ctx).First(&securityRule, id).Error; err != nil { - return err - } - - if err := s.db.WithContext(ctx).Unscoped().Delete(&models.SecurityRule{}, id).Error; err != nil { - return err - } - - return nil -} - -func (s *service) UpdateSecurityRule(ctx context.Context, id uint, json types.UpdateSecurityRuleRequest) (*models.SecurityRule, error) { - securityRule := models.SecurityRule{} - if err := s.db.WithContext(ctx).First(&securityRule, id).Updates(models.SecurityRule{ - Name: json.Name, - BIO: json.BIO, - Domain: json.Domain, - ProxyDomain: json.ProxyDomain, - }).Error; err != nil { - return nil, err - } - - return &securityRule, nil -} - -func (s *service) GetSecurityRule(ctx context.Context, id uint) (*models.SecurityRule, error) { - securityRule := models.SecurityRule{} - if err := s.db.WithContext(ctx).First(&securityRule, id).Error; err != nil { - return nil, err - } - - return &securityRule, nil -} - -func (s *service) GetSecurityRules(ctx context.Context, q types.GetSecurityRulesQuery) ([]models.SecurityRule, int64, error) { - var count int64 - var securityRules []models.SecurityRule - if err := s.db.WithContext(ctx).Scopes(models.Paginate(q.Page, q.PerPage)).Where(&models.SecurityRule{ - Name: q.Name, - }).Find(&securityRules).Limit(-1).Offset(-1).Count(&count).Error; err != nil { - return nil, 0, err - } - - return securityRules, count, nil -} diff --git a/manager/service/service.go b/manager/service/service.go index 6c29a88ac0b..04dfd8b40a5 100644 --- a/manager/service/service.go +++ b/manager/service/service.go @@ -92,22 +92,6 @@ type Service interface { GetScheduler(context.Context, uint) (*models.Scheduler, error) GetSchedulers(context.Context, types.GetSchedulersQuery) ([]models.Scheduler, int64, error) - CreateSecurityRule(context.Context, types.CreateSecurityRuleRequest) (*models.SecurityRule, error) - DestroySecurityRule(context.Context, uint) error - UpdateSecurityRule(context.Context, uint, types.UpdateSecurityRuleRequest) (*models.SecurityRule, error) - GetSecurityRule(context.Context, uint) (*models.SecurityRule, error) - GetSecurityRules(context.Context, types.GetSecurityRulesQuery) ([]models.SecurityRule, int64, error) - - CreateSecurityGroup(context.Context, types.CreateSecurityGroupRequest) (*models.SecurityGroup, error) - DestroySecurityGroup(context.Context, uint) error - UpdateSecurityGroup(context.Context, uint, types.UpdateSecurityGroupRequest) (*models.SecurityGroup, error) - GetSecurityGroup(context.Context, uint) (*models.SecurityGroup, error) - GetSecurityGroups(context.Context, types.GetSecurityGroupsQuery) ([]models.SecurityGroup, int64, error) - AddSchedulerClusterToSecurityGroup(context.Context, uint, uint) error - AddSeedPeerClusterToSecurityGroup(context.Context, uint, uint) error - AddSecurityRuleToSecurityGroup(context.Context, uint, uint) error - DestroySecurityRuleToSecurityGroup(context.Context, uint, uint) error - CreateBucket(context.Context, types.CreateBucketRequest) error DestroyBucket(context.Context, string) error GetBucket(context.Context, string) (*objectstorage.BucketMetadata, error) diff --git a/manager/types/scheduler_cluster.go b/manager/types/scheduler_cluster.go index a19f647007b..8fd3dcd3375 100644 --- a/manager/types/scheduler_cluster.go +++ b/manager/types/scheduler_cluster.go @@ -33,7 +33,6 @@ type CreateSchedulerClusterRequest struct { Scopes *SchedulerClusterScopes `json:"scopes" binding:"omitempty"` IsDefault bool `json:"is_default" binding:"omitempty"` SeedPeerClusterID uint `json:"seed_peer_cluster_id" binding:"omitempty"` - SecurityGroupID uint `json:"security_group_id" binding:"omitempty"` } type UpdateSchedulerClusterRequest struct { @@ -44,7 +43,6 @@ type UpdateSchedulerClusterRequest struct { Scopes *SchedulerClusterScopes `json:"scopes" binding:"omitempty"` IsDefault bool `json:"is_default" binding:"omitempty"` SeedPeerClusterID uint `json:"seed_peer_cluster_id" binding:"omitempty"` - SecurityGroupID uint `json:"security_group_id" binding:"omitempty"` } type GetSchedulerClustersQuery struct { diff --git a/manager/types/security_group.go b/manager/types/security_group.go deleted file mode 100644 index eb25c195c78..00000000000 --- a/manager/types/security_group.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package types - -type SecurityGroupParams struct { - ID uint `uri:"id" binding:"required"` -} - -type AddSchedulerClusterToSecurityGroupParams struct { - ID uint `uri:"id" binding:"required"` - SchedulerClusterID uint `uri:"scheduler_cluster_id" binding:"required"` -} - -type AddSeedPeerClusterToSecurityGroupParams struct { - ID uint `uri:"id" binding:"required"` - SeedPeerClusterID uint `uri:"seed_peer_cluster_id" binding:"required"` -} - -type AddSecurityRuleToSecurityGroupParams struct { - ID uint `uri:"id" binding:"required"` - SecurityRuleID uint `uri:"security_rule_id" binding:"required"` -} - -type CreateSecurityGroupRequest struct { - Name string `json:"name" binding:"required"` - BIO string `json:"bio" binding:"omitempty"` -} - -type UpdateSecurityGroupRequest struct { - Name string `json:"name" binding:"omitempty"` - BIO string `json:"bio" binding:"omitempty"` -} - -type GetSecurityGroupsQuery struct { - Name string `form:"name" binding:"omitempty"` - Page int `form:"page" binding:"omitempty,gte=1"` - PerPage int `form:"per_page" binding:"omitempty,gte=1,lte=50"` -} diff --git a/manager/types/security_rule.go b/manager/types/security_rule.go deleted file mode 100644 index 4351578f047..00000000000 --- a/manager/types/security_rule.go +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2020 The Dragonfly Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package types - -type SecurityRuleParams struct { - ID uint `uri:"id" binding:"required"` -} - -type CreateSecurityRuleRequest struct { - Name string `json:"name" binding:"required"` - BIO string `json:"bio" binding:"omitempty"` - Domain string `json:"domain" binding:"required"` - ProxyDomain string `json:"proxy_domain" binding:"omitempty"` -} - -type UpdateSecurityRuleRequest struct { - Name string `json:"name" binding:"omitempty"` - BIO string `json:"bio" binding:"omitempty"` - Domain string `json:"domain" binding:"omitempty"` - ProxyDomain string `json:"proxy_domain" binding:"omitempty"` -} - -type GetSecurityRulesQuery struct { - Page int `form:"page" binding:"omitempty,gte=1"` - PerPage int `form:"per_page" binding:"omitempty,gte=1,lte=50"` - Name string `form:"name" binding:"omitempty"` - Domain string `form:"domain" binding:"omitempty"` - ProxyDomain string `form:"proxy_domain" binding:"omitempty"` -} diff --git a/scheduler/networktopology/probes_test.go b/scheduler/networktopology/probes_test.go index 7d73a50a0c9..4a9875d5661 100644 --- a/scheduler/networktopology/probes_test.go +++ b/scheduler/networktopology/probes_test.go @@ -104,7 +104,6 @@ var ( mockNetwork = resource.Network{ TCPConnectionCount: 10, UploadTCPConnectionCount: 1, - SecurityDomain: mockHostSecurityDomain, Location: mockHostLocation, IDC: mockHostIDC, } @@ -127,9 +126,8 @@ var ( Platform: "darwin", } - mockHostSecurityDomain = "security_domain" - mockHostLocation = "location" - mockHostIDC = "idc" + mockHostLocation = "location" + mockHostIDC = "idc" mockProbe = &Probe{ Host: mockHost, diff --git a/scheduler/resource/host.go b/scheduler/resource/host.go index 09293dbb8d6..bb637a2bfd7 100644 --- a/scheduler/resource/host.go +++ b/scheduler/resource/host.go @@ -266,9 +266,6 @@ type Network struct { // Return count of upload tcp connections opened and status is ESTABLISHED. UploadTCPConnectionCount uint32 `csv:"uploadTCPConnectionCount"` - // Security domain for network. - SecurityDomain string `csv:"securityDomain"` - // Location path(area|country|province|city|...). Location string `csv:"location"` diff --git a/scheduler/resource/host_test.go b/scheduler/resource/host_test.go index bfd44c6ff0f..cb9c7c26007 100644 --- a/scheduler/resource/host_test.go +++ b/scheduler/resource/host_test.go @@ -104,7 +104,6 @@ var ( mockNetwork = Network{ TCPConnectionCount: 10, UploadTCPConnectionCount: 1, - SecurityDomain: mockHostSecurityDomain, Location: mockHostLocation, IDC: mockHostIDC, } @@ -127,11 +126,10 @@ var ( Platform: "darwin", } - mockHostID = idgen.HostIDV2("127.0.0.1", "hostname") - mockSeedHostID = idgen.HostIDV2("127.0.0.1", "hostname_seed") - mockHostSecurityDomain = "security_domain" - mockHostLocation = "location" - mockHostIDC = "idc" + mockHostID = idgen.HostIDV2("127.0.0.1", "hostname") + mockSeedHostID = idgen.HostIDV2("127.0.0.1", "hostname_seed") + mockHostLocation = "location" + mockHostIDC = "idc" ) func TestHost_NewHost(t *testing.T) { diff --git a/scheduler/scheduling/evaluator/evaluator_base.go b/scheduler/scheduling/evaluator/evaluator_base.go index 1f57f5e0f45..f6a72efd542 100644 --- a/scheduler/scheduling/evaluator/evaluator_base.go +++ b/scheduler/scheduling/evaluator/evaluator_base.go @@ -77,21 +77,11 @@ func NewEvaluatorBase() Evaluator { // The larger the value after evaluation, the higher the priority. func (eb *evaluatorBase) Evaluate(parent *resource.Peer, child *resource.Peer, totalPieceCount int32) float64 { - parentSecurityDomain := parent.Host.Network.SecurityDomain parentLocation := parent.Host.Network.Location parentIDC := parent.Host.Network.IDC - childSecurityDomain := child.Host.Network.SecurityDomain childLocation := child.Host.Network.Location childIDC := child.Host.Network.IDC - // If the SecurityDomain of hosts exists but is not equal, - // it cannot be scheduled as a parent. - if parentSecurityDomain != "" && - childSecurityDomain != "" && - parentSecurityDomain != childSecurityDomain { - return minScore - } - return finishedPieceWeight*calculatePieceScore(parent, child, totalPieceCount) + parentHostUploadSuccessWeight*calculateParentHostUploadSuccessScore(parent) + freeUploadWeight*calculateFreeUploadScore(parent.Host) + diff --git a/scheduler/scheduling/evaluator/evaluator_base_test.go b/scheduler/scheduling/evaluator/evaluator_base_test.go index 682c6226374..8eba3596b27 100644 --- a/scheduler/scheduling/evaluator/evaluator_base_test.go +++ b/scheduler/scheduling/evaluator/evaluator_base_test.go @@ -106,7 +106,6 @@ var ( mockNetwork = resource.Network{ TCPConnectionCount: 10, UploadTCPConnectionCount: 1, - SecurityDomain: mockHostSecurityDomain, Location: mockHostLocation, IDC: mockHostIDC, } @@ -140,7 +139,6 @@ var ( mockTaskPieceLength int32 = 2048 mockHostID = idgen.HostIDV2("127.0.0.1", "hostname") mockSeedHostID = idgen.HostIDV2("127.0.0.1", "hostname_seed") - mockHostSecurityDomain = "security_domain" mockHostLocation = "location" mockHostIDC = "idc" mockPeerID = idgen.PeerIDV2() @@ -177,7 +175,7 @@ func TestEvaluatorBase_Evaluate(t *testing.T) { expect func(t *testing.T, score float64) }{ { - name: "security domain is not the same", + name: "evaluate parent", parent: resource.NewPeer(idgen.PeerIDV1("127.0.0.1"), resource.NewTask(mockTaskID, mockTaskURL, mockTaskTag, mockTaskApplication, commonv2.TaskType_DFDAEMON, mockTaskFilters, mockTaskHeader, mockTaskBackToSourceLimit, resource.WithDigest(mockTaskDigest), resource.WithPieceLength(mockTaskPieceLength)), resource.NewHost( @@ -190,62 +188,14 @@ func TestEvaluatorBase_Evaluate(t *testing.T) { mockRawHost.Port, mockRawHost.DownloadPort, mockRawHost.Type)), totalPieceCount: 1, mock: func(parent *resource.Peer, child *resource.Peer) { - parent.Host.Network.SecurityDomain = "foo" - child.Host.Network.SecurityDomain = "bar" }, expect: func(t *testing.T, score float64) { assert := assert.New(t) - assert.Equal(score, float64(0)) - }, - }, - { - name: "security domain is same", - parent: resource.NewPeer(idgen.PeerIDV1("127.0.0.1"), - resource.NewTask(mockTaskID, mockTaskURL, mockTaskTag, mockTaskApplication, commonv2.TaskType_DFDAEMON, mockTaskFilters, mockTaskHeader, mockTaskBackToSourceLimit, resource.WithDigest(mockTaskDigest), resource.WithPieceLength(mockTaskPieceLength)), - resource.NewHost( - mockRawSeedHost.ID, mockRawSeedHost.IP, mockRawSeedHost.Hostname, - mockRawSeedHost.Port, mockRawSeedHost.DownloadPort, mockRawSeedHost.Type)), - child: resource.NewPeer(idgen.PeerIDV1("127.0.0.1"), - resource.NewTask(mockTaskID, mockTaskURL, mockTaskTag, mockTaskApplication, commonv2.TaskType_DFDAEMON, mockTaskFilters, mockTaskHeader, mockTaskBackToSourceLimit, resource.WithDigest(mockTaskDigest), resource.WithPieceLength(mockTaskPieceLength)), - resource.NewHost( - mockRawHost.ID, mockRawHost.IP, mockRawHost.Hostname, - mockRawHost.Port, mockRawHost.DownloadPort, mockRawHost.Type)), - totalPieceCount: 1, - mock: func(parent *resource.Peer, child *resource.Peer) { - parent.Host.Network.SecurityDomain = "bac" - child.Host.Network.SecurityDomain = "bac" - parent.FinishedPieces.Set(0) - }, - expect: func(t *testing.T, score float64) { - assert := assert.New(t) - assert.Equal(score, float64(0.55)) - }, - }, - { - name: "parent security domain is empty", - parent: resource.NewPeer(idgen.PeerIDV1("127.0.0.1"), - resource.NewTask(mockTaskID, mockTaskURL, mockTaskTag, mockTaskApplication, commonv2.TaskType_DFDAEMON, mockTaskFilters, mockTaskHeader, mockTaskBackToSourceLimit, resource.WithDigest(mockTaskDigest), resource.WithPieceLength(mockTaskPieceLength)), - resource.NewHost( - mockRawSeedHost.ID, mockRawSeedHost.IP, mockRawSeedHost.Hostname, - mockRawSeedHost.Port, mockRawSeedHost.DownloadPort, mockRawSeedHost.Type)), - child: resource.NewPeer(idgen.PeerIDV1("127.0.0.1"), - resource.NewTask(mockTaskID, mockTaskURL, mockTaskTag, mockTaskApplication, commonv2.TaskType_DFDAEMON, mockTaskFilters, mockTaskHeader, mockTaskBackToSourceLimit, resource.WithDigest(mockTaskDigest), resource.WithPieceLength(mockTaskPieceLength)), - resource.NewHost( - mockRawHost.ID, mockRawHost.IP, mockRawHost.Hostname, - mockRawHost.Port, mockRawHost.DownloadPort, mockRawHost.Type)), - totalPieceCount: 1, - mock: func(parent *resource.Peer, child *resource.Peer) { - parent.Host.Network.SecurityDomain = "" - child.Host.Network.SecurityDomain = "baz" - parent.FinishedPieces.Set(0) - }, - expect: func(t *testing.T, score float64) { - assert := assert.New(t) - assert.Equal(score, float64(0.55)) + assert.Equal(score, float64(0.35)) }, }, { - name: "child security domain is empty", + name: "evaluate parent with pieces", parent: resource.NewPeer(idgen.PeerIDV1("127.0.0.1"), resource.NewTask(mockTaskID, mockTaskURL, mockTaskTag, mockTaskApplication, commonv2.TaskType_DFDAEMON, mockTaskFilters, mockTaskHeader, mockTaskBackToSourceLimit, resource.WithDigest(mockTaskDigest), resource.WithPieceLength(mockTaskPieceLength)), resource.NewHost( @@ -258,8 +208,6 @@ func TestEvaluatorBase_Evaluate(t *testing.T) { mockRawHost.Port, mockRawHost.DownloadPort, mockRawHost.Type)), totalPieceCount: 1, mock: func(parent *resource.Peer, child *resource.Peer) { - parent.Host.Network.SecurityDomain = "baz" - child.Host.Network.SecurityDomain = "" parent.FinishedPieces.Set(0) }, expect: func(t *testing.T, score float64) { diff --git a/scheduler/scheduling/scheduling.go b/scheduler/scheduling/scheduling.go index ba463ce52ec..b8a39cb616a 100644 --- a/scheduler/scheduling/scheduling.go +++ b/scheduler/scheduling/scheduling.go @@ -669,7 +669,6 @@ func ConstructSuccessSmallTaskResponse(candidateParent *resource.Peer) *schedule Network: &commonv2.Network{ TcpConnectionCount: candidateParent.Host.Network.TCPConnectionCount, UploadTcpConnectionCount: candidateParent.Host.Network.UploadTCPConnectionCount, - SecurityDomain: candidateParent.Host.Network.SecurityDomain, Location: candidateParent.Host.Network.Location, Idc: candidateParent.Host.Network.IDC, }, @@ -844,7 +843,6 @@ func ConstructSuccessNormalTaskResponse(dynconfig config.DynconfigInterface, can Network: &commonv2.Network{ TcpConnectionCount: candidateParent.Host.Network.TCPConnectionCount, UploadTcpConnectionCount: candidateParent.Host.Network.UploadTCPConnectionCount, - SecurityDomain: candidateParent.Host.Network.SecurityDomain, Location: candidateParent.Host.Network.Location, Idc: candidateParent.Host.Network.IDC, }, diff --git a/scheduler/scheduling/scheduling_test.go b/scheduler/scheduling/scheduling_test.go index c589459c223..fb81c4139cc 100644 --- a/scheduler/scheduling/scheduling_test.go +++ b/scheduler/scheduling/scheduling_test.go @@ -135,7 +135,6 @@ var ( mockNetwork = resource.Network{ TCPConnectionCount: 10, UploadTCPConnectionCount: 1, - SecurityDomain: mockHostSecurityDomain, Location: mockHostLocation, IDC: mockHostIDC, } @@ -169,7 +168,6 @@ var ( mockTaskPieceLength int32 = 2048 mockHostID = idgen.HostIDV2("127.0.0.1", "hostname") mockSeedHostID = idgen.HostIDV2("127.0.0.1", "hostname_seed") - mockHostSecurityDomain = "security_domain" mockHostLocation = "location" mockHostIDC = "idc" mockPeerID = idgen.PeerIDV2() @@ -1353,7 +1351,6 @@ func TestScheduling_ConstructSuccessSmallTaskResponse(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: candidateParent.Host.Network.TCPConnectionCount, UploadTcpConnectionCount: candidateParent.Host.Network.UploadTCPConnectionCount, - SecurityDomain: candidateParent.Host.Network.SecurityDomain, Location: candidateParent.Host.Network.Location, Idc: candidateParent.Host.Network.IDC, }, @@ -1512,7 +1509,6 @@ func TestScheduling_ConstructSuccessNormalTaskResponse(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: candidateParents[0].Host.Network.TCPConnectionCount, UploadTcpConnectionCount: candidateParents[0].Host.Network.UploadTCPConnectionCount, - SecurityDomain: candidateParents[0].Host.Network.SecurityDomain, Location: candidateParents[0].Host.Network.Location, Idc: candidateParents[0].Host.Network.IDC, }, @@ -1645,7 +1641,6 @@ func TestScheduling_ConstructSuccessNormalTaskResponse(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: candidateParents[0].Host.Network.TCPConnectionCount, UploadTcpConnectionCount: candidateParents[0].Host.Network.UploadTCPConnectionCount, - SecurityDomain: candidateParents[0].Host.Network.SecurityDomain, Location: candidateParents[0].Host.Network.Location, Idc: candidateParents[0].Host.Network.IDC, }, diff --git a/scheduler/service/service_v1.go b/scheduler/service/service_v1.go index 53bf2d365b9..5f5175043eb 100644 --- a/scheduler/service/service_v1.go +++ b/scheduler/service/service_v1.go @@ -513,7 +513,6 @@ func (v *V1) AnnounceHost(ctx context.Context, req *schedulerv1.AnnounceHostRequ options = append(options, resource.WithNetwork(resource.Network{ TCPConnectionCount: req.Network.TcpConnectionCount, UploadTCPConnectionCount: req.Network.UploadTcpConnectionCount, - SecurityDomain: req.Network.SecurityDomain, Location: req.Network.Location, IDC: req.Network.Idc, })) @@ -602,7 +601,6 @@ func (v *V1) AnnounceHost(ctx context.Context, req *schedulerv1.AnnounceHostRequ host.Network = resource.Network{ TCPConnectionCount: req.Network.TcpConnectionCount, UploadTCPConnectionCount: req.Network.UploadTcpConnectionCount, - SecurityDomain: req.Network.SecurityDomain, Location: req.Network.Location, IDC: req.Network.Idc, } @@ -772,9 +770,8 @@ func (v *V1) storeHost(ctx context.Context, peerHost *schedulerv1.PeerHost) *res host, loaded := v.resource.HostManager().Load(peerHost.Id) if !loaded { options := []resource.HostOption{resource.WithNetwork(resource.Network{ - SecurityDomain: peerHost.SecurityDomain, - Location: peerHost.Location, - IDC: peerHost.Idc, + Location: peerHost.Location, + IDC: peerHost.Idc, })} if clientConfig, err := v.dynconfig.GetSchedulerClusterClientConfig(); err == nil && clientConfig.LoadLimit > 0 { options = append(options, resource.WithConcurrentUploadLimit(int32(clientConfig.LoadLimit))) @@ -793,7 +790,6 @@ func (v *V1) storeHost(ctx context.Context, peerHost *schedulerv1.PeerHost) *res host.Port = peerHost.RpcPort host.DownloadPort = peerHost.DownPort - host.Network.SecurityDomain = peerHost.SecurityDomain host.Network.Location = peerHost.Location host.Network.IDC = peerHost.Idc host.UpdatedAt.Store(time.Now()) @@ -1306,7 +1302,6 @@ func (v *V1) createRecord(peer *resource.Peer, parents []*resource.Peer, req *sc parentRecord.Host.Network = resource.Network{ TCPConnectionCount: parent.Host.Network.TCPConnectionCount, UploadTCPConnectionCount: parent.Host.Network.UploadTCPConnectionCount, - SecurityDomain: parent.Host.Network.SecurityDomain, Location: parent.Host.Network.Location, IDC: parent.Host.Network.IDC, } @@ -1418,7 +1413,6 @@ func (v *V1) createRecord(peer *resource.Peer, parents []*resource.Peer, req *sc download.Host.Network = resource.Network{ TCPConnectionCount: peer.Host.Network.TCPConnectionCount, UploadTCPConnectionCount: peer.Host.Network.UploadTCPConnectionCount, - SecurityDomain: peer.Host.Network.SecurityDomain, Location: peer.Host.Network.Location, IDC: peer.Host.Network.IDC, } diff --git a/scheduler/service/service_v1_test.go b/scheduler/service/service_v1_test.go index 83d2ca18a27..10e6af7d463 100644 --- a/scheduler/service/service_v1_test.go +++ b/scheduler/service/service_v1_test.go @@ -142,7 +142,6 @@ var ( mockNetwork = resource.Network{ TCPConnectionCount: 10, UploadTCPConnectionCount: 1, - SecurityDomain: mockHostSecurityDomain, Location: mockHostLocation, IDC: mockHostIDC, } @@ -166,14 +165,13 @@ var ( } mockPeerHost = &schedulerv1.PeerHost{ - Id: mockHostID, - Ip: "127.0.0.1", - RpcPort: 8003, - DownPort: 8001, - Hostname: "hostname", - SecurityDomain: mockHostSecurityDomain, - Location: mockHostLocation, - Idc: mockHostIDC, + Id: mockHostID, + Ip: "127.0.0.1", + RpcPort: 8003, + DownPort: 8001, + Hostname: "hostname", + Location: mockHostLocation, + Idc: mockHostIDC, } mockTaskBackToSourceLimit int32 = 200 @@ -187,7 +185,6 @@ var ( mockTaskPieceLength int32 = 2048 mockHostID = idgen.HostIDV2("127.0.0.1", "hostname") mockSeedHostID = idgen.HostIDV2("127.0.0.1", "hostname_seed") - mockHostSecurityDomain = "security_domain" mockHostLocation = "location" mockHostIDC = "idc" mockPeerID = idgen.PeerIDV2() @@ -1963,7 +1960,6 @@ func TestServiceV1_AnnounceHost(t *testing.T) { Network: &schedulerv1.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, @@ -2066,7 +2062,6 @@ func TestServiceV1_AnnounceHost(t *testing.T) { Network: &schedulerv1.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, @@ -2169,7 +2164,6 @@ func TestServiceV1_AnnounceHost(t *testing.T) { Network: &schedulerv1.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, @@ -2268,7 +2262,6 @@ func TestServiceV1_AnnounceHost(t *testing.T) { Network: &schedulerv1.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, @@ -3144,7 +3137,6 @@ func TestServiceV1_storeHost(t *testing.T) { assert.Equal(host.ID, mockRawHost.ID) assert.Equal(host.Port, mockRawHost.Port) assert.Equal(host.DownloadPort, mockRawHost.DownloadPort) - assert.Equal(host.Network.SecurityDomain, mockRawHost.Network.SecurityDomain) assert.Equal(host.Network.Location, mockRawHost.Network.Location) assert.Equal(host.Network.IDC, mockRawHost.Network.IDC) assert.NotEqual(host.UpdatedAt.Load(), mockRawHost.UpdatedAt.Load()) diff --git a/scheduler/service/service_v2.go b/scheduler/service/service_v2.go index 650de527826..8f804a66134 100644 --- a/scheduler/service/service_v2.go +++ b/scheduler/service/service_v2.go @@ -330,7 +330,6 @@ func (v *V2) StatPeer(ctx context.Context, req *schedulerv2.StatPeerRequest) (*c Network: &commonv2.Network{ TcpConnectionCount: peer.Host.Network.TCPConnectionCount, UploadTcpConnectionCount: peer.Host.Network.UploadTCPConnectionCount, - SecurityDomain: peer.Host.Network.SecurityDomain, Location: peer.Host.Network.Location, Idc: peer.Host.Network.IDC, }, @@ -504,7 +503,6 @@ func (v *V2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequ options = append(options, resource.WithNetwork(resource.Network{ TCPConnectionCount: req.Host.Network.TcpConnectionCount, UploadTCPConnectionCount: req.Host.Network.UploadTcpConnectionCount, - SecurityDomain: req.Host.Network.SecurityDomain, Location: req.Host.Network.Location, IDC: req.Host.Network.Idc, })) @@ -594,7 +592,6 @@ func (v *V2) AnnounceHost(ctx context.Context, req *schedulerv2.AnnounceHostRequ host.Network = resource.Network{ TCPConnectionCount: req.Host.Network.TcpConnectionCount, UploadTCPConnectionCount: req.Host.Network.UploadTcpConnectionCount, - SecurityDomain: req.Host.Network.SecurityDomain, Location: req.Host.Network.Location, IDC: req.Host.Network.Idc, } diff --git a/scheduler/service/service_v2_test.go b/scheduler/service/service_v2_test.go index 973a299406b..77735dac6df 100644 --- a/scheduler/service/service_v2_test.go +++ b/scheduler/service/service_v2_test.go @@ -201,7 +201,6 @@ func TestServiceV2_StatPeer(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: peer.Host.Network.TCPConnectionCount, UploadTcpConnectionCount: peer.Host.Network.UploadTCPConnectionCount, - SecurityDomain: peer.Host.Network.SecurityDomain, Location: peer.Host.Network.Location, Idc: peer.Host.Network.IDC, }, @@ -456,7 +455,6 @@ func TestServiceV2_AnnounceHost(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, @@ -561,7 +559,6 @@ func TestServiceV2_AnnounceHost(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, @@ -666,7 +663,6 @@ func TestServiceV2_AnnounceHost(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, @@ -767,7 +763,6 @@ func TestServiceV2_AnnounceHost(t *testing.T) { Network: &commonv2.Network{ TcpConnectionCount: mockNetwork.TCPConnectionCount, UploadTcpConnectionCount: mockNetwork.UploadTCPConnectionCount, - SecurityDomain: mockNetwork.SecurityDomain, Location: mockNetwork.Location, Idc: mockNetwork.IDC, }, diff --git a/scheduler/storage/storage_test.go b/scheduler/storage/storage_test.go index 6ff110ec8af..4ccd3ae23b9 100644 --- a/scheduler/storage/storage_test.go +++ b/scheduler/storage/storage_test.go @@ -93,7 +93,6 @@ var ( Network: resource.Network{ TCPConnectionCount: 400, UploadTCPConnectionCount: 200, - SecurityDomain: "product", Location: "china", IDC: "e1", },