Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] New bcs instance resource supported #1064

Merged
merged 2 commits into from
Apr 22, 2021
Merged

[Feature Request] New bcs instance resource supported #1064

merged 2 commits into from
Apr 22, 2021

Conversation

Lance52259
Copy link
Contributor

@Lance52259 Lance52259 commented Apr 14, 2021

What this PR does / why we need it:
New BCS instance resource supported:

  • bcs instance create:
    • two fabric version (1.4 and 2.0)
    • three service edition (basic, professional and enterprise)
    • four consensus algorithm (solo, kafka, SFLIC and etcdraft)
    • two sign algorithm (ECDSA and SM2)
    • two volume type (nfs and efs)
    • two database type (goleveldb and couchdb)
  • bcs instance read (state):
    • basic info
    • channel info
    • peer organization info
    • couchdb info
    • kafka info

TODO:

  • create and bind new channels and peer organizations
  • invitor infos
  • prepaid
  • evs supported (SATA, SAS, SSD)

Which issue this PR fixes:
(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)
fixes #1023

Special notes for your reviewer:

Release note:

1. new bcs instance resource and acc test.
2. new bcs instance document.

PR Checklist

  • Tests added/passed.
  • Documentation updated.
  • Schema updated.

Acceptance Steps Performed

BCS client test

make testacc TEST='./huaweicloud' TESTARGS='-run=TestAccServiceEndpoints_Application'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./huaweicloud -v -run=TestAccServiceEndpoints_Application -timeout 360m -parallel 4
=== RUN   TestAccServiceEndpoints_Application
--- PASS: TestAccServiceEndpoints_Application (1.56s)
PASS
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud       1.603s

Basic test

make testacc TEST='./huaweicloud' TESTARGS='-run=TestAccBCSV2Instance_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./huaweicloud -v -run=TestAccBCSV2Instance_basic -timeout 360m -parallel 4
=== RUN   TestAccBCSV2Instance_basic
=== PAUSE TestAccBCSV2Instance_basic
=== CONT  TestAccBCSV2Instance_basic
--- PASS: TestAccBCSV2Instance_basic (1184.98s)
PASS
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud       1185.043s

Kafka consensus

make testacc TEST='./huaweicloud' TESTARGS='-run=TestAccBCSV2Instance_kafka'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./huaweicloud -v -run=TestAccBCSV2Instance_kafka -timeout 360m -parallel 4
=== RUN   TestAccBCSV2Instance_kafka
=== PAUSE TestAccBCSV2Instance_kafka
=== CONT  TestAccBCSV2Instance_kafka
--- PASS: TestAccBCSV2Instance_kafka (2539.99s)
PASS
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud       2540.048s

huaweicloud/config/endpoints.go Outdated Show resolved Hide resolved
```hcl
data "huaweicloud_availability_zones" "test" {}

resource "huaweicloud_cce_cluster" "test" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to use data source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example now uses data source to support the cluster info.

resource "huaweicloud_bcs_instance" "test" {
depends_on = [huaweicloud_cce_node.test]

name = {Resource_Name}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to use var.instance_name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has been updated as a variable

Comment on lines 160 to 161
* `cluster_type` - (Required, String, ForceNew) Specifies the type of the cluster.
Valid value is `cce`. Changing this will create a new instance.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this parameter only supports cce, we can omit it or set it defaults to cce.

Copy link
Contributor Author

@Lance52259 Lance52259 Apr 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cluster_type has been removed and always set with cce.

Changing this will create a new instance.

* `orderer_node_num` - (Required, Int, ForceNew) Specifies the number of peers in the orderer organizaion.
Refer to Table 1 for the configuration of the `orderer_node_num`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where can I get the link if Table 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description has been updated and use link to point the table.

Target: []string{"Normal"},
Refresh: blockchainStateRefreshFunc(client, instanceID),
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 15 * time.Second,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we wait for more time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the creation time of the basic version (The simplest configuration of instance creation time: 2m50s±20s), it is now set to 150s.

Comment on lines 141 to 145
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get the cce cluster name by id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cluster_info struct is updated to cluster_id parameter.

return nil
}

func resourceBCSInstanceV2Update(d *schema.ResourceData, meta interface{}) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function can be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related notes added.

)

//Huawei@123
const salt_password string = "JDYkcGxkUm9uUE55UTEweGRCUyRxbWFDRFluTFhPVjNCakVraGc5YUdhUTBxeWFocmNDbzZ4YS9rVWkyYVB2S" +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard coding is not recommended, can we use key_pair?

Copy link
Contributor Author

@Lance52259 Lance52259 Apr 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's updated

fabric_version = "1.4"
blockchain_type = "private"
enterprise_project_id = "%s"
password = "Huawei@123"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we using random_password?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the acc test does not support random providers, the message is:

        - Could not satisfy plugin requirements: 
        Plugin reinitialization required. Please run "terraform init".
        
        Plugins are external binaries that Terraform uses to access and manipulate
        resources. The configuration provided requires plugins which can't be located,
        don't satisfy the version constraints, or are otherwise incompatible.
        
        Terraform automatically discovers provider requirements from your
        configuration, including providers used in child modules. To see the
        requirements and constraints from each module, run "terraform providers".
        
        - provider "random" is not available

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration of random password is :

resource "random_password" "instance_password" {
	length           = 12
	special          = true
	min_lower        = 1
	min_upper        = 1
	override_special = "!@$%%^-_=+[{}]:,./?"
}

return &schema.Resource{
Create: resourceBCSInstanceV2Create,
Read: resourceBCSInstanceV2Read,
Update: resourceBCSInstanceV2Update,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is nothing to do in update func, this line is unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used to update delete_obs and delete_storage, and the related notes added.

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of 'channels' is list, so change the param 'name' won't cause forcenew. Is this your intention

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, forceNew is added


* `edition` - (Required, Int, ForceNew) Specifies Service edition of the BCS instance.
Valid values are `1`, `2` and `4`.
For the specifications corresponding to these three versions, please refer to the [specification table](#jump).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this can jump to the specification table?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, it can jump to the specification table (I mark it with jump) at the end of Argument Reference.

Changing this will create a new instance.

* `orderer_node_num` - (Required, Int, ForceNew) Specifies the number of peers in the orderer organizaion.
For the number of orderer nodes, please refer to the [specification table](#jump).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the specification table shown the max number of orderer nodes?

For the number of orderer nodes, please refer to the [specification table](#jump).
Changing this will create a new instance.

* `cluster_id` - (Required, String, ForceNew) Specifies the ID of the CCE cluster to attach to the BCS instance.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to named as cce_cluster_id

Computed: true,
ForceNew: true,
},
"eip_enable": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in schema the default value of eip_enable is false, but it is defaults to true in docs.

* `type` - (Optional, String, ForceNew) Specifies the type of SFS turbo.
Changing this creates a new instance.

The `block_info` block supports:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add the description of block_info

}

func resourceBCSInstanceV2Create(d *schema.ResourceData, meta interface{}) error {
var FALSE bool = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/FALSE/newCluster/g

@ShiChangkuo ShiChangkuo merged commit 7280621 into huaweicloud:master Apr 22, 2021
@Lance52259 Lance52259 deleted the br_bcs_instance_active branch May 11, 2021 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: BCS resources support
3 participants