Skip to content

Commit

Permalink
Enable domain update clusters info (#2940)
Browse files Browse the repository at this point in the history
Enable domain update clusters info
  • Loading branch information
yux0 authored Dec 30, 2019
1 parent e057c46 commit 2348e96
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions common/domain/attrValidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (d *AttrValidatorImpl) validateDomainReplicationConfigForGlobalDomain(
return nil
}

func (d *AttrValidatorImpl) validateDomainReplicationConfigClustersDoesNotChange(
func (d *AttrValidatorImpl) validateDomainReplicationConfigClustersDoesNotRemove(
clustersOld []*persistence.ClusterReplicationConfig,
clustersNew []*persistence.ClusterReplicationConfig,
) error {
Expand All @@ -132,13 +132,13 @@ func (d *AttrValidatorImpl) validateDomainReplicationConfigClustersDoesNotChange
clusterNamesNew[clusterConfig.ClusterName] = true
}

if len(clusterNamesNew) != len(clusterNamesOld) {
return errCannotModifyClustersFromDomain
if len(clusterNamesNew) < len(clusterNamesOld) {
return errCannotRemoveClustersFromDomain
}

for clusterName := range clusterNamesOld {
if _, ok := clusterNamesNew[clusterName]; !ok {
return errCannotModifyClustersFromDomain
return errCannotRemoveClustersFromDomain
}
}
return nil
Expand Down
12 changes: 6 additions & 6 deletions common/domain/attrValidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ func (s *attrValidatorSuite) TestValidateDomainReplicationConfigForGlobalDomain(
s.NoError(err)
}

func (s *attrValidatorSuite) TestValidateDomainReplicationConfigClustersDoesNotChange() {
err := s.validator.validateDomainReplicationConfigClustersDoesNotChange(
func (s *attrValidatorSuite) TestValidateDomainReplicationConfigClustersDoesNotRemove() {
err := s.validator.validateDomainReplicationConfigClustersDoesNotRemove(
[]*persistence.ClusterReplicationConfig{
{ClusterName: cluster.TestCurrentClusterName},
{ClusterName: cluster.TestAlternativeClusterName},
Expand All @@ -220,7 +220,7 @@ func (s *attrValidatorSuite) TestValidateDomainReplicationConfigClustersDoesNotC
)
s.NoError(err)

err = s.validator.validateDomainReplicationConfigClustersDoesNotChange(
err = s.validator.validateDomainReplicationConfigClustersDoesNotRemove(
[]*persistence.ClusterReplicationConfig{
{ClusterName: cluster.TestCurrentClusterName},
},
Expand All @@ -229,9 +229,9 @@ func (s *attrValidatorSuite) TestValidateDomainReplicationConfigClustersDoesNotC
{ClusterName: cluster.TestAlternativeClusterName},
},
)
s.IsType(&shared.BadRequestError{}, err)
s.NoError(err)

err = s.validator.validateDomainReplicationConfigClustersDoesNotChange(
err = s.validator.validateDomainReplicationConfigClustersDoesNotRemove(
[]*persistence.ClusterReplicationConfig{
{ClusterName: cluster.TestCurrentClusterName},
{ClusterName: cluster.TestAlternativeClusterName},
Expand All @@ -242,7 +242,7 @@ func (s *attrValidatorSuite) TestValidateDomainReplicationConfigClustersDoesNotC
)
s.IsType(&shared.BadRequestError{}, err)

err = s.validator.validateDomainReplicationConfigClustersDoesNotChange(
err = s.validator.validateDomainReplicationConfigClustersDoesNotRemove(
[]*persistence.ClusterReplicationConfig{
{ClusterName: cluster.TestCurrentClusterName},
},
Expand Down
2 changes: 1 addition & 1 deletion common/domain/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
// err indicating that this cluster is not the master, so cannot do domain registration or update
errNotMasterCluster = &workflow.BadRequestError{Message: "Cluster is not master cluster, cannot do domain registration or domain update."}
errCannotAddClusterToLocalDomain = &workflow.BadRequestError{Message: "Cannot add more replicated cluster to local domain."}
errCannotModifyClustersFromDomain = &workflow.BadRequestError{Message: "Cannot modify existing replicated clusters from a domain."}
errCannotRemoveClustersFromDomain = &workflow.BadRequestError{Message: "Cannot remove existing replicated clusters from a domain."}
errActiveClusterNotInClusters = &workflow.BadRequestError{Message: "Active cluster is not contained in all clusters."}
errCannotDoDomainFailoverAndUpdate = &workflow.BadRequestError{Message: "Cannot set active cluster to current cluster when other parameters are set."}

Expand Down
2 changes: 1 addition & 1 deletion common/domain/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func (d *HandlerImpl) UpdateDomain(
})
}

if err := d.domainAttrValidator.validateDomainReplicationConfigClustersDoesNotChange(
if err := d.domainAttrValidator.validateDomainReplicationConfigClustersDoesNotRemove(
replicationConfig.Clusters,
clustersNew,
); err != nil {
Expand Down

0 comments on commit 2348e96

Please sign in to comment.