mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Do not display scaling buttons if scaling is not possible. (#441)
* Do not display scaling buttons if scaling is not possible.
This commit is contained in:
parent
443e291823
commit
a27e5eff2f
3 changed files with 22 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
# Change Log
|
||||
|
||||
- Disable scaling buttons if scaling is not possible.
|
||||
|
||||
## [0.3.16](https://github.com/arangodb/kube-arangodb/tree/0.3.16) (2019-09-25)
|
||||
- Revised helm charts.
|
||||
- Use separate service account for operator.
|
||||
|
|
|
@ -204,16 +204,32 @@ func (ci *clusterScalingIntegration) updateClusterServerCount(ctx context.Contex
|
|||
if err != nil {
|
||||
return false, maskAny(err)
|
||||
}
|
||||
|
||||
var coordinatorCountPtr *int
|
||||
var dbserverCountPtr *int
|
||||
|
||||
coordinatorCount := spec.Coordinators.GetCount()
|
||||
dbserverCount := spec.DBServers.GetCount()
|
||||
|
||||
if spec.Coordinators.GetMaxCount() == spec.Coordinators.GetMinCount() {
|
||||
coordinatorCountPtr = nil
|
||||
} else {
|
||||
coordinatorCountPtr = &coordinatorCount
|
||||
}
|
||||
|
||||
if spec.DBServers.GetMaxCount() == spec.DBServers.GetMinCount() {
|
||||
dbserverCountPtr = nil
|
||||
} else {
|
||||
dbserverCountPtr = &dbserverCount
|
||||
}
|
||||
|
||||
ci.lastNumberOfServers.mutex.Lock()
|
||||
lastNumberOfServers := ci.lastNumberOfServers.NumberOfServers
|
||||
ci.lastNumberOfServers.mutex.Unlock()
|
||||
|
||||
// This is to prevent unneseccary updates that may override some values written by the WebUI (in the case of a update loop)
|
||||
if coordinatorCount != lastNumberOfServers.GetCoordinators() || dbserverCount != lastNumberOfServers.GetDBServers() {
|
||||
if err := arangod.SetNumberOfServers(ctx, c.Connection(), coordinatorCount, dbserverCount); err != nil {
|
||||
if err := arangod.SetNumberOfServers(ctx, c.Connection(), coordinatorCountPtr, dbserverCountPtr); err != nil {
|
||||
if expectSuccess {
|
||||
log.Debug().Err(err).Msg("Failed to set number of servers")
|
||||
}
|
||||
|
|
|
@ -71,14 +71,14 @@ func GetNumberOfServers(ctx context.Context, conn driver.Connection) (NumberOfSe
|
|||
}
|
||||
|
||||
// SetNumberOfServers updates the number of servers the cluster has.
|
||||
func SetNumberOfServers(ctx context.Context, conn driver.Connection, noCoordinators, noDBServers int) error {
|
||||
func SetNumberOfServers(ctx context.Context, conn driver.Connection, noCoordinators, noDBServers *int) error {
|
||||
req, err := conn.NewRequest("PUT", "_admin/cluster/numberOfServers")
|
||||
if err != nil {
|
||||
return maskAny(err)
|
||||
}
|
||||
input := NumberOfServers{
|
||||
Coordinators: &noCoordinators,
|
||||
DBServers: &noDBServers,
|
||||
Coordinators: noCoordinators,
|
||||
DBServers: noDBServers,
|
||||
}
|
||||
if _, err := req.SetBody(input); err != nil {
|
||||
return maskAny(err)
|
||||
|
|
Loading…
Reference in a new issue