func()

in oracle/controllers/instancecontroller/instance_controller_standby.go [295:352]


func (r *InstanceReconciler) verifySettings(ctx context.Context, inst *v1alpha1.Instance) (externalErrMsgs []string, err error) {
	if inst.Spec.DBUniqueName == "" {
		externalErrMsgs = append(externalErrMsgs, "spec.dbUniqueName is required for standby replication, try adding spec.dbUniqueName in the instance Kubernetes manifest.")
		return externalErrMsgs, nil
	}
	if inst.Spec.CDBName == "" {
		externalErrMsgs = append(externalErrMsgs, "spec.cdbName is required for standby replication, try adding spec.cdbName in the instance Kubernetes manifest.")
		return externalErrMsgs, nil
	}
	if inst.Spec.Images == nil || inst.Spec.Images["service"] == "" {
		externalErrMsgs = append(externalErrMsgs, "spec.images.service is required for standby replication, try adding spec.images.service in the instance Kubernetes manifest.")
		return externalErrMsgs, nil
	}
	if inst.Spec.ReplicationSettings == nil {
		externalErrMsgs = append(externalErrMsgs, "spec.replicationSettings is required for standby replication, try adding spec.replicationSettings in the instance Kubernetes manifest.")
		return externalErrMsgs, nil
	}
	if inst.Spec.ReplicationSettings.PrimaryUser.GsmSecretRef == nil {
		externalErrMsgs = append(externalErrMsgs, "spec.replicationSettings.primaryCredential.gsmSecretRef is required for standby replication, "+
			"try creating a secret to store password in Google Secret Manager and add corresponding spec.replicationSettings.primaryCredential.gsmSecretRef in the instance Kubernetes manifest.")
		return externalErrMsgs, nil
	}
	if inst.Spec.ReplicationSettings.PrimaryUser.Name != "sys" {
		externalErrMsgs = append(externalErrMsgs, "spec.replicationSettings.primaryUser.name must be sys for standby replication.")
		return externalErrMsgs, nil
	}

	credentialReq, err := toCredentialReq(inst.Spec.ReplicationSettings.PrimaryUser)
	if err != nil {
		return nil, err
	}

	resp, err := controllers.VerifyStandbySettings(ctx, r, r.DatabaseClientFactory, inst.Namespace, inst.Name, controllers.VerifyStandbySettingsRequest{
		PrimaryHost:         inst.Spec.ReplicationSettings.PrimaryHost,
		PrimaryPort:         inst.Spec.ReplicationSettings.PrimaryPort,
		PrimaryService:      inst.Spec.ReplicationSettings.PrimaryServiceName,
		PrimaryUser:         inst.Spec.ReplicationSettings.PrimaryUser.Name,
		PrimaryCredential:   credentialReq,
		StandbyDbUniqueName: inst.Spec.DBUniqueName,
		StandbyCdbName:      inst.Spec.CDBName,
		BackupGcsPath:       inst.Spec.ReplicationSettings.BackupURI,
		PasswordFileGcsPath: inst.Spec.ReplicationSettings.PasswordFileURI,
		StandbyVersion:      inst.Spec.Version,
	})

	if err != nil {
		return nil, err
	}

	settingErrs := resp.Errors
	if settingErrs != nil && len(settingErrs) > 0 {
		for _, settingErr := range settingErrs {
			externalErrMsgs = append(externalErrMsgs, fmt.Sprintf("%s: %s", settingErr.Type.String(), settingErr.Detail))
		}
	}

	return externalErrMsgs, nil
}