Skip to content

Commit

Permalink
Create default ExecutionCluster CR for control cluster (#980)
Browse files Browse the repository at this point in the history
* fix: default cluster when empty in execution context

* fix: create default ExecutionCluster for control cluster in engine
  • Loading branch information
cd1989 authored and caicloud-bot committed May 12, 2019
1 parent 982fd2e commit 1d983cb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/workflow/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ func main() {
log.WithField("configmap", *cm).Fatal("Load config from ConfigMap error: ", err)
}

// Init logging system.
// Init logging and control cluster
controller.InitLogger(&controller.Config.Logging)
if err = controller.InitControlCluster(client); err != nil {
log.Fatal("Init control cluster error: ", err)
}

// create CRD
v1alpha1.EnsureCRDCreated("", *kubeConfigPath)
Expand Down
26 changes: 26 additions & 0 deletions pkg/workflow/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import (
"strings"

log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/api/errors"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/caicloud/cyclone/pkg/apis/cyclone/v1alpha1"
"github.com/caicloud/cyclone/pkg/common"
"github.com/caicloud/cyclone/pkg/k8s/clientset"
)

// InitLogger inits logging
Expand All @@ -31,3 +37,23 @@ func InitLogger(logging *LoggingConfig) {
})
log.SetOutput(os.Stdout)
}

// InitControlCluster initializes control cluster for workflow to run.
func InitControlCluster(client clientset.Interface) error {
// Create ExecutionCluster instance for control cluster. This makes it possible to
// use only workflow engine to run workflow in control cluster.
// Create ExecutionCluster resource for Workflow Engine to use
_, err := client.CycloneV1alpha1().ExecutionClusters().Create(&v1alpha1.ExecutionCluster{
ObjectMeta: meta_v1.ObjectMeta{
Name: common.ControlClusterName,
},
})

// If the CR already exists, just ignore it.
if err != nil && errors.IsAlreadyExists(err) {
log.Infof("ExecutionCluster resource '%s' already exist", common.ControlClusterName)
return nil
}

return err
}

0 comments on commit 1d983cb

Please sign in to comment.