Skip to content

Commit

Permalink
Test helm update to 3.2 (#1731)
Browse files Browse the repository at this point in the history
* Test helm update to 3.2

* Update generated app repository client and API

* Update calls using kube client to pass context (still remaining test fail).

* Fix test for helm 3.2.1
  • Loading branch information
absoludity committed May 20, 2020
1 parent bb0cb76 commit 65fc66e
Show file tree
Hide file tree
Showing 33 changed files with 401 additions and 173 deletions.
1 change: 1 addition & 0 deletions .gitmodules
@@ -1,3 +1,4 @@
[submodule "code-generator"]
path = cmd/apprepository-controller/vendor/k8s.io/code-generator
url = https://github.com/kubernetes/code-generator
branch = release-1.18
11 changes: 6 additions & 5 deletions cmd/apprepository-controller/controller.go
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"context"
"fmt"
"time"

Expand Down Expand Up @@ -270,7 +271,7 @@ func (c *Controller) syncHandler(key string) error {
if errors.IsNotFound(err) {
log.Infof("AppRepository '%s' no longer exists so performing cleanup of charts from the DB", key)
// Trigger a Job to perfrom the cleanup of the charts in the DB corresponding to deleted AppRepository
_, err = c.kubeclientset.BatchV1().Jobs(namespace).Create(newCleanupJob(name, namespace, c.kubeappsNamespace))
_, err = c.kubeclientset.BatchV1().Jobs(namespace).Create(context.TODO(), newCleanupJob(name, namespace, c.kubeappsNamespace), metav1.CreateOptions{})
return nil
}
return fmt.Errorf("Error fetching object with key %s from store: %v", key, err)
Expand All @@ -282,23 +283,23 @@ func (c *Controller) syncHandler(key string) error {
// If the resource doesn't exist, we'll create it
if errors.IsNotFound(err) {
log.Infof("Creating CronJob %q for AppRepository %q", cronjobName, apprepo.GetName())
cronjob, err = c.kubeclientset.BatchV1beta1().CronJobs(c.kubeappsNamespace).Create(newCronJob(apprepo, c.kubeappsNamespace))
cronjob, err = c.kubeclientset.BatchV1beta1().CronJobs(c.kubeappsNamespace).Create(context.TODO(), newCronJob(apprepo, c.kubeappsNamespace), metav1.CreateOptions{})
if err != nil {
return err
}

// Trigger a manual Job for the initial sync
_, err = c.kubeclientset.BatchV1().Jobs(c.kubeappsNamespace).Create(newSyncJob(apprepo, c.kubeappsNamespace))
_, err = c.kubeclientset.BatchV1().Jobs(c.kubeappsNamespace).Create(context.TODO(), newSyncJob(apprepo, c.kubeappsNamespace), metav1.CreateOptions{})
} else if err == nil {
// If the resource already exists, we'll update it
log.Infof("Updating CronJob %q in namespace %q for AppRepository %q in namespace %q", cronjobName, c.kubeappsNamespace, apprepo.GetName(), apprepo.GetNamespace())
cronjob, err = c.kubeclientset.BatchV1beta1().CronJobs(c.kubeappsNamespace).Update(newCronJob(apprepo, c.kubeappsNamespace))
cronjob, err = c.kubeclientset.BatchV1beta1().CronJobs(c.kubeappsNamespace).Update(context.TODO(), newCronJob(apprepo, c.kubeappsNamespace), metav1.UpdateOptions{})
if err != nil {
return err
}

// The AppRepository has changed, launch a manual Job
_, err = c.kubeclientset.BatchV1().Jobs(c.kubeappsNamespace).Create(newSyncJob(apprepo, c.kubeappsNamespace))
_, err = c.kubeclientset.BatchV1().Jobs(c.kubeappsNamespace).Create(context.TODO(), newSyncJob(apprepo, c.kubeappsNamespace), metav1.CreateOptions{})
}

// If an error occurs during Get/Create, we'll requeue the item so we can
Expand Down
14 changes: 12 additions & 2 deletions cmd/apprepository-controller/hack/update-codegen.sh
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2017 Bitnami.
# Copyright 2020 Bitnami.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,14 +14,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# From https://github.com/kubernetes/sample-controller#when-using-go-111-modules
# To regenerate the api code:
#
# 1. update the .gitmodules in the root directory with the correct branch of code-generator
# and then run: git submodule update --remote
# 2. Run the this script from the apprepository-controller directory: ./hack/update-codegen.sh
# 3. Move the newly generated files over the old ones:
# mv github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/apis/apprepository/v1alpha1/zz_generated.deepcopy.go ./pkg/apis/apprepository/v1alpha1/zz_generated.deepcopy.go
# rm pkg/client -rf && mv github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/client ./pkg
set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../../../k8s.io/code-generator)}

${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
bash "${CODEGEN_PKG}"/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/client github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/apis \
apprepository:v1alpha1 \
--output-base "${SCRIPT_ROOT}" \
--go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65fc66e

Please sign in to comment.