Skip to content

Commit

Permalink
feat: add new parameter: SUPPORT_BUNDLE_COLLECTOR
Browse files Browse the repository at this point in the history
Signed-off-by: Ray Chang <ray.chang@suse.com>
  • Loading branch information
weizhe0422 authored and bk201 committed Mar 16, 2023
1 parent 22744b6 commit 0e19076
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions cmd/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func init() {
managerCmd.PersistentFlags().StringVar(&sbm.ImagePullPolicy, "image-pull-policy", os.Getenv("SUPPORT_BUNDLE_IMAGE_PULL_POLICY"), "Pull policy of the support bundle image")
managerCmd.PersistentFlags().StringVar(&sbm.NodeSelector, "node-selector", os.Getenv("SUPPORT_BUNDLE_NODE_SELECTOR"), "NodeSelector of agent DaemonSet. e.g., key1=value1,key2=value2")
managerCmd.PersistentFlags().StringVar(&sbm.RegistrySecret, "registry-secret", os.Getenv("SUPPORT_BUNDLE_REGISTRY_SECRET"), "The registry secret for image pull")
managerCmd.PersistentFlags().StringVar(&sbm.SpecifyCollector, "specify-collector", os.Getenv("SUPPORT_BUNDLE_COLLECTOR"), "Execute specify collector script. e.g., longhorn")
managerCmd.PersistentFlags().StringSliceVar(&sbm.ExcludeResourceList, "exclude-resources", getEnvStringSlice("SUPPORT_BUNDLE_EXCLUDE_RESOURCES"), "List of resources to exclude. e.g., settings.harvesterhci.io,secrets")
managerCmd.PersistentFlags().StringSliceVar(&sbm.BundleCollectors, "extra-collectors", getEnvStringSlice("SUPPORT_BUNDLE_EXTRA_COLLECTORS"), "Get extra resource for the specific components e.g., harvester")
}
10 changes: 5 additions & 5 deletions hack/collector-default → hack/collector-longhorn
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ function collect_sysinfo(){
cd ${BUNDLE_DIR}
mkdir -p hostinfos
cd hostinfos
echo "hostname : " `cat ${HOST_PATH}/etc/hostname` > hostinfo
echo "os-release : " `cat ${HOST_PATH}/etc/os-release` >> hostinfo
echo "system-info : " `uname -a` >> hostinfo

echo -e "hostname : \n `cat ${HOST_PATH}/etc/hostname | sed "s/^/\t/"`" > hostinfo
echo -e "os-release : \n `cat ${HOST_PATH}/etc/os-release | sed "s/^/\t/"`" >> hostinfo
echo -e "system-info : \n `uname -a | sed "s/^/\t/"`" >> hostinfo

# Boot Configuration
cat ${HOST_PATH}/boot/config-$(uname -r) > kernel_config
Expand All @@ -24,7 +24,7 @@ function collect_dmesg(){
}

function collect_syslog(){
tail -c 10m ${HOST_PATH}/var/log/syslog > syslog.log
cp ${HOST_PATH}/var/log/syslog* .
}

function collect_kubelet_log(){
Expand Down
9 changes: 7 additions & 2 deletions hack/support-bundle-collector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ if [ -z "$OS_ID" ]; then
exit 1
fi

OS_COLLECTOR="collector-$OS_ID"
if [ -n "$SUPPORT_BUNDLE_COLLECTOR" ]; then
OS_COLLECTOR="collector-$SUPPORT_BUNDLE_COLLECTOR"
else
OS_COLLECTOR="collector-$OS_ID"
fi
echo "OS_COLLECTOR="${OS_COLLECTOR}

if [ -x "$(which $OS_COLLECTOR)" ]; then
$OS_COLLECTOR $HOST_PATH $BUNDLE_DIR
else
echo "No OS collector found"
collector-default $HOST_PATH $BUNDLE_DIR
fi

cd ${OUTPUT_DIR}
Expand Down
7 changes: 6 additions & 1 deletion pkg/manager/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"fmt"

"github.com/pkg/errors"
"github.com/rancher/support-bundle-kit/pkg/types"
"github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/rancher/support-bundle-kit/pkg/types"
)

type AgentDaemonSet struct {
Expand Down Expand Up @@ -100,6 +101,10 @@ func (a *AgentDaemonSet) Create(image string, managerURL string) error {
Name: "SUPPORT_BUNDLE_MANAGER_URL",
Value: managerURL,
},
{
Name: "SUPPORT_BUNDLE_COLLECTOR",
Value: a.sbm.SpecifyCollector,
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down
1 change: 1 addition & 0 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type SupportBundleManager struct {
ExcludeResources []schema.GroupResource
ExcludeResourceList []string
BundleCollectors []string
SpecifyCollector string

context context.Context

Expand Down

0 comments on commit 0e19076

Please sign in to comment.