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

feat: add release channel support for pulsar cluster #44

Merged
merged 8 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func init() {
"instance_name": "The pulsar instance name",
"location": "The location of the pulsar cluster, " +
"supported location https://docs.streamnative.io/docs/cluster#cluster-location",
"release_channel": "The release channel of the pulsar cluster subscribe to",
"bookie_replicas": "The number of bookie replicas",
"broker_replicas": "The number of broker replicas",
"compute_unit": "compute unit, 1 compute unit is 2 cpu and 8gb memory",
Expand Down
21 changes: 19 additions & 2 deletions cloud/resource_pulsar_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ func resourcePulsarCluster() *schema.Resource {
Description: descriptions["location"],
ValidateFunc: validateNotBlank,
},
"release_channel": {
Type: schema.TypeString,
Optional: true,
Default: "rapid",
Copy link
Member

Choose a reason for hiding this comment

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

Is the rapid channel used by default?

Copy link
Member

Choose a reason for hiding this comment

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

yes, on UI also uses the rapid as default

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, keep consistent with console UI

Description: descriptions["release_channel"],
ValidateFunc: validateNotBlank,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can add a function validateReleaseChannel to verify if it is lts, rapid or null.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, thanks.

},
"bookie_replicas": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -232,6 +239,7 @@ func resourcePulsarClusterCreate(ctx context.Context, d *schema.ResourceData, me
name := d.Get("name").(string)
instanceName := d.Get("instance_name").(string)
location := d.Get("location").(string)
releaseChannel := d.Get("release_channel").(string)
bookieReplicas := int32(d.Get("bookie_replicas").(int))
brokerReplicas := int32(d.Get("broker_replicas").(int))
computeUnit := d.Get("compute_unit").(float64)
Expand Down Expand Up @@ -272,8 +280,9 @@ func resourcePulsarClusterCreate(ctx context.Context, d *schema.ResourceData, me
Namespace: namespace,
},
Spec: cloudv1alpha1.PulsarClusterSpec{
InstanceName: instanceName,
Location: location,
InstanceName: instanceName,
Location: location,
ReleaseChannel: releaseChannel,
BookKeeper: &cloudv1alpha1.BookKeeper{
Replicas: &bookieReplicas,
Resources: &cloudv1alpha1.BookkeeperNodeResource{
Expand Down Expand Up @@ -375,6 +384,10 @@ func resourcePulsarClusterRead(ctx context.Context, d *schema.ResourceData, meta
_ = d.Set("pulsar_version", brokerImage[1])
bookkeeperImage := strings.Split(pulsarCluster.Spec.BookKeeper.Image, ":")
_ = d.Set("bookkeeper_version", bookkeeperImage[1])
releaseChannel := pulsarCluster.Spec.ReleaseChannel
if releaseChannel != "" {
_ = d.Set("release_channel", releaseChannel)
}
d.SetId(fmt.Sprintf("%s/%s", pulsarCluster.Namespace, pulsarCluster.Name))
return nil
}
Expand All @@ -396,6 +409,10 @@ func resourcePulsarClusterUpdate(ctx context.Context, d *schema.ResourceData, me
return diag.FromErr(fmt.Errorf("ERROR_UPDATE_PULSAR_CLUSTER: " +
"The pulsar cluster location does not support updates"))
}
if d.HasChange("release_channel") {
return diag.FromErr(fmt.Errorf("ERROR_UPDATE_PULSAR_CLUSTER: " +
"The pulsar cluster release channel does not support updates"))
}
namespace := d.Get("organization").(string)
name := d.Get("name").(string)
clientSet, err := getClientSet(getFactoryFromMeta(meta))
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/lestrrat-go/jwx/v2 v2.0.21
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/streamnative/cloud-api-server v1.17.1-0.20240201114855-a7d3a65094e8
github.com/streamnative/cloud-api-server v1.25.3
github.com/streamnative/cloud-cli v0.14.3-0.20240202094224-5eec608e4680
github.com/xhit/go-str2duration/v2 v2.1.0
k8s.io/apimachinery v0.28.4
Expand Down Expand Up @@ -160,7 +160,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.4 // indirect
k8s.io/apiserver v0.23.17 // indirect
k8s.io/apiserver v0.24.0 // indirect
k8s.io/component-base v0.28.4 // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ github.com/streamnative/apiserver-builder-alpha v0.0.0-20230717175906-0f92408874
github.com/streamnative/apiserver-builder-alpha v0.0.0-20230717175906-0f9240887463/go.mod h1:W1q2VCPvT9GjMUsFX4JYmdXfSAYsrmLVLALfutt5LsE=
github.com/streamnative/cloud-api-server v1.17.1-0.20240201114855-a7d3a65094e8 h1:xBeOFWaVodZLoF0G9suB+XcV1wts3bWAyQII0bjCwSk=
github.com/streamnative/cloud-api-server v1.17.1-0.20240201114855-a7d3a65094e8/go.mod h1:rnneB8IS0MtXXwi/HAXxBojs2qQj8w2taq48WCrYhv8=
github.com/streamnative/cloud-api-server v1.25.3 h1:Dvr7H7tyOKCKGwj5JmO7KGN2TVlu9KrsF/Ih3zBce1c=
github.com/streamnative/cloud-api-server v1.25.3/go.mod h1:GX9siEefhX5wq6u3ay3lh8taVVvM7TTTGnXuJrWksWw=
github.com/streamnative/cloud-cli v0.14.3-0.20240202094224-5eec608e4680 h1:PRqjyTsfwTCAd3SGDjgPT4Nmbczeegdm/ApyDGr14PA=
github.com/streamnative/cloud-cli v0.14.3-0.20240202094224-5eec608e4680/go.mod h1:48XuDAuu3upsbndxqN+grxz9yPSklZk9ycxKB235dGs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
Loading