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

Test if sharding is disabled in project before cluster creation #745

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Remove double negation :-)
  • Loading branch information
jknipper committed Jan 19, 2023
commit bf210d150bd1dd484547481b90b184339b07f141
14 changes: 7 additions & 7 deletions pkg/controller/ground.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ func (op *GroundControl) handler(key string) error {
return nil
}

if disabled, err := op.isShardingDisabledInProject(kluster); err != nil || !disabled {
if enabled, err := op.isShardingEnabledInProject(kluster); err != nil || enabled {
if err != nil {
op.Recorder.Eventf(kluster, api_v1.EventTypeWarning, FailedCreate, "Cluster creation failed. Could not examine project tags: %s", err)
return err
}
msg := "Cluster creation failed. VCenter sharding must be disabled for project."
op.Recorder.Eventf(kluster, api_v1.EventTypeWarning, FailedCreate, msg)
return fmt.Errorf("Cluster creation failed. VCenter sharding must be disabled for project.")
return fmt.Errorf(msg)
}

op.Logger.Log(
Expand Down Expand Up @@ -910,25 +910,25 @@ func (op *GroundControl) requiresKubernikusInfo(kluster *v1.Kluster) bool {
return kluster.Status.Apiserver == "" || kluster.Status.Wormhole == "" || kluster.Spec.Version == "" || (swag.BoolValue(kluster.Spec.Dashboard) && kluster.Status.Dashboard == "")
}

func (op *GroundControl) isShardingDisabledInProject(kluster *v1.Kluster) (bool, error) {
func (op *GroundControl) isShardingEnabledInProject(kluster *v1.Kluster) (bool, error) {
client, err := op.Factories.Openstack.ProjectAdminClientFor(kluster.Account())
if err != nil {
return false, err
return true, err
}

tags, err := client.GetProjectTags()
if err != nil {
return false, err
return true, err
}

for _, tag := range tags {
if tag == ShardingEnabledProjectTag {
return false, nil
return true, nil
}

}

return true, nil
return false, nil
}

func (op *GroundControl) discoverKubernikusInfo(kluster *v1.Kluster) error {
Expand Down