Skip to content

Commit

Permalink
MGMT-5999 Add a flag to enable day2 in kubeapi (#1745)
Browse files Browse the repository at this point in the history
Add a flag to disable by default the automatic creation of Day2 cluster
in KubeApi.

Signed-off-by: Fred Rolland <frolland@redhat.com>
  • Loading branch information
rollandf committed May 26, 2021
1 parent cf99d1f commit 443ebb7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -265,7 +265,7 @@ deploy-service-requirements: | deploy-namespace deploy-inventory-service-file
--ocp-versions '$(subst ",\",$(OPENSHIFT_VERSIONS))' --public-registries "$(PUBLIC_CONTAINER_REGISTRIES)" \
--check-cvo $(CHECK_CLUSTER_VERSION) --apply-manifest $(APPLY_MANIFEST) $(ENABLE_KUBE_API_CMD) $(E2E_TESTS_CONFIG) \
--storage $(STORAGE) --ipv6-support $(IPV6_SUPPORT) --enable-sno-dnsmasq $(ENABLE_SINGLE_NODE_DNSMASQ) \
--hw-requirements '$(subst ",\",$(HW_REQUIREMENTS))'
--hw-requirements '$(subst ",\",$(HW_REQUIREMENTS))' --kubeapi-day2 "$(ENABLE_KUBE_API_DAY2)"
ifeq ($(MIRROR_REGISTRY_SUPPORT), True)
python3 ./tools/deploy_assisted_installer_configmap_registry_ca.py --target "$(TARGET)" \
--namespace "$(NAMESPACE)" --apply-manifest $(APPLY_MANIFEST) --ca-file-path $(MIRROR_REG_CA_FILE) --registries-file-path $(REGISTRIES_FILE_PATH)
Expand Down Expand Up @@ -376,7 +376,7 @@ _run_subsystem_test:
$(MAKE) _test TEST_SCENARIO=subsystem TIMEOUT=120m TEST="$(or $(TEST),./subsystem/...)"

enable-kube-api-for-subsystem: $(BUILD_FOLDER)
$(MAKE) deploy-service-requirements AUTH_TYPE=local ENABLE_KUBE_API=true
$(MAKE) deploy-service-requirements AUTH_TYPE=local ENABLE_KUBE_API=true ENABLE_KUBE_API_DAY2=true
$(call restart_service_pods)
$(MAKE) wait-for-service

Expand Down
22 changes: 12 additions & 10 deletions cmd/main.go
Expand Up @@ -122,6 +122,7 @@ var Options struct {
AssistedServiceISOConfig assistedserviceiso.Config
manifestsGeneratorConfig network.Config
EnableKubeAPI bool `envconfig:"ENABLE_KUBE_API" default:"false"`
EnableKubeAPIDay2Cluster bool `envconfig:"ENABLE_KUBE_API_DAY2" default:"false"`
InfraEnvConfig controllers.InfraEnvConfig
ISOEditorConfig isoeditor.Config
CheckClusterVersion bool `envconfig:"CHECK_CLUSTER_VERSION" default:"false"`
Expand Down Expand Up @@ -457,16 +458,17 @@ func main() {
}).SetupWithManager(ctrlMgr), "unable to create controller InfraEnv")

failOnError((&controllers.ClusterDeploymentsReconciler{
Client: ctrlMgr.GetClient(),
Log: log,
Scheme: ctrlMgr.GetScheme(),
Installer: bm,
ClusterApi: clusterApi,
HostApi: hostApi,
CRDEventsHandler: crdEventsHandler,
Manifests: manifestsApi,
ServiceBaseURL: Options.BMConfig.ServiceBaseURL,
AuthType: Options.Auth.AuthType,
Client: ctrlMgr.GetClient(),
Log: log,
Scheme: ctrlMgr.GetScheme(),
Installer: bm,
ClusterApi: clusterApi,
HostApi: hostApi,
CRDEventsHandler: crdEventsHandler,
Manifests: manifestsApi,
ServiceBaseURL: Options.BMConfig.ServiceBaseURL,
AuthType: Options.Auth.AuthType,
EnableDay2Cluster: Options.EnableKubeAPIDay2Cluster,
}).SetupWithManager(ctrlMgr), "unable to create controller ClusterDeployment")

failOnError((&controllers.AgentReconciler{
Expand Down
21 changes: 11 additions & 10 deletions internal/controller/controllers/clusterdeployments_controller.go
Expand Up @@ -75,15 +75,16 @@ const defaultRequeueAfterOnError = 10 * time.Second
// ClusterDeploymentsReconciler reconciles a Cluster object
type ClusterDeploymentsReconciler struct {
client.Client
Log logrus.FieldLogger
Scheme *runtime.Scheme
Installer bminventory.InstallerInternals
ClusterApi cluster.API
HostApi host.API
CRDEventsHandler CRDEventsHandler
Manifests manifests.ClusterManifestsInternals
ServiceBaseURL string
AuthType auth.AuthType
Log logrus.FieldLogger
Scheme *runtime.Scheme
Installer bminventory.InstallerInternals
ClusterApi cluster.API
HostApi host.API
CRDEventsHandler CRDEventsHandler
Manifests manifests.ClusterManifestsInternals
ServiceBaseURL string
AuthType auth.AuthType
EnableDay2Cluster bool
}

// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;update;create
Expand Down Expand Up @@ -176,7 +177,7 @@ func (r *ClusterDeploymentsReconciler) Reconcile(origCtx context.Context, req ct
if !isInstalled(clusterDeployment, clusterInstall) {
return r.createNewCluster(ctx, log, req.NamespacedName, clusterDeployment, clusterInstall)
}
if !r.isSNO(clusterInstall) {
if !r.isSNO(clusterInstall) && r.EnableDay2Cluster {
return r.createNewDay2Cluster(ctx, log, req.NamespacedName, clusterDeployment, clusterInstall)
}
// cluster is installed and SNO nothing to do.
Expand Down
Expand Up @@ -712,6 +712,7 @@ var _ = Describe("cluster reconcile", func() {
})

It("installed SNO no day2", func() {
cr.EnableDay2Cluster = true
openshiftID := strfmt.UUID(uuid.New().String())
backEndCluster.Status = swag.String(models.ClusterStatusInstalled)
backEndCluster.StatusInfo = swag.String("Done")
Expand Down Expand Up @@ -789,6 +790,7 @@ var _ = Describe("cluster reconcile", func() {
})

It("Fail to create day2", func() {
cr.EnableDay2Cluster = true
openshiftID := strfmt.UUID(uuid.New().String())
backEndCluster.Status = swag.String(models.ClusterStatusInstalled)
backEndCluster.OpenshiftClusterID = openshiftID
Expand Down Expand Up @@ -820,6 +822,7 @@ var _ = Describe("cluster reconcile", func() {
})

It("Create day2 if day1 is already deleted none SNO", func() {
cr.EnableDay2Cluster = true
mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(nil, gorm.ErrRecordNotFound)
id := strfmt.UUID(uuid.New().String())
clusterReply := &common.Cluster{
Expand Down Expand Up @@ -963,6 +966,7 @@ var _ = Describe("cluster reconcile", func() {
})

It("install day2 host", func() {
cr.EnableDay2Cluster = true
openshiftID := strfmt.UUID(uuid.New().String())
backEndCluster.Status = swag.String(models.ClusterStatusInstalled)
backEndCluster.OpenshiftClusterID = openshiftID
Expand Down Expand Up @@ -992,6 +996,7 @@ var _ = Describe("cluster reconcile", func() {
})

It("install failure day2 host", func() {
cr.EnableDay2Cluster = true
openshiftID := strfmt.UUID(uuid.New().String())
backEndCluster.Status = swag.String(models.ClusterStatusInstalled)
backEndCluster.OpenshiftClusterID = openshiftID
Expand Down
4 changes: 4 additions & 0 deletions tools/deploy_assisted_installer_configmap.py
Expand Up @@ -26,6 +26,7 @@ def handle_arguments():
parser.add_argument("--ipv6-support", default="True")
parser.add_argument("--enable-sno-dnsmasq", default="True")
parser.add_argument("--hw-requirements")
parser.add_argument("--kubeapi-day2", default="False")

return deployment_options.load_deployment_options(parser)

Expand Down Expand Up @@ -114,6 +115,9 @@ def main():
if deploy_options.enable_kube_api:
y['data']['ENABLE_KUBE_API'] = 'true'

if deploy_options.kubeapi_day2:
y['data']['ENABLE_KUBE_API_DAY2'] = 'true'

data = yaml.dump(y)
dst.write(data)

Expand Down

0 comments on commit 443ebb7

Please sign in to comment.