From 62f729727ae891941c8c6350c3cb1a91eeeee6d9 Mon Sep 17 00:00:00 2001 From: Sanket Sudake Date: Fri, 24 Nov 2023 19:01:31 +0530 Subject: [PATCH] Change container base image to cgr.dev/chainguard/static (#2881) * Change container base image to cgr.dev/chainguard/static * Lint fixes * fix test failure * Add router deployment wait * add check command in upgrade script --------- Signed-off-by: Sanket Sudake --- cmd/builder/Dockerfile | 3 +-- cmd/fetcher/Dockerfile | 3 +-- cmd/fission-bundle/Dockerfile | 3 +-- cmd/preupgradechecks/Dockerfile | 3 +-- cmd/reporter/Dockerfile | 5 ++--- pkg/apis/core/v1/validation.go | 2 +- pkg/buildermgr/envwatcher.go | 2 +- pkg/buildermgr/pkgwatcher.go | 2 +- pkg/executor/executortype/container/containermgr.go | 2 +- pkg/executor/executortype/poolmgr/gp_deployment.go | 2 +- pkg/executor/fscache/functionServiceCache.go | 2 +- pkg/executor/fscache/functionServiceCache_test.go | 2 +- pkg/executor/reaper/reaper.go | 2 +- pkg/executor/util/merge.go | 4 ++-- pkg/fetcher/fetcher.go | 2 +- pkg/fission-cli/cliwrapper/cli/cli.go | 2 +- pkg/fission-cli/cmd/function/log.go | 4 ++-- pkg/fission-cli/cmd/spec/apply.go | 4 ++-- pkg/fission-cli/logdb/influxdb.go | 10 +++++----- pkg/storagesvc/stowClient.go | 2 +- test/e2e/framework/services/services.go | 2 +- test/tests/test_archive_cli.sh | 2 -- test/upgrade_test/fission_objects.sh | 6 ++++-- 23 files changed, 33 insertions(+), 38 deletions(-) diff --git a/cmd/builder/Dockerfile b/cmd/builder/Dockerfile index 1c4646ec..130886d3 100644 --- a/cmd/builder/Dockerfile +++ b/cmd/builder/Dockerfile @@ -1,4 +1,3 @@ -FROM alpine:3.18 -RUN apk add --update ca-certificates +FROM cgr.dev/chainguard/static:latest COPY builder /builder ENTRYPOINT ["/builder"] diff --git a/cmd/fetcher/Dockerfile b/cmd/fetcher/Dockerfile index 08fff08e..3282693d 100644 --- a/cmd/fetcher/Dockerfile +++ b/cmd/fetcher/Dockerfile @@ -1,4 +1,3 @@ -FROM alpine:3.18 -RUN apk add --update ca-certificates +FROM cgr.dev/chainguard/static:latest COPY fetcher / ENTRYPOINT ["/fetcher"] diff --git a/cmd/fission-bundle/Dockerfile b/cmd/fission-bundle/Dockerfile index 05bb526d..82ffbc40 100644 --- a/cmd/fission-bundle/Dockerfile +++ b/cmd/fission-bundle/Dockerfile @@ -1,4 +1,3 @@ -FROM alpine:3.18 -RUN apk add --update ca-certificates +FROM cgr.dev/chainguard/static:latest COPY fission-bundle / ENTRYPOINT ["/fission-bundle"] diff --git a/cmd/preupgradechecks/Dockerfile b/cmd/preupgradechecks/Dockerfile index cb3cbd75..bef71ae4 100644 --- a/cmd/preupgradechecks/Dockerfile +++ b/cmd/preupgradechecks/Dockerfile @@ -1,4 +1,3 @@ -FROM alpine:3.18 -RUN apk add --update ca-certificates +FROM cgr.dev/chainguard/static:latest COPY pre-upgrade-checks / ENTRYPOINT ["/pre-upgrade-checks"] diff --git a/cmd/reporter/Dockerfile b/cmd/reporter/Dockerfile index 0909a8e8..87816208 100644 --- a/cmd/reporter/Dockerfile +++ b/cmd/reporter/Dockerfile @@ -1,4 +1,3 @@ -FROM alpine:3.18 -RUN apk add --update ca-certificates +FROM cgr.dev/chainguard/static:latest COPY reporter / -ENTRYPOINT ["/reporter"] \ No newline at end of file +ENTRYPOINT ["/reporter"] diff --git a/pkg/apis/core/v1/validation.go b/pkg/apis/core/v1/validation.go index d43a17c2..5aea08d6 100644 --- a/pkg/apis/core/v1/validation.go +++ b/pkg/apis/core/v1/validation.go @@ -337,7 +337,7 @@ func (es ExecutionStrategy) Validate() error { } // TODO Add validation warning - //if es.SpecializationTimeout < 120 { + // if es.SpecializationTimeout < 120 { // result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.SpecializationTimeout", es.SpecializationTimeout, "SpecializationTimeout must be a value equal to or greater than 120")) //} } diff --git a/pkg/buildermgr/envwatcher.go b/pkg/buildermgr/envwatcher.go index fa1dd9d3..89dcf1f0 100644 --- a/pkg/buildermgr/envwatcher.go +++ b/pkg/buildermgr/envwatcher.go @@ -163,7 +163,7 @@ func (envw *environmentWatcher) EnvWatchEventHandlers(ctx context.Context) error } func (envw *environmentWatcher) AddUpdateBuilder(ctx context.Context, env *fv1.Environment) { - //builder is not supported with v1 interface and ignore env without builder image + // builder is not supported with v1 interface and ignore env without builder image if env.Spec.Version != 1 && len(env.Spec.Builder.Image) != 0 { if _, ok := envw.cache[crd.CacheKeyUIDFromMeta(&env.ObjectMeta)]; !ok { builderInfo, err := envw.createBuilder(ctx, env, envw.nsResolver.GetBuilderNS(env.ObjectMeta.Namespace)) diff --git a/pkg/buildermgr/pkgwatcher.go b/pkg/buildermgr/pkgwatcher.go index 3d458983..4245aa8e 100644 --- a/pkg/buildermgr/pkgwatcher.go +++ b/pkg/buildermgr/pkgwatcher.go @@ -127,7 +127,7 @@ func (pkgw *packageWatcher) build(ctx context.Context, srcpkg *fv1.Package) { healthCheckBackOff := utils.NewDefaultBackOff() builderNs := pkgw.nsResolver.GetBuilderNS(env.ObjectMeta.Namespace) - //if err != nil { + // if err != nil { // pkgw.logger.Error("Unable to create BackOff for Health Check", zap.Error(err)) //} // Do health check for environment builder pod diff --git a/pkg/executor/executortype/container/containermgr.go b/pkg/executor/executortype/container/containermgr.go index 316fa315..391c0b1b 100644 --- a/pkg/executor/executortype/container/containermgr.go +++ b/pkg/executor/executortype/container/containermgr.go @@ -430,7 +430,7 @@ func (caaf *Container) fnCreate(ctx context.Context, fn *fv1.Function) (*fscache kubeObjRefs := []apiv1.ObjectReference{ { - //obj.TypeMeta.Kind does not work hence this, needs investigation and a fix + // obj.TypeMeta.Kind does not work hence this, needs investigation and a fix Kind: "deployment", Name: depl.ObjectMeta.Name, APIVersion: depl.TypeMeta.APIVersion, diff --git a/pkg/executor/executortype/poolmgr/gp_deployment.go b/pkg/executor/executortype/poolmgr/gp_deployment.go index 56e18060..4d2f4155 100644 --- a/pkg/executor/executortype/poolmgr/gp_deployment.go +++ b/pkg/executor/executortype/poolmgr/gp_deployment.go @@ -43,7 +43,7 @@ func getPoolName(env *fv1.Environment) string { return a } - //To fit the 63 character limit + // To fit the 63 character limit if len(env.ObjectMeta.Name)+len(env.ObjectMeta.Namespace) < 37 { envPodName = env.ObjectMeta.Name + "-" + env.ObjectMeta.Namespace } else { diff --git a/pkg/executor/fscache/functionServiceCache.go b/pkg/executor/fscache/functionServiceCache.go index 123c8736..78a852f9 100644 --- a/pkg/executor/fscache/functionServiceCache.go +++ b/pkg/executor/fscache/functionServiceCache.go @@ -40,7 +40,7 @@ import ( type fscRequestType int -//type executorType int +// type executorType int // FunctionServiceCache Request Types const ( diff --git a/pkg/executor/fscache/functionServiceCache_test.go b/pkg/executor/fscache/functionServiceCache_test.go index 4128f00f..24a6fd2e 100644 --- a/pkg/executor/fscache/functionServiceCache_test.go +++ b/pkg/executor/fscache/functionServiceCache_test.go @@ -165,7 +165,7 @@ func TestFunctionServiceNewCache(t *testing.T) { _, err = fsc.GetFuncSvc(ctx, fsvc.Function, 5, concurrency) require.NoError(t, err) - //key := fmt.Sprintf("%v_%v", cancel.UID, fn.ObjectMeta.ResourceVersion) + // key := fmt.Sprintf("%v_%v", cancel.UID, fn.ObjectMeta.ResourceVersion) key := crd.CacheKeyURGFromMeta(&fn.ObjectMeta) fsc.MarkAvailable(key, fsvc.Address) diff --git a/pkg/executor/reaper/reaper.go b/pkg/executor/reaper/reaper.go index 66d4c139..7db392be 100644 --- a/pkg/executor/reaper/reaper.go +++ b/pkg/executor/reaper/reaper.go @@ -218,7 +218,7 @@ func CleanupHpa(ctx context.Context, logger *zap.Logger, client kubernetes.Inter func GetReaperNamespace() map[string]string { ns := utils.DefaultNSResolver() - //to support backward compatibility we need to cleanup deployment and rolebinding created in function, buidler and default namespace as well + // to support backward compatibility we need to cleanup deployment and rolebinding created in function, buidler and default namespace as well fissionResourceNs := ns.FissionNSWithOptions(utils.WithBuilderNs(), utils.WithFunctionNs(), utils.WithDefaultNs()) return fissionResourceNs } diff --git a/pkg/executor/util/merge.go b/pkg/executor/util/merge.go index 60be5076..31c1e1f0 100644 --- a/pkg/executor/util/merge.go +++ b/pkg/executor/util/merge.go @@ -112,12 +112,12 @@ func MergePodSpec(srcPodSpec *apiv1.PodSpec, targetPodSpec *apiv1.PodSpec) (*api srcPodSpec.EnableServiceLinks = targetPodSpec.EnableServiceLinks } - //TODO - Security context should be merged instead of overriding. + // TODO - Security context should be merged instead of overriding. if targetPodSpec.SecurityContext != nil { srcPodSpec.SecurityContext = targetPodSpec.SecurityContext } - //TODO - Affinity should be merged instead of overriding. + // TODO - Affinity should be merged instead of overriding. if targetPodSpec.Affinity != nil { srcPodSpec.Affinity = targetPodSpec.Affinity } diff --git a/pkg/fetcher/fetcher.go b/pkg/fetcher/fetcher.go index 9a57014d..7c1eca95 100644 --- a/pkg/fetcher/fetcher.go +++ b/pkg/fetcher/fetcher.go @@ -348,7 +348,7 @@ func (fetcher *Fetcher) Fetch(ctx context.Context, pkg *fv1.Package, req Functio } } - //checking if file is a zip + // checking if file is a zip if match, _ := utils.IsZip(tmpPath); match && !req.KeepArchive { // unarchive tmp file to a tmp unarchive path tmpUnarchivePath := filepath.Join(fetcher.sharedVolumePath, uuid.NewString()) diff --git a/pkg/fission-cli/cliwrapper/cli/cli.go b/pkg/fission-cli/cliwrapper/cli/cli.go index 04e5e222..04a7727d 100644 --- a/pkg/fission-cli/cliwrapper/cli/cli.go +++ b/pkg/fission-cli/cliwrapper/cli/cli.go @@ -26,7 +26,7 @@ type ( Input interface { Context() context.Context - //Parse(input interface{}) error + // Parse(input interface{}) error // IsSet checks whether a flag has been set by the user IsSet(key string) bool diff --git a/pkg/fission-cli/cmd/function/log.go b/pkg/fission-cli/cmd/function/log.go index 1b147ba1..e6cd726a 100644 --- a/pkg/fission-cli/cmd/function/log.go +++ b/pkg/fission-cli/cmd/function/log.go @@ -103,7 +103,7 @@ func (opts *LogSubCommand) do(input cli.Input) error { t = time.Now().UTC() // next time fetch values from this time if err != nil { console.Verbose(2, "error querying logs: %s", err) - if dbType == logdb.KUBERNETES { //in case of Kubernetes log we print pod namespace warning once + if dbType == logdb.KUBERNETES { // in case of Kubernetes log we print pod namespace warning once warn = false } responseChan <- struct{}{} @@ -116,7 +116,7 @@ func (opts *LogSubCommand) do(input cli.Input) error { continue } - if dbType == logdb.KUBERNETES { //in case of Kubernetes log we print pods info only once. And then print new logs + if dbType == logdb.KUBERNETES { // in case of Kubernetes log we print pods info only once. And then print new logs detail = false } responseChan <- struct{}{} diff --git a/pkg/fission-cli/cmd/spec/apply.go b/pkg/fission-cli/cmd/spec/apply.go index 377e80cf..77fd78e5 100644 --- a/pkg/fission-cli/cmd/spec/apply.go +++ b/pkg/fission-cli/cmd/spec/apply.go @@ -517,7 +517,7 @@ func localArchiveFromSpec(specDir string, aus *spectypes.ArchiveUploadSpec) (*fv // to do a filepath.Walk and call path.Match on each path... files := make([]string, 0) - //checking if file is a zip + // checking if file is a zip if match, _ := utils.IsZip(aus.IncludeGlobs[0]); match && len(aus.IncludeGlobs) == 1 { files = append(files, aus.IncludeGlobs[0]) } else { @@ -560,7 +560,7 @@ func localArchiveFromSpec(specDir string, aus *spectypes.ArchiveUploadSpec) (*fv } archiveFileName = archiveFile.Name() - //This instance is required to allow overwriting and not changing DefaultZip + // This instance is required to allow overwriting and not changing DefaultZip zipOverwrite := archiver.Zip{OverwriteExisting: true} err = zipOverwrite.Archive(files, archiveFileName) if err != nil { diff --git a/pkg/fission-cli/logdb/influxdb.go b/pkg/fission-cli/logdb/influxdb.go index 7d1146be..362cb1a2 100644 --- a/pkg/fission-cli/logdb/influxdb.go +++ b/pkg/fission-cli/logdb/influxdb.go @@ -79,7 +79,7 @@ func (influx InfluxDB) GetLogs(ctx context.Context, filter LogFilter, output *by parameters := make(map[string]interface{}) parameters["funcuid"] = filter.FuncUid parameters["time"] = timestamp - //the parameters above are only for the where clause and do not work with LIMIT + // the parameters above are only for the where clause and do not work with LIMIT orderCondition := " order by \"time\" asc" if filter.Reverse { @@ -104,7 +104,7 @@ func (influx InfluxDB) GetLogs(ctx context.Context, filter LogFilter, output *by for _, r := range response.Results { for _, series := range r.Series { - //create map of columns to row indices + // create map of columns to row indices indexMap := makeIndexMap(series.Columns) // TODO: Remove fallback indexes. Some of index's name changed in fluent-bit, here we add extra fallbackIndexes to address compatibility problem. @@ -130,16 +130,16 @@ func (influx InfluxDB) GetLogs(ctx context.Context, filter LogFilter, output *by return err } entry := LogEntry{ - //The attributes of the LogEntry are selected as relative to their position in InfluxDB's line protocol response + // The attributes of the LogEntry are selected as relative to their position in InfluxDB's line protocol response Timestamp: t, Container: getEntryValue(row, container, container_1), FuncName: getEntryValue(row, functionName, -1), FuncUid: getEntryValue(row, funcuid, funcuid_1, funcuid_2), - Message: strings.TrimSuffix(getEntryValue(row, logMessage, -1), "\n"), //log field + Message: strings.TrimSuffix(getEntryValue(row, logMessage, -1), "\n"), // log field Namespace: getEntryValue(row, nameSpace, -1), Pod: getEntryValue(row, podName, -1), Stream: getEntryValue(row, stream, -1), - Sequence: seqNum, //sequence tag + Sequence: seqNum, // sequence tag } logEntries = append(logEntries, entry) } diff --git a/pkg/storagesvc/stowClient.go b/pkg/storagesvc/stowClient.go index aa395573..ca3a396f 100644 --- a/pkg/storagesvc/stowClient.go +++ b/pkg/storagesvc/stowClient.go @@ -37,7 +37,7 @@ type ( storage Storage } - //StowClient is the wrapper client for stow (Cloud storage abstraction package) + // StowClient is the wrapper client for stow (Cloud storage abstraction package) StowClient struct { logger *zap.Logger config *storageConfig diff --git a/test/e2e/framework/services/services.go b/test/e2e/framework/services/services.go index 4c4f6530..f201169b 100644 --- a/test/e2e/framework/services/services.go +++ b/test/e2e/framework/services/services.go @@ -112,7 +112,7 @@ func StartServices(ctx context.Context, f *framework.Framework, mgr manager.Inte os.Setenv("ROUTER_UNTAP_SERVICE_TIMEOUT", "3600s") os.Setenv("USE_ENCODED_PATH", "false") os.Setenv("DISPLAY_ACCESS_LOG", "true") - //os.Setenv("DEBUG_ENV", "false") + // os.Setenv("DEBUG_ENV", "false") routerPort, err := utils.FindFreePort() if err != nil { return fmt.Errorf("error finding unused port: %v", err) diff --git a/test/tests/test_archive_cli.sh b/test/tests/test_archive_cli.sh index caea7314..a343cc3e 100755 --- a/test/tests/test_archive_cli.sh +++ b/test/tests/test_archive_cli.sh @@ -37,8 +37,6 @@ create_archive uploadResp=$(fission ar upload --name "$tmp_dir"/test-deploy-pkg.zip) filename=$(echo "$uploadResp" | cut -d':' -f2 | tr -d ' ') -kubectl exec -i "$podname" -n fission -- /bin/sh -c "ls $filename" - # Test for list listResp=$(fission ar list) diff --git a/test/upgrade_test/fission_objects.sh b/test/upgrade_test/fission_objects.sh index 3c929de6..10b5de57 100644 --- a/test/upgrade_test/fission_objects.sh +++ b/test/upgrade_test/fission_objects.sh @@ -63,8 +63,9 @@ create_fission_objects() { } test_fission_objects() { - fission env list - fission function list + doit fission env list + doit fission function list + doit fission check -v 2 echo "-----------------###############################--------------------" echo " Running fission object tests" echo "-----------------###############################--------------------" @@ -111,6 +112,7 @@ install_current_release() { doit helm dependency update "$ROOT"/charts/fission-all doit make update-crds doit helm upgrade --debug --wait --namespace $ns --set $HELM_VARS_LATEST_RELEASE fission "$ROOT"/charts/fission-all + doit kubectl rollout status deployment/router -n $ns --watch --timeout 2m } "$@"