aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/plugin
diff options
context:
space:
mode:
authorhthieu <huu_trung.thieu@nokia-bell-labs.com>2021-07-01 20:03:09 +0200
committerhthieu <huu_trung.thieu@nokia-bell-labs.com>2021-08-11 15:02:27 +0200
commit57d1305db9f032c94949b719f0dc052ac7cd2d41 (patch)
tree1249fbd139622900c4f0d04bfacf52836e471d31 /src/k8splugin/internal/plugin
parent6875d67ee2ad879170774304dd35d9a14dd9f50c (diff)
Support pre/post install/delete hooks  
Update instance create and delete handler to support pre/post install/delete hooks.  Add hook.go: to execute and delete hook (base on delete policy).  Implement watchUntilReady in generic plugin to wait for readiness of hook rss. Add hook_sorter.go: to sort hook based on weight. User can define timeout for each type of hooks in overwrite-values. Variable name is k8s-rb-instance-pre-install-timeout (default 60s), k8s-rb-instance-post-install-timeout (default 600s), k8s-rb-instance-pre-delete-timeout (default 60s) and k8s-rb-instance-post-delete-timeout (600s). This is timeout for each hook of a hook event (not a total time). Add recovery capability to continue the execution of instantiation (create or delete) when the plugin stop unexpectedly. For now, this is disabled because we have data-race issue during test. Will enable when we find the solution. Add basic test for hooks (in hook_test.go) Add test for hook in instance_test For instance get request, we can request for full data by adding query param to the request: full=true. Issue-ID: MULTICLOUD-1347 Signed-off-by: hthieu <huu_trung.thieu@nokia-bell-labs.com> Change-Id: If2b4a90831b9bfce1af8b926e4062a7d706bee08
Diffstat (limited to 'src/k8splugin/internal/plugin')
-rw-r--r--src/k8splugin/internal/plugin/helpers.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/k8splugin/internal/plugin/helpers.go b/src/k8splugin/internal/plugin/helpers.go
index 98a2f5c8..29213076 100644
--- a/src/k8splugin/internal/plugin/helpers.go
+++ b/src/k8splugin/internal/plugin/helpers.go
@@ -1,5 +1,6 @@
/*
* Copyright 2019 Intel Corporation, Inc
+ * Copyright © 2021 Nokia Bell Labs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,12 +18,14 @@
package plugin
import (
- "github.com/onap/multicloud-k8s/src/k8splugin/internal/utils"
+ "k8s.io/client-go/rest"
"log"
"strings"
+ "time"
"github.com/onap/multicloud-k8s/src/k8splugin/internal/config"
"github.com/onap/multicloud-k8s/src/k8splugin/internal/helm"
+ "github.com/onap/multicloud-k8s/src/k8splugin/internal/utils"
pkgerrors "github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
@@ -71,6 +74,16 @@ type Reference interface {
//Update kubernetes resource based on the groupVersionKind and resourceName provided in resource
Update(yamlFilePath string, namespace string, client KubernetesConnector) (string, error)
+
+
+ //WatchUntilReady a kubernetes resource until it's ready
+ WatchUntilReady(timeout time.Duration,
+ ns string,
+ res helm.KubernetesResource,
+ mapper meta.RESTMapper,
+ restClient rest.Interface,
+ objType runtime.Object,
+ clientSet kubernetes.Interface) error
}
// GetPluginByKind returns a plugin by the kind name