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

Update instance type for pulsarinstance #79

Merged
merged 7 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions cloud/apikey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestApiKey(t *testing.T) {
apiKeyGeneratedName,
"shared-gcp",
"streamnative",
"us-central1", "lts"),
"us-central1", "rapid"),
Check: resource.ComposeTestCheckFunc(
testCheckApiKeyExists("streamnative_apikey.test-terraform-api-key"),
),
Expand Down Expand Up @@ -121,6 +121,7 @@ resource "streamnative_pulsar_instance" "test-api-key-pulsar-instance" {
availability_mode = "zonal"
pool_name = "%s"
pool_namespace = "%s"
type = "dedicated"
}
resource "streamnative_pulsar_cluster" "test-api-key-pulsar-cluster" {
organization = "%s"
Expand All @@ -129,7 +130,7 @@ resource "streamnative_pulsar_cluster" "test-api-key-pulsar-cluster" {
location = "%s"
release_channel = "%s"
config {
websocket_enabled = true
websocket_enabled = false
function_enabled = false
transaction_enabled = false
protocols {
Expand All @@ -141,7 +142,6 @@ resource "streamnative_pulsar_cluster" "test-api-key-pulsar-cluster" {
}
}
custom = {
"allowAutoTopicCreation" = "true"
"bookkeeper.journalSyncData" = "false"
"managedLedgerOffloadAutoTriggerSizeThresholdBytes" = "0"
}
Expand Down
8 changes: 6 additions & 2 deletions cloud/data_source_pulsar_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,14 @@ func dataSourcePulsarClusterRead(ctx context.Context, d *schema.ResourceData, me
}
if pulsarInstance.Spec.Type != cloudv1alpha1.PulsarInstanceTypeServerless && !pulsarCluster.IsUsingUrsaEngine() {
bookkeeperImage := strings.Split(pulsarCluster.Spec.BookKeeper.Image, ":")
_ = d.Set("bookkeeper_version", bookkeeperImage[1])
if len(bookkeeperImage) > 1 {
_ = d.Set("bookkeeper_version", bookkeeperImage[1])
}
}
brokerImage := strings.Split(pulsarCluster.Spec.Broker.Image, ":")
_ = d.Set("pulsar_version", brokerImage[1])
if len(brokerImage) > 1 {
_ = d.Set("pulsar_version", brokerImage[1])
}
_ = d.Set("type", pulsarInstance.Spec.Type)
releaseChannel := pulsarCluster.Spec.ReleaseChannel
if releaseChannel != "" {
Expand Down
2 changes: 1 addition & 1 deletion cloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func init() {
"pool_member_type": "Type of infrastructure pool member, one of aws, gcloud and azure",
"pool_member_location": "The location of the infrastructure pool member",
"instance_name": "The pulsar instance name",
"instance_type": "The streamnative cloud instance type, supporting 'serverless' and 'standard'",
"instance_type": "The streamnative cloud instance type, supporting 'serverless', 'dedicated', 'byoc' and 'byoc-pro'",
"instance_engine": "The streamnative cloud instance engine, supporting 'ursa' and 'classic', default 'classic'",
"location": "The location of the pulsar cluster, " +
"supported location https://docs.streamnative.io/docs/cluster#cluster-location",
Expand Down
6 changes: 3 additions & 3 deletions cloud/pulsar_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestPulsarCluster(t *testing.T) {
clusterGeneratedName,
"shared-gcp",
"streamnative",
"us-central1", "lts"),
"us-central1", "rapid"),
Check: resource.ComposeTestCheckFunc(
testCheckPulsarClusterExists("streamnative_pulsar_cluster.test-pulsar-cluster"),
),
Expand Down Expand Up @@ -125,6 +125,7 @@ resource "streamnative_pulsar_instance" "test-pulsar-instance" {
availability_mode = "zonal"
pool_name = "%s"
pool_namespace = "%s"
type = "dedicated"
}
resource "streamnative_pulsar_cluster" "test-pulsar-cluster" {
organization = "%s"
Expand All @@ -133,7 +134,7 @@ resource "streamnative_pulsar_cluster" "test-pulsar-cluster" {
location = "%s"
release_channel = "%s"
config {
websocket_enabled = true
websocket_enabled = false
function_enabled = false
transaction_enabled = false
protocols {
Expand All @@ -145,7 +146,6 @@ resource "streamnative_pulsar_cluster" "test-pulsar-cluster" {
}
}
custom = {
"allowAutoTopicCreation" = "true"
"bookkeeper.journalSyncData" = "false"
"managedLedgerOffloadAutoTriggerSizeThresholdBytes" = "0"
}
Expand Down
14 changes: 6 additions & 8 deletions cloud/resource_pulsar_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,6 @@ func resourcePulsarClusterCreate(ctx context.Context, d *schema.ResourceData, me
if err != nil {
return diag.FromErr(fmt.Errorf("ERROR_GET_PULSAR_INSTANCE_ON_CREATE_PULSAR_CLUSTER: %w", err))
}
if pulsarInstance.Spec.Plan == string(cloudv1alpha1.PulsarInstanceTypeFree) {
return diag.FromErr(fmt.Errorf(
"ERROR_CREATE_PULSAR_CLUSTER: "+
"creating a cluster under instance of type '%s' is no longer allowed",
cloudv1alpha1.PulsarInstanceTypeFree))
}
ursaEngine, ok := pulsarInstance.Annotations[UrsaEngineAnnotation]
ursaEnabled := ok && ursaEngine == UrsaEngineValue
bookieCPU := resource.NewMilliQuantity(int64(storageUnit*2*1000), resource.DecimalSI)
Expand Down Expand Up @@ -596,10 +590,14 @@ func resourcePulsarClusterRead(ctx context.Context, d *schema.ResourceData, meta
}
if pulsarInstance.Spec.Type != cloudv1alpha1.PulsarInstanceTypeServerless && !pulsarCluster.IsUsingUrsaEngine() {
bookkeeperImage := strings.Split(pulsarCluster.Spec.BookKeeper.Image, ":")
_ = d.Set("bookkeeper_version", bookkeeperImage[1])
if len(bookkeeperImage) > 1 {
_ = d.Set("bookkeeper_version", bookkeeperImage[1])
}
}
brokerImage := strings.Split(pulsarCluster.Spec.Broker.Image, ":")
_ = d.Set("pulsar_version", brokerImage[1])
if len(brokerImage) > 1 {
_ = d.Set("pulsar_version", brokerImage[1])
}
releaseChannel := pulsarCluster.Spec.ReleaseChannel
if releaseChannel != "" {
_ = d.Set("release_channel", releaseChannel)
Expand Down
21 changes: 16 additions & 5 deletions cloud/resource_pulsar_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,22 @@ func resourcePulsarInstanceCreate(ctx context.Context, d *schema.ResourceData, m
Namespace: poolNamespace,
Name: poolName,
}
var t cloudv1alpha1.PulsarInstanceType
poolOption, err := clientSet.CloudV1alpha1().
PoolOptions(namespace).
Get(ctx, fmt.Sprintf("%s-%s", poolNamespace, poolName), metav1.GetOptions{})
if err != nil {
return diag.FromErr(fmt.Errorf("ERROR_GET_POOL_OPTION: %w", err))
}
if instanceType == "" {
t = cloudv1alpha1.PulsarInstanceTypeStandard
} else {
t = cloudv1alpha1.PulsarInstanceType(instanceType)
if poolOption.Spec.DeploymentType == cloudv1alpha1.PoolDeploymentTypeHosted {
instanceType = "serverless"
}
if poolOption.Spec.DeploymentType == cloudv1alpha1.PoolDeploymentTypeManaged {
instanceType = "byoc"
}
if poolOption.Spec.DeploymentType == cloudv1alpha1.PoolDeploymentTypeManagedPro {
instanceType = "byoc-pro"
}
}
pulsarInstance := &cloudv1alpha1.PulsarInstance{
TypeMeta: metav1.TypeMeta{
Expand All @@ -151,7 +162,7 @@ func resourcePulsarInstanceCreate(ctx context.Context, d *schema.ResourceData, m
},
Spec: cloudv1alpha1.PulsarInstanceSpec{
AvailabilityMode: cloudv1alpha1.InstanceAvailabilityMode(availabilityMode),
Type: t,
Type: cloudv1alpha1.PulsarInstanceType(instanceType),
PoolRef: poolRef,
},
}
Expand Down
4 changes: 2 additions & 2 deletions cloud/validate_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func validateEngine(val interface{}, key string) (warns []string, errs []error)

func validateInstanceType(val interface{}, key string) (warns []string, errs []error) {
v := val.(string)
if v != "serverless" && v != "standard" {
errs = append(errs, fmt.Errorf("%q must be serverless or standard", key))
if v != "serverless" && v != "standard" && v != "dedicated" && v != "byoc" && v != "byoc-pro" {
errs = append(errs, fmt.Errorf("%q must be serverless, dedicated, byoc and byoc-pro", key))
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/pulsar_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ description: |-
- `ready` (String) Pulsar cluster is ready, it will be set to 'True' after the cluster is ready
- `release_channel` (String) The release channel of the pulsar cluster subscribe to, it must to be lts or rapid, default rapid
- `storage_unit` (Number) storage unit, 1 storage unit is 2 cpu and 8gb memory
- `type` (String) The streamnative cloud instance type, supporting 'serverless' and 'standard'
- `type` (String) The streamnative cloud instance type, supporting 'serverless', 'dedicated', 'byoc' and 'byoc-pro'
- `websocket_service_url` (String) If you want to connect to the pulsar cluster using the websocket protocol, use this websocket service url.
- `websocket_service_urls` (List of String) If you want to connect to the pulsar cluster using the websocket protocol, use this websocket service url. There'll be multiple service urls if the cluster attached with multiple gateways

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/pulsar_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ description: |-
- `pulsar_tls_service_urls` (List of String) The service url of the pulsar cluster, use it to produce and consume message. There'll be multiple service urls if the cluster attached with multiple gateways
- `pulsar_version` (String) The version of the pulsar cluster
- `ready` (String) Pulsar cluster is ready, it will be set to 'True' after the cluster is ready
- `type` (String) The streamnative cloud instance type, supporting 'serverless' and 'standard'
- `type` (String) The streamnative cloud instance type, supporting 'serverless', 'dedicated', 'byoc' and 'byoc-pro'
- `websocket_service_url` (String) If you want to connect to the pulsar cluster using the websocket protocol, use this websocket service url.
- `websocket_service_urls` (List of String) If you want to connect to the pulsar cluster using the websocket protocol, use this websocket service url. There'll be multiple service urls if the cluster attached with multiple gateways

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/pulsar_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ description: |-
### Optional

- `engine` (String) The streamnative cloud instance engine, supporting 'ursa' and 'classic', default 'classic'
- `type` (String) The streamnative cloud instance type, supporting 'serverless' and 'standard'
- `type` (String) The streamnative cloud instance type, supporting 'serverless', 'dedicated', 'byoc' and 'byoc-pro'

### Read-Only

Expand Down
2 changes: 1 addition & 1 deletion examples/ursa/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resource "streamnative_pulsar_instance" "test-ursa" {
availability_mode = "regional"
pool_name = "shared-aws"
pool_namespace = "max"
type = "standard"
type = "byoc"
engine = "ursa"
}

Expand Down
37 changes: 27 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/streamnative/terraform-provider-streamnative

go 1.19
go 1.21

require (
github.com/99designs/keyring v1.2.1
Expand All @@ -10,8 +10,8 @@ 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.25.2-0.20240831031803-0f2ee39717f6
github.com/streamnative/cloud-cli v0.14.3-0.20240202094224-5eec608e4680
github.com/streamnative/cloud-api-server v1.25.2-0.20241126113204-4d08d27e3122
github.com/streamnative/cloud-cli v0.19.5
github.com/xhit/go-str2duration/v2 v2.1.0
k8s.io/apimachinery v0.29.4
k8s.io/cli-runtime v0.29.4
Expand All @@ -21,19 +21,27 @@ require (
)

require (
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/AthenZ/athenz v1.10.39 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/DataDog/zstd v1.5.0 // indirect
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/actgardner/gogen-avro/v10 v10.2.1 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apache/pulsar-client-go v0.13.1 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/ardielle/ardielle-go v1.5.2 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bits-and-blooms/bitset v1.4.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
Expand All @@ -50,7 +58,7 @@ require (
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fvbommel/sortorder v1.0.1 // indirect
github.com/go-errors/errors v1.4.2 // indirect
Expand All @@ -61,6 +69,7 @@ require (
github.com/goccy/go-json v0.10.2 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.0.1 // indirect
Expand All @@ -72,6 +81,7 @@ require (
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hamba/avro/v2 v2.22.2-0.20240625062549-66aad10411d9 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand All @@ -96,6 +106,7 @@ require (
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.5 // indirect
Expand All @@ -105,6 +116,7 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand All @@ -113,23 +125,28 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20210610120745-9d4ed1856297 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -145,19 +162,20 @@ require (
go.etcd.io/etcd/client/v3 v3.5.1 // indirect
go.opentelemetry.io/contrib v0.20.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp v0.20.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/otel/sdk/export/metric v0.20.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
Expand All @@ -166,7 +184,8 @@ require (
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down Expand Up @@ -245,8 +264,6 @@ replace (
github.com/streamnative/sn-operator/api => github.com/streamnative/sn-operator/api v0.6.0-rc.18
github.com/streamnative/sn-operator/api/commons => github.com/streamnative/sn-operator/api/commons v0.6.0-rc.18
github.com/streamnative/sn-operator/pkg/commons => github.com/streamnative/sn-operator/pkg/commons v0.6.0-rc.18
google.golang.org/api => google.golang.org/api v0.32.0
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200825200019-8632dd797987
)

replace sigs.k8s.io/apiserver-builder-alpha => github.com/streamnative/apiserver-builder-alpha v0.0.0-20240326220620-ce0d72b3e222 // v1.23.sn
Loading