diff --git a/.config.yaml.sample b/.config.yaml.sample index 4ee176bf..69872474 100644 --- a/.config.yaml.sample +++ b/.config.yaml.sample @@ -16,6 +16,6 @@ HealthProbePort: 8083 # Enable/Disable features. FeatureFlags: - DeployNatsConnector: true + DeployConnector: true DeployNeptune: false SkipAstraRegistration: false diff --git a/README.md b/README.md index 88d9faa2..d63562f4 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,7 @@ This guide provides instructions for installing the latest version of the Astra clusterName: skipTLSValidation: false # Should be set to false in production environments tokenRef: astra-token - natsSyncClient: - cloudBridgeURL: + astraControlURL: hostAliasIP: imageRegistry: name: cr.astra.netapp.io/astra diff --git a/app/conf/config.go b/app/conf/config.go index 00402751..dad2e08e 100644 --- a/app/conf/config.go +++ b/app/conf/config.go @@ -78,8 +78,8 @@ func DefaultConfiguration() *MutableConfiguration { WaitDurationForResource: 5 * time.Minute, ErrorTimeout: 5, FeatureFlags: featureFlags{ - DeployNatsConnector: true, - DeployNeptune: true, + DeployConnector: true, + DeployNeptune: true, }, } } @@ -95,8 +95,8 @@ func toImmutableConfig(config *MutableConfiguration) *ImmutableConfiguration { waitDurationForResource: config.WaitDurationForResource, errorTimeout: config.ErrorTimeout, featureFlags: ImmutableFeatureFlags{ - deployNatsConnector: config.FeatureFlags.DeployNatsConnector, - deployNeptune: config.FeatureFlags.DeployNeptune, + deployConnector: config.FeatureFlags.DeployConnector, + deployNeptune: config.FeatureFlags.DeployNeptune, }, config: config, } @@ -142,17 +142,17 @@ func (i ImmutableConfiguration) FeatureFlags() ImmutableFeatureFlags { } type ImmutableFeatureFlags struct { - deployNatsConnector bool - deployNeptune bool + deployConnector bool + deployNeptune bool } type featureFlags struct { - DeployNatsConnector bool - DeployNeptune bool + DeployConnector bool + DeployNeptune bool } -func (f ImmutableFeatureFlags) DeployNatsConnector() bool { - return f.deployNatsConnector +func (f ImmutableFeatureFlags) DeployConnector() bool { + return f.deployConnector } func (f ImmutableFeatureFlags) DeployNeptune() bool { diff --git a/app/conf/config_test.go b/app/conf/config_test.go index 0c1d1499..2eaaae08 100644 --- a/app/conf/config_test.go +++ b/app/conf/config_test.go @@ -40,8 +40,8 @@ func TestImmutableFeatureFlags(t *testing.T) { // Initialize a test feature flag configuration flags := conf.ImmutableFeatureFlags{} - if flags.DeployNatsConnector() != false { - t.Errorf("Expected true, got %v", flags.DeployNatsConnector()) + if flags.DeployConnector() != false { + t.Errorf("Expected true, got %v", flags.DeployConnector()) } if flags.DeployNeptune() != false { diff --git a/app/deployer/connector/astra_connect_natless.go b/app/deployer/connector/astra_connect_natless.go index 58976284..95e15a9b 100644 --- a/app/deployer/connector/astra_connect_natless.go +++ b/app/deployer/connector/astra_connect_natless.go @@ -54,6 +54,7 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co connectorImage = fmt.Sprintf("%s/astra-connector:%s", imageRegistry, containerImage) log.Info("Using AstraConnector image", "image", connectorImage) + replicaCount := int32(1) if m.Spec.Astra.ClusterId == "" && m.Spec.Astra.ClusterName == "" { err := fmt.Errorf("clusterID and clusterName both cannot be empty") @@ -70,8 +71,7 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co }, }, Spec: appsv1.DeploymentSpec{ - // TODO remove option to set replica count in CRD. This should always only-ever be 1 - Replicas: &m.Spec.AstraConnect.Replicas, + Replicas: &replicaCount, Selector: &metav1.LabelSelector{ MatchLabels: ls, }, @@ -88,17 +88,13 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co Name: "LOG_LEVEL", // todo should this match what operator is Value: "info", }, - { - Name: "NATS_DISABLED", - Value: "true", - }, { Name: "API_TOKEN_SECRET_REF", Value: m.Spec.Astra.TokenRef, }, { Name: "ASTRA_CONTROL_URL", - Value: m.Spec.NatsSyncClient.CloudBridgeURL, + Value: m.Spec.Astra.AstraControlURL, }, { Name: "ACCOUNT_ID", @@ -114,7 +110,7 @@ func (d *AstraConnectDeployer) GetDeploymentObjects(m *v1.AstraConnector, ctx co }, { Name: "HOST_ALIAS_IP", - Value: m.Spec.NatsSyncClient.HostAliasIP, + Value: m.Spec.Astra.HostAliasIP, }, { Name: "SKIP_TLS_VALIDATION", @@ -198,17 +194,23 @@ func (d *AstraConnectDeployer) GetServiceObjects(m *v1.AstraConnector, ctx conte // GetConfigMapObjects returns a ConfigMap object for Astra Connect func (d *AstraConnectDeployer) GetConfigMapObjects(m *v1.AstraConnector, ctx context.Context) ([]client.Object, controllerutil.MutateFn, error) { + data := map[string]string{ + "skip_tls_validation": strconv.FormatBool(m.Spec.Astra.SkipTLSValidation), + } + configMap := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Namespace: m.Namespace, Name: common.AstraConnectName, }, - Data: map[string]string{ - //"nats_url": GetNatsURL(m), - "skip_tls_validation": strconv.FormatBool(m.Spec.Astra.SkipTLSValidation), - }, + Data: data, + } + + mutateFn := func() error { + configMap.Data = data + return nil } - return []client.Object{configMap}, model.NonMutateFn, nil + return []client.Object{configMap}, mutateFn, nil } // GetServiceAccountObjects returns a ServiceAccount object for Astra Connect diff --git a/app/deployer/connector/astra_connect_test.go b/app/deployer/connector/astra_connect_test.go index ed7f0dd8..471a560a 100644 --- a/app/deployer/connector/astra_connect_test.go +++ b/app/deployer/connector/astra_connect_test.go @@ -64,7 +64,6 @@ func TestAstraConnectGetDeploymentObjects(t *testing.T) { assert.Equal(t, 10, len(container.Env)) assert.Equal(t, "LOG_LEVEL", container.Env[0].Name) - assert.Equal(t, "NATS_DISABLED", container.Env[1].Name) assert.Equal(t, "true", container.Env[1].Value) assert.Equal(t, 1, len(deployment.Spec.Template.Spec.ImagePullSecrets)) @@ -116,8 +115,7 @@ func DummyAstraConnector() v1.AstraConnector { Secret: "test-secret", }, AstraConnect: v1.AstraConnect{ - Image: "test-image", - Replicas: 1, + Image: "test-image", }, AutoSupport: v1.AutoSupport{ Enrolled: true, diff --git a/app/register/register.go b/app/register/register.go index 701056f3..4bf8dce2 100644 --- a/app/register/register.go +++ b/app/register/register.go @@ -127,11 +127,11 @@ type AstraConnector struct { func GetAstraHostURL(astraConnector *v1.AstraConnector) string { var astraHost string - if astraConnector.Spec.NatsSyncClient.CloudBridgeURL != "" { - astraHost = astraConnector.Spec.NatsSyncClient.CloudBridgeURL + if astraConnector.Spec.Astra.AstraControlURL != "" { + astraHost = astraConnector.Spec.Astra.AstraControlURL astraHost = strings.TrimSuffix(astraHost, "/") } else { - astraHost = common.NatsSyncClientDefaultCloudBridgeURL + astraHost = common.DefaultCloudAstraControlURL } return astraHost @@ -160,8 +160,8 @@ func (c clusterRegisterUtil) SetHttpClient(disableTls bool, astraHost string) er c.Log.WithValues("disableTls", disableTls).Info("TLS Validation Disabled! Not for use in production!") } - if c.AstraConnector.Spec.NatsSyncClient.HostAliasIP != "" { - c.Log.WithValues("HostAliasIP", c.AstraConnector.Spec.NatsSyncClient.HostAliasIP).Info("Using the HostAlias IP") + if c.AstraConnector.Spec.Astra.HostAliasIP != "" { + c.Log.WithValues("HostAliasIP", c.AstraConnector.Spec.Astra.HostAliasIP).Info("Using the HostAlias IP") cloudBridgeHost, err := c.getAstraHostFromURL(astraHost) if err != nil { return err @@ -174,10 +174,10 @@ func (c clusterRegisterUtil) SetHttpClient(disableTls bool, astraHost string) er http.DefaultTransport.(*http.Transport).DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { if addr == cloudBridgeHost+":443" { - addr = c.AstraConnector.Spec.NatsSyncClient.HostAliasIP + ":443" + addr = c.AstraConnector.Spec.Astra.HostAliasIP + ":443" } if addr == cloudBridgeHost+":80" { - addr = c.AstraConnector.Spec.NatsSyncClient.HostAliasIP + ":80" + addr = c.AstraConnector.Spec.Astra.HostAliasIP + ":80" } return dialer.DialContext(ctx, network, addr) } diff --git a/app/register/register_test.go b/app/register/register_test.go index 621464c0..47c43fa5 100644 --- a/app/register/register_test.go +++ b/app/register/register_test.go @@ -102,8 +102,8 @@ func createClusterRegister(astraConnectorInput AstraConnectorInput) (register.Cl } if astraConnectorInput.invalidHostDetails { - astraConnector.Spec.NatsSyncClient.CloudBridgeURL = testURL - astraConnector.Spec.NatsSyncClient.HostAliasIP = testIP + astraConnector.Spec.Astra.AstraControlURL = testURL + astraConnector.Spec.Astra.HostAliasIP = testIP } clusterRegisterUtil := register.NewClusterRegisterUtil(astraConnector, mockHttpClient, fakeClient, k8sUtil, log, context.Background()) diff --git a/common/constants.go b/common/constants.go index 22be003b..ea84dab6 100644 --- a/common/constants.go +++ b/common/constants.go @@ -7,8 +7,6 @@ package common import ( _ "embed" "strings" - - "github.com/NetApp-Polaris/astra-connector-operator/app/conf" ) const ( @@ -18,8 +16,7 @@ const ( AstraConnectName = "astraconnect" AstraConnectorOperatorRepository = "netapp/astra-connector-operator" - NatsSyncClientDefaultImage = "natssync-client:2.2.202402012115" - NatsSyncClientDefaultCloudBridgeURL = "https://astra.netapp.io" + DefaultCloudAstraControlURL = "https://astra.netapp.io" NeptuneName = "neptune-controller-manager" @@ -27,10 +24,6 @@ const ( NeptuneMetricServiceProtocol = "TCP" NeptuneReplicas = 1 - ConnectorNeptuneCapability = "neptuneV1" - ConnectorV2Capability = "connectorV2" // V2 refers specifically to Arch 3.0 connector and beyond - ConnectorWatcherCapability = "watcherV1" - RbacProxyImage = "kube-rbac-proxy:v0.14.1" ) @@ -55,15 +48,3 @@ var ( func GetNeptuneRepositories() []string { return []string{"controller", "exechook", "resourcebackup", "resourcedelete", "resourcerestore", "resourcesummaryupload", "restic"} } - -func GetConnectorCapabilities() []string { - capabilities := []string{ - ConnectorV2Capability, - ConnectorWatcherCapability, - } - - if conf.Config.FeatureFlags().DeployNeptune() { - capabilities = append(capabilities, ConnectorNeptuneCapability) - } - return capabilities -} diff --git a/details/operator-sdk/api/v1/astraconnector_types.go b/details/operator-sdk/api/v1/astraconnector_types.go index d6de5063..85092ae1 100644 --- a/details/operator-sdk/api/v1/astraconnector_types.go +++ b/details/operator-sdk/api/v1/astraconnector_types.go @@ -12,6 +12,8 @@ import ( type Astra struct { // +kubebuilder:validation:Required AccountId string `json:"accountId"` + // +kubebuilder:validation:Required + AstraControlURL string `json:"astraControlURL,omitempty"` // +kubebuilder:validation:Optional CloudId string `json:"cloudId"` // +kubebuilder:validation:Optional @@ -19,6 +21,8 @@ type Astra struct { // +kubebuilder:validation:Optional ClusterName string `json:"clusterName,omitempty"` // +kubebuilder:validation:Optional + HostAliasIP string `json:"hostAliasIP,omitempty"` + // +kubebuilder:validation:Optional SkipTLSValidation bool `json:"skipTLSValidation,omitempty"` TokenRef string `json:"tokenRef,omitempty"` // +kubebuilder:validation:Optional @@ -36,30 +40,10 @@ type AutoSupport struct { URL string `json:"url,omitempty"` } -type NatsSyncClient struct { - CloudBridgeURL string `json:"cloudBridgeURL,omitempty"` - // +kubebuilder:validation:Optional - Image string `json:"image,omitempty"` - // +kubebuilder:validation:Optional - HostAliasIP string `json:"hostAliasIP,omitempty"` - // +kubebuilder:default:=1 - Replicas int32 `json:"replicas,omitempty"` -} - -// +kubebuilder:validation:Optional - -type Nats struct { - Image string `json:"image,omitempty"` - // +kubebuilder:default:=1 - Replicas int32 `json:"replicas,omitempty"` -} - // +kubebuilder:validation:Optional type AstraConnect struct { - Image string `json:"image,omitempty"` - // +kubebuilder:default:=1 - Replicas int32 `json:"replicas,omitempty"` + Image string `json:"image,omitempty"` ResourceRequirements corev1.ResourceRequirements `json:"resources,omitempty"` } @@ -73,12 +57,10 @@ type Neptune struct { // AstraConnectorSpec defines the desired state of AstraConnector type AstraConnectorSpec struct { - Astra Astra `json:"astra"` - NatsSyncClient NatsSyncClient `json:"natsSyncClient,omitempty"` - Nats Nats `json:"nats,omitempty"` - AstraConnect AstraConnect `json:"astraConnect,omitempty"` - Neptune Neptune `json:"neptune"` - ImageRegistry ImageRegistry `json:"imageRegistry,omitempty"` + Astra Astra `json:"astra"` + AstraConnect AstraConnect `json:"astraConnect,omitempty"` + Neptune Neptune `json:"neptune"` + ImageRegistry ImageRegistry `json:"imageRegistry,omitempty"` // AutoSupport indicates willingness to participate in NetApp's proactive support application, NetApp Active IQ. // An internet connection is required (port 442) and all support data is anonymized. @@ -98,11 +80,6 @@ type AstraConnectorSpec struct { // AstraConnectorStatus defines the observed state of AstraConnector type AstraConnectorStatus struct { - NatsSyncClient NatsSyncClientStatus `json:"natsSyncClient"` -} - -// NatsSyncClientStatus defines the observed state of NatsSyncClient -type NatsSyncClientStatus struct { Registered string `json:"registered"` //todo cluster vs connector registered AstraClusterId string `json:"astraClusterID,omitempty"` Status string `json:"status"` @@ -117,9 +94,9 @@ type ImageRegistry struct { //+kubebuilder:object:root=true //+kubebuilder:subresource:status -//+kubebuilder:printcolumn:name="Registered",type=string,JSONPath=`.status.natsSyncClient.registered` -//+kubebuilder:printcolumn:name="AstraClusterID",type=string,JSONPath=`.status.natsSyncClient.astraClusterID` -//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.natsSyncClient.status` +//+kubebuilder:printcolumn:name="Registered",type=string,JSONPath=`.status.registered` +//+kubebuilder:printcolumn:name="AstraClusterID",type=string,JSONPath=`.status.astraClusterID` +//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status` // AstraConnector is the Schema for the astraconnectors API // +kubebuilder:subresource:status diff --git a/details/operator-sdk/api/v1/zz_generated.deepcopy.go b/details/operator-sdk/api/v1/zz_generated.deepcopy.go index aefea291..a88b764a 100644 --- a/details/operator-sdk/api/v1/zz_generated.deepcopy.go +++ b/details/operator-sdk/api/v1/zz_generated.deepcopy.go @@ -107,8 +107,6 @@ func (in *AstraConnectorList) DeepCopyObject() runtime.Object { func (in *AstraConnectorSpec) DeepCopyInto(out *AstraConnectorSpec) { *out = *in out.Astra = in.Astra - out.NatsSyncClient = in.NatsSyncClient - out.Nats = in.Nats in.AstraConnect.DeepCopyInto(&out.AstraConnect) in.Neptune.DeepCopyInto(&out.Neptune) out.ImageRegistry = in.ImageRegistry @@ -135,7 +133,6 @@ func (in *AstraConnectorSpec) DeepCopy() *AstraConnectorSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AstraConnectorStatus) DeepCopyInto(out *AstraConnectorStatus) { *out = *in - out.NatsSyncClient = in.NatsSyncClient } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AstraConnectorStatus. @@ -178,51 +175,6 @@ func (in *ImageRegistry) DeepCopy() *ImageRegistry { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Nats) DeepCopyInto(out *Nats) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Nats. -func (in *Nats) DeepCopy() *Nats { - if in == nil { - return nil - } - out := new(Nats) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NatsSyncClient) DeepCopyInto(out *NatsSyncClient) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatsSyncClient. -func (in *NatsSyncClient) DeepCopy() *NatsSyncClient { - if in == nil { - return nil - } - out := new(NatsSyncClient) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NatsSyncClientStatus) DeepCopyInto(out *NatsSyncClientStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatsSyncClientStatus. -func (in *NatsSyncClientStatus) DeepCopy() *NatsSyncClientStatus { - if in == nil { - return nil - } - out := new(NatsSyncClientStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Neptune) DeepCopyInto(out *Neptune) { *out = *in diff --git a/details/operator-sdk/config/crd/bases/astra.netapp.io_astraconnectors.yaml b/details/operator-sdk/config/crd/bases/astra.netapp.io_astraconnectors.yaml index 9011d05c..b73f3c4a 100644 --- a/details/operator-sdk/config/crd/bases/astra.netapp.io_astraconnectors.yaml +++ b/details/operator-sdk/config/crd/bases/astra.netapp.io_astraconnectors.yaml @@ -17,13 +17,13 @@ spec: scope: Namespaced versions: - additionalPrinterColumns: - - jsonPath: .status.natsSyncClient.registered + - jsonPath: .status.registered name: Registered type: string - - jsonPath: .status.natsSyncClient.astraClusterID + - jsonPath: .status.astraClusterID name: AstraClusterID type: string - - jsonPath: .status.natsSyncClient.status + - jsonPath: .status.status name: Status type: string name: v1 @@ -50,12 +50,16 @@ spec: properties: accountId: type: string + astraURL: + type: string cloudId: type: string clusterId: type: string clusterName: type: string + hostAliasIP: + type: string skipTLSValidation: type: boolean tokenRef: @@ -71,10 +75,6 @@ spec: properties: image: type: string - replicas: - default: 1 - format: int32 - type: integer resources: description: ResourceRequirements describes the compute resource requirements. @@ -159,28 +159,6 @@ spec: type: string description: Labels any additional labels wanted to be added to resources type: object - nats: - properties: - image: - type: string - replicas: - default: 1 - format: int32 - type: integer - type: object - natsSyncClient: - properties: - cloudBridgeURL: - type: string - hostAliasIP: - type: string - image: - type: string - replicas: - default: 1 - format: int32 - type: integer - type: object neptune: description: Neptune properties: @@ -248,16 +226,12 @@ spec: status: description: AstraConnectorStatus defines the observed state of AstraConnector properties: - natsSyncClient: - description: NatsSyncClientStatus defines the observed state of NatsSyncClient - properties: - astraClusterID: - type: string - registered: - type: string - status: - type: string - type: object + astraClusterID: + type: string + registered: + type: string + status: + type: string type: object type: object served: true diff --git a/details/operator-sdk/config/samples/astra_v1_astraconnector.yaml b/details/operator-sdk/config/samples/astra_v1_astraconnector.yaml index f46e6dc7..38f43fc5 100644 --- a/details/operator-sdk/config/samples/astra_v1_astraconnector.yaml +++ b/details/operator-sdk/config/samples/astra_v1_astraconnector.yaml @@ -9,6 +9,5 @@ spec: accountId: Astra Account ID from the API Access page in Astra UI skipTLSValidation: true clusterName: Name of your cluster - natsSyncClient: - cloudBridgeURL: https://integration.astra.netapp.io + astraControlURL: https://integration.astra.netapp.io hostAliasIP: 10.193.60.80 diff --git a/details/operator-sdk/controllers/astraconnector_controller.go b/details/operator-sdk/controllers/astraconnector_controller.go index d9b1cb15..a4a5e5d5 100644 --- a/details/operator-sdk/controllers/astraconnector_controller.go +++ b/details/operator-sdk/controllers/astraconnector_controller.go @@ -69,7 +69,7 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque } // Error reading the object - requeue the request. log.Error(err, FailedAstraConnectorGet) - _ = r.updateAstraConnectorStatus(ctx, astraConnector, v1.NatsSyncClientStatus{ + _ = r.updateAstraConnectorStatus(ctx, astraConnector, v1.AstraConnectorStatus{ Status: FailedAstraConnectorGet, Registered: "false", }) @@ -77,11 +77,11 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque return ctrl.Result{}, err } - natsSyncClientStatus := astraConnector.Status.NatsSyncClient - natsSyncClientStatus.AstraClusterId = astraConnector.Status.NatsSyncClient.AstraClusterId + astraConnectorStatus := astraConnector.Status + astraConnectorStatus.AstraClusterId = astraConnector.Status.AstraClusterId - if natsSyncClientStatus.Registered == "" { - natsSyncClientStatus.Registered = "false" + if astraConnectorStatus.Registered == "" { + astraConnectorStatus.Registered = "false" } // Validate AstraConnector CR for any errors @@ -89,8 +89,8 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque if err != nil { // Error validating the connector object. Do not requeue and update the connector status. log.Error(err, FailedAstraConnectorValidation) - natsSyncClientStatus.Status = fmt.Sprintf("%s; %s", FailedAstraConnectorValidation, err.Error()) - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = fmt.Sprintf("%s; %s", FailedAstraConnectorValidation, err.Error()) + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) // Do not requeue. This is a user input error return ctrl.Result{}, err } @@ -106,8 +106,8 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque log.Info("Adding finalizer to AstraConnector instance", "finalizerName", finalizerName) controllerutil.AddFinalizer(astraConnector, finalizerName) if err := r.Update(ctx, astraConnector); err != nil { - natsSyncClientStatus.Status = FailedFinalizerAdd - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = FailedFinalizerAdd + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) return ctrl.Result{}, err } // spec change this will trigger a reconcile @@ -117,8 +117,8 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque // The object is being deleted if controllerutil.ContainsFinalizer(astraConnector, finalizerName) { // Update status message to indicate that CR delete is in progress - natsSyncClientStatus.Status = DeleteInProgress - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = DeleteInProgress + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) // delete any cluster scoped resources created by the operator r.deleteConnectorClusterScopedResources(ctx, astraConnector) @@ -126,15 +126,15 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque // remove our finalizer from the list and update it. controllerutil.RemoveFinalizer(astraConnector, finalizerName) if err := r.Update(ctx, astraConnector); err != nil { - natsSyncClientStatus.Status = FailedFinalizerRemove - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = FailedFinalizerRemove + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) // Do not requeue. Item is being deleted return ctrl.Result{}, err } // Update status message to indicate that CR delete is in finished - natsSyncClientStatus.Status = DeletionComplete - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = DeletionComplete + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) } // Stop reconciliation as the item is being deleted @@ -158,8 +158,8 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque errString = errString + err.Error() } errString = "Pre-check errors: " + errString - natsSyncClientStatus.Status = errString - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = errString + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) // Do not requeue. Item is being deleted return ctrl.Result{}, errors.New(errString) } @@ -168,7 +168,7 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque // deploy Neptune if conf.Config.FeatureFlags().DeployNeptune() { log.Info("Initiating Neptune deployment") - neptuneResult, err := r.deployNeptune(ctx, astraConnector, &natsSyncClientStatus) + neptuneResult, err := r.deployNeptune(ctx, astraConnector, &astraConnectorStatus) if err != nil { // Note: Returning nil in error since we want to wait for the requeue to happen // non nil errors triggers the requeue right away @@ -177,21 +177,21 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque } } - if conf.Config.FeatureFlags().DeployNatsConnector() { + if conf.Config.FeatureFlags().DeployConnector() { log.Info("Initiating Connector deployment") var connectorResults ctrl.Result var deployError error - connectorResults, deployError = r.deployNatlessConnector(ctx, astraConnector, &natsSyncClientStatus) + connectorResults, deployError = r.deployNatlessConnector(ctx, astraConnector, &astraConnectorStatus) // Wait for the cluster to become managed (aka "registered") - natsSyncClientStatus.Status = WaitForClusterManagedState - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = WaitForClusterManagedState + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) isManaged, err := waitForManagedCluster(astraConnector, r.Client, log) if !isManaged { log.Error(err, "timed out waiting for cluster to become managed, requeueing after delay", "delay", conf.Config.ErrorTimeout()) - natsSyncClientStatus.Status = ErrorClusterUnmanaged - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = ErrorClusterUnmanaged + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) // Do not wait 5min, wait 5sec before requeue instead since we have already been waiting in waitForManagedCluster return ctrl.Result{RequeueAfter: time.Second * conf.Config.ErrorTimeout()}, nil } @@ -201,29 +201,29 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque err = r.createASUPCR(ctx, astraConnector, astraConnector.Spec.Astra.ClusterId) if err != nil { log.Error(err, FailedASUPCreation) - natsSyncClientStatus.Status = FailedASUPCreation - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Status = FailedASUPCreation + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) return ctrl.Result{RequeueAfter: time.Minute * conf.Config.ErrorTimeout()}, err } - natsSyncClientStatus.Registered = "true" - natsSyncClientStatus.AstraClusterId = astraConnector.Spec.Astra.ClusterId - natsSyncClientStatus.Status = RegisteredWithAstra - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + astraConnectorStatus.Registered = "true" + astraConnectorStatus.AstraClusterId = astraConnector.Spec.Astra.ClusterId + astraConnectorStatus.Status = RegisteredWithAstra + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) if deployError != nil { // Note: Returning nil in error since we want to wait for the requeue to happen // non nil errors triggers the requeue right away - log.Error(err, "Error deploying NatsConnector, requeueing after delay", "delay", conf.Config.ErrorTimeout()) + log.Error(err, "Error deploying Connector, requeueing after delay", "delay", conf.Config.ErrorTimeout()) return connectorResults, nil } } - if natsSyncClientStatus.AstraClusterId != "" { - log.Info(fmt.Sprintf("Updating CR status, clusterID: '%s'", natsSyncClientStatus.AstraClusterId)) + if astraConnectorStatus.AstraClusterId != "" { + log.Info(fmt.Sprintf("Updating CR status, clusterID: '%s'", astraConnectorStatus.AstraClusterId)) } - _ = r.updateAstraConnectorStatus(ctx, astraConnector, natsSyncClientStatus) + _ = r.updateAstraConnectorStatus(ctx, astraConnector, astraConnectorStatus) err = r.waitForStatusUpdate(astraConnector, log) if err != nil { log.Error(err, "Failed to update status, ignoring since this will be fixed on a future reconcile.") @@ -235,11 +235,11 @@ func (r *AstraConnectorController) Reconcile(ctx context.Context, req ctrl.Reque func (r *AstraConnectorController) updateAstraConnectorStatus( ctx context.Context, astraConnector *v1.AstraConnector, - natsSyncClientStatus v1.NatsSyncClientStatus) error { + newAstraConnectorStatus v1.AstraConnectorStatus) error { // due to conflicts with network or changing object we need to retry on conflict return retry.RetryOnConflict(retry.DefaultRetry, func() error { - astraConnector.Status.NatsSyncClient = natsSyncClientStatus + astraConnector.Status = newAstraConnectorStatus // Update the status err := r.Status().Update(ctx, astraConnector) diff --git a/details/operator-sdk/controllers/deployer.go b/details/operator-sdk/controllers/deployer.go index c0397788..1fa68517 100644 --- a/details/operator-sdk/controllers/deployer.go +++ b/details/operator-sdk/controllers/deployer.go @@ -44,7 +44,7 @@ var resources = []createResourceParams{ {createMessage: CreateDeployment, errorMessage: ErrorCreateDeployments, getResource: model.Deployer.GetDeploymentObjects, clusterScope: false}, } -func (r *AstraConnectorController) deployResources(ctx context.Context, deployer model.Deployer, astraConnector *installer.AstraConnector, natsSyncClientStatus *installer.NatsSyncClientStatus) error { +func (r *AstraConnectorController) deployResources(ctx context.Context, deployer model.Deployer, astraConnector *installer.AstraConnector, astraConnectorStatus *installer.AstraConnectorStatus) error { log := ctrllog.FromContext(ctx) k8sUtil := k8s.NewK8sUtil(r.Client, r.Clientset, log) @@ -62,18 +62,18 @@ func (r *AstraConnectorController) deployResources(ctx context.Context, deployer key := client.ObjectKeyFromObject(kubeObject) statusMsg := fmt.Sprintf(funcList.createMessage, key.Namespace, key.Name) log.Info(statusMsg) - natsSyncClientStatus.Status = statusMsg - _ = r.updateAstraConnectorStatus(ctx, astraConnector, *natsSyncClientStatus) + astraConnectorStatus.Status = statusMsg + _ = r.updateAstraConnectorStatus(ctx, astraConnector, *astraConnectorStatus) result, err := k8sUtil.CreateOrUpdateResource(ctx, kubeObject, astraConnector, mutateFunc) if err != nil { - return r.formatError(ctx, astraConnector, log, funcList.errorMessage, key.Namespace, key.Name, err, natsSyncClientStatus) + return r.formatError(ctx, astraConnector, log, funcList.errorMessage, key.Namespace, key.Name, err, astraConnectorStatus) } else { waitCtx, cancel := context.WithCancel(ctx) defer cancel() err = r.waitForResourceReady(waitCtx, kubeObject, astraConnector) if err != nil { - return r.formatError(ctx, astraConnector, log, funcList.errorMessage, key.Namespace, key.Name, err, natsSyncClientStatus) + return r.formatError(ctx, astraConnector, log, funcList.errorMessage, key.Namespace, key.Name, err, astraConnectorStatus) } log.Info(fmt.Sprintf("Successfully %s resources", result)) } @@ -158,10 +158,10 @@ func (r *AstraConnectorController) waitForResourceReady(ctx context.Context, kub func (r *AstraConnectorController) formatError(ctx context.Context, astraConnector *installer.AstraConnector, log logr.Logger, errorMessage, namespace, name string, err error, - natsSyncClientStatus *installer.NatsSyncClientStatus) error { + astraConnectorStatus *installer.AstraConnectorStatus) error { statusMsg := fmt.Sprintf(errorMessage, namespace, name) - natsSyncClientStatus.Status = statusMsg - _ = r.updateAstraConnectorStatus(ctx, astraConnector, *natsSyncClientStatus) + astraConnectorStatus.Status = statusMsg + _ = r.updateAstraConnectorStatus(ctx, astraConnector, *astraConnectorStatus) log.Error(err, statusMsg) return errors.Wrapf(err, statusMsg) } diff --git a/details/operator-sdk/controllers/natless_connector.go b/details/operator-sdk/controllers/natless_connector.go index 2de8789d..263fe292 100644 --- a/details/operator-sdk/controllers/natless_connector.go +++ b/details/operator-sdk/controllers/natless_connector.go @@ -17,13 +17,13 @@ import ( ) func (r *AstraConnectorController) deployNatlessConnector(ctx context.Context, - astraConnector *v1.AstraConnector, natsSyncClientStatus *v1.NatsSyncClientStatus) (ctrl.Result, error) { + astraConnector *v1.AstraConnector, astraConnectorStatus *v1.AstraConnectorStatus) (ctrl.Result, error) { log := ctrllog.FromContext(ctx) - // let's deploy Astra Connector without Nats + // let's deploy Astra Connector connectorDeployers := getDeployers() for _, deployer := range connectorDeployers { - err := r.deployResources(ctx, deployer, astraConnector, natsSyncClientStatus) + err := r.deployResources(ctx, deployer, astraConnector, astraConnectorStatus) if err != nil { // Failed deploying we want status to reflect that for at least 30 seconds before it's requeued so // anyone watching can be informed diff --git a/details/operator-sdk/controllers/neptune.go b/details/operator-sdk/controllers/neptune.go index d4cb1da8..0b84a975 100644 --- a/details/operator-sdk/controllers/neptune.go +++ b/details/operator-sdk/controllers/neptune.go @@ -12,14 +12,14 @@ import ( ) func (r *AstraConnectorController) deployNeptune(ctx context.Context, - astraConnector *v1.AstraConnector, natsSyncClientStatus *v1.NatsSyncClientStatus) (ctrl.Result, error) { + astraConnector *v1.AstraConnector, astraConnectorStatus *v1.AstraConnectorStatus) (ctrl.Result, error) { // TODO CRD will be installed as part of our crd install // check if they are installed if not error here or maybe a pre-check // Deploy Neptune neptuneDeployer := neptune.NewNeptuneClientDeployerV2() - err := r.deployResources(ctx, neptuneDeployer, astraConnector, natsSyncClientStatus) + err := r.deployResources(ctx, neptuneDeployer, astraConnector, astraConnectorStatus) if err != nil { // Failed deploying we want status to reflect that for at least 30 seconds before it's requeued so // anyone watching can be informed diff --git a/details/operator-sdk/controllers/status_strings.go b/details/operator-sdk/controllers/status_strings.go index e0efede4..7bd7b582 100644 --- a/details/operator-sdk/controllers/status_strings.go +++ b/details/operator-sdk/controllers/status_strings.go @@ -32,11 +32,7 @@ const ( FailedAstraConnectorGet = "Failed to get AstraConnector" FailedAstraConnectorValidation = "Failed to validate AstraConnector" - FailedLocationIDGet = "Failed to get the locationID from ConfigMap" - EmptyLocationIDGet = "Got an empty location ID from ConfigMap" - - FailedUnRegisterNSClient = "Failed to unregister natsSyncClient" - FailedASUPCreation = "Failed to create ASUP CR" + FailedASUPCreation = "Failed to create ASUP CR" DeployedComponents = "Deployed all the connector components" RegisteredWithAstra = "Registered with Astra" diff --git a/scripts/create_default_images_manifest.go b/scripts/create_default_images_manifest.go index 8c7bca18..91a91886 100644 --- a/scripts/create_default_images_manifest.go +++ b/scripts/create_default_images_manifest.go @@ -33,8 +33,6 @@ func main() { // Connector images images := []string{ fmt.Sprintf("%s/astra-connector:%s", defaultImageRegistry, common.ConnectorImageTag), - fmt.Sprintf("%s/%s", defaultImageRegistry, common.NatsSyncClientDefaultImage), - // fmt.Sprintf("%s/%s", defaultImageRegistry, common.NatsDefaultImage), fmt.Sprintf("%s:%s", common.AstraConnectorOperatorRepository, connectorOperatorVersion), fmt.Sprintf("%s/trident-autosupport:%s", defaultImageRegistry, common.AsupImageTag), fmt.Sprintf("%s/%s", defaultImageRegistry, common.RbacProxyImage), diff --git a/unified-installer/astra-unified-installer.sh b/unified-installer/astra-unified-installer.sh index 3ed5cb38..b0343f09 100755 --- a/unified-installer/astra-unified-installer.sh +++ b/unified-installer/astra-unified-installer.sh @@ -2259,10 +2259,18 @@ metadata: spec: astra: accountId: ${account_id} + astraControlURL: ${astra_url} tokenRef: astra-api-token cloudId: ${cloud_id} clusterId: ${cluster_id} skipTLSValidation: ${skip_tls_validation} # Should be set to false in production environments${labels_field_and_content} +EOF + +if [ -n "$host_alias_ip" ]; then + echo " hostAliasIP: $host_alias_ip" >> "$crs_file" +fi + +cat <> "$crs_file" imageRegistry: name: "${connector_registry}" secret: "${connector_regcred_name}" @@ -2277,13 +2285,6 @@ spec: cpu: ".5" memory: ${memory_limit}Gi EOF - { - echo " natsSyncClient:" - echo " cloudBridgeURL: ${astra_url}" - } >> "$crs_file" - if [ -n "$host_alias_ip" ]; then - echo " hostAliasIP: $host_alias_ip" >> "$crs_file" - fi if [ -n "$connector_tag" ]; then echo " astraConnect:" >> "$crs_file" @@ -2700,7 +2701,7 @@ step_monitor_deployment_progress() { add_problem "neptune deploy: failed" "Neptune failed to deploy" elif ! wait_for_deployment_running "astraconnect" "$connector_ns" "5"; then add_problem "astraconnect deploy: failed" "The Astra Connector failed to deploy" - elif ! wait_for_cr_state "astraconnectors/astra-connector" ".status.natsSyncClient.status" "Registered with Astra" "$connector_ns"; then + elif ! wait_for_cr_state "astraconnectors/astra-connector" ".status.status" "Registered with Astra" "$connector_ns"; then add_problem "cluster registration: failed" "Cluster registration failed" fi fi diff --git a/util/go_util_test.go b/util/go_util_test.go index 648b3542..d5733f81 100644 --- a/util/go_util_test.go +++ b/util/go_util_test.go @@ -18,17 +18,15 @@ func createAstraConnector() *v1.AstraConnector { }, Spec: v1.AstraConnectorSpec{ Astra: v1.Astra{ - TokenRef: "test-api-token", - AccountId: "test-account-id", - ClusterName: "test-cluster-name", + TokenRef: "test-api-token", + AccountId: "test-account-id", + ClusterName: "test-cluster-name", + AstraControlURL: "test-url", }, AutoSupport: v1.AutoSupport{ Enrolled: true, URL: "https://my-asup", }, - NatsSyncClient: v1.NatsSyncClient{ - CloudBridgeURL: "test-url", - }, }, } @@ -64,8 +62,8 @@ func TestGetJSONFieldName(t *testing.T) { jsonTag := util.GetJSONFieldName(&ac.Spec, &ac.Spec.Astra) assert.Equal(t, "astra", jsonTag) - jsonTag = util.GetJSONFieldName(&ac.Status, &ac.Status.NatsSyncClient) - assert.Equal(t, "natsSyncClient", jsonTag) + jsonTag = util.GetJSONFieldName(&ac.Status, &ac.Status) + assert.Equal(t, "astraConnectorStatus", jsonTag) }) t.Run("TestGetJSONFieldName__WhenInvalidStructFieldReturnEmptyString", func(t *testing.T) {