- Currently, fission components don't handle shutdown signals. So we don't get any to do the required cleanup before the fission process exits. Adding signal capture process with cancelling context so that all dependent processes stop working when the process gets term signal. - Set log level to error in otel shutdown function Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
74 lines
2.3 KiB
Go
74 lines
2.3 KiB
Go
/*
|
|
Copyright 2016 The Fission Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/docopt/docopt-go"
|
|
"go.uber.org/zap"
|
|
|
|
"github.com/fission/fission/pkg/info"
|
|
"github.com/fission/fission/pkg/utils/loggerfactory"
|
|
"github.com/fission/fission/pkg/utils/signals"
|
|
)
|
|
|
|
func getStringArgWithDefault(arg interface{}, defaultValue string) string {
|
|
if arg != nil {
|
|
return arg.(string)
|
|
} else {
|
|
return defaultValue
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
logger := loggerfactory.GetLogger()
|
|
defer logger.Sync()
|
|
|
|
usage := `Package to perform operations needed prior to fission installation
|
|
Usage:
|
|
pre-upgrade-checks --fn-pod-namespace=<podNamespace> --envbuilder-namespace=<envBuilderNamespace>
|
|
Options:
|
|
--fn-pod-namespace=<podNamespace> Namespace where function pods get deployed.
|
|
--envbuilder-namespace=<envBuilderNamespace> Namespace where builder env pods are deployed.`
|
|
|
|
arguments, err := docopt.ParseArgs(usage, nil, info.BuildInfo().String())
|
|
if err != nil {
|
|
logger.Fatal("Could not parse command line arguments", zap.Error(err))
|
|
}
|
|
|
|
functionPodNs := getStringArgWithDefault(arguments["--fn-pod-namespace"], "fission-function")
|
|
envBuilderNs := getStringArgWithDefault(arguments["--envbuilder-namespace"], "fission-builder")
|
|
|
|
crdBackedClient, err := makePreUpgradeTaskClient(logger, functionPodNs, envBuilderNs)
|
|
if err != nil {
|
|
logger.Fatal("error creating a crd client, please retry helm upgrade",
|
|
zap.Error(err))
|
|
}
|
|
|
|
ctx := signals.SetupSignalHandlerWithContext(logger)
|
|
crd := crdBackedClient.GetFunctionCRD(ctx)
|
|
if crd == nil {
|
|
logger.Info("nothing to do since CRDs are not present on the cluster")
|
|
return
|
|
}
|
|
|
|
err = crdBackedClient.LatestSchemaApplied(ctx)
|
|
if err != nil {
|
|
logger.Fatal("New CRDs are not applied")
|
|
}
|
|
crdBackedClient.VerifyFunctionSpecReferences(ctx)
|
|
}
|