Skip to content
6 changes: 3 additions & 3 deletions pkg/collect/cluster_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (c *CollectClusterResources) Collect(progressChan chan<- interface{}) (Coll
// replicasets
replicasets, replicasetsErrors := replicasets(ctx, client, namespaceNames)
for k, v := range replicasets {
output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, fmt.Sprintf("%s-errors.json", constants.CLUSTER_RESOURCES_STATEFULSETS), k), bytes.NewBuffer(v))
output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, constants.CLUSTER_RESOURCES_REPLICASETS, k), bytes.NewBuffer(v))
}
output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, fmt.Sprintf("%s-errors.json", constants.CLUSTER_RESOURCES_REPLICASETS)), marshalErrors(replicasetsErrors))

Expand Down Expand Up @@ -370,9 +370,9 @@ func (c *CollectClusterResources) Collect(progressChan chan<- interface{}) (Coll
// endpointslices
endpointslices, endpointslicesErrors := endpointslices(ctx, client, namespaceNames)
for k, v := range endpointslices {
_ = output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, constants.CLUSTER_RESOURCES_ENDPOINTSICES, k), bytes.NewBuffer(v))
_ = output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, constants.CLUSTER_RESOURCES_ENDPOINTSLICES, k), bytes.NewBuffer(v))
}
_ = output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, fmt.Sprintf("%s-errors.json", constants.CLUSTER_RESOURCES_ENDPOINTSICES)), marshalErrors(endpointslicesErrors))
_ = output.SaveResult(c.BundlePath, path.Join(constants.CLUSTER_RESOURCES_DIR, fmt.Sprintf("%s-errors.json", constants.CLUSTER_RESOURCES_ENDPOINTSLICES)), marshalErrors(endpointslicesErrors))

// Service Accounts
servicesAccounts, servicesAccountsErrors := serviceAccounts(ctx, client, namespaceNames)
Expand Down
81 changes: 66 additions & 15 deletions pkg/collect/goldpinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -191,21 +192,21 @@ func (c *CollectGoldpinger) DiscoverOrCreateGoldpinger(ns string) (string, creat
if serviceAccountName == "" {
serviceAccountName = "ts-goldpinger-serviceaccount"

svcAcc, err := c.createGoldpingerServiceAccount(ns, serviceAccountName)
svcAcc, err := c.ensureGoldpingerServiceAccount(ns, serviceAccountName)
if err != nil {
return "", ret, errors.Wrap(err, "failed to create goldpinger service account")
}
ret.ServiceAccnt = svcAcc
klog.V(2).Infof("%s ServiceAccount created", svcAcc.Name)

r, err := c.createGoldpingerRole(ns)
r, err := c.ensureGoldpingerRole(ns)
if err != nil {
return "", ret, errors.Wrap(err, "failed to create goldpinger role")
}
ret.Role = r
klog.V(2).Infof("%s Role created", r.Name)

rb, err := c.createGoldpingerRoleBinding(ns)
rb, err := c.ensureGoldpingerRoleBinding(ns)
if err != nil {
return "", ret, errors.Wrap(err, "failed to create goldpinger role binding")
}
Expand All @@ -217,7 +218,7 @@ func (c *CollectGoldpinger) DiscoverOrCreateGoldpinger(ns string) (string, creat
}
}

ds, err := c.createGoldpingerDaemonSet(ns, serviceAccountName)
ds, err := c.ensureGoldpingerDaemonSet(ns, serviceAccountName)
if err != nil {
return "", ret, errors.Wrap(err, "failed to create goldpinger daemonset")
}
Expand All @@ -236,7 +237,7 @@ func (c *CollectGoldpinger) DiscoverOrCreateGoldpinger(ns string) (string, creat

time.Sleep(delay)

svc, err := c.createGoldpingerService(ns)
svc, err := c.ensureGoldpingerService(ns)
if err != nil {
return "", ret, errors.Wrap(err, "failed to create goldpinger service")
}
Expand All @@ -246,18 +247,28 @@ func (c *CollectGoldpinger) DiscoverOrCreateGoldpinger(ns string) (string, creat
return getUrlFromService(svc), ret, nil
}

func (c *CollectGoldpinger) createGoldpingerServiceAccount(ns, name string) (*corev1.ServiceAccount, error) {
func (c *CollectGoldpinger) ensureGoldpingerServiceAccount(ns, name string) (*corev1.ServiceAccount, error) {
svcAcc := &corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
},
}

return c.Client.CoreV1().ServiceAccounts(ns).Create(c.Context, svcAcc, metav1.CreateOptions{})
created, err := c.Client.CoreV1().ServiceAccounts(ns).Create(c.Context, svcAcc, metav1.CreateOptions{})
if err != nil && !kerrors.IsAlreadyExists(err) {
return nil, err
}

// If the service account already exists, retrieve it
if kerrors.IsAlreadyExists(err) {
return c.Client.CoreV1().ServiceAccounts(ns).Get(c.Context, name, metav1.GetOptions{})
}

return created, nil
}

func (c *CollectGoldpinger) createGoldpingerRole(ns string) (*rbacv1.Role, error) {
func (c *CollectGoldpinger) ensureGoldpingerRole(ns string) (*rbacv1.Role, error) {
role := &rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Name: "ts-goldpinger-role",
Expand All @@ -272,10 +283,20 @@ func (c *CollectGoldpinger) createGoldpingerRole(ns string) (*rbacv1.Role, error
},
}

return c.Client.RbacV1().Roles(ns).Create(c.Context, role, metav1.CreateOptions{})
created, err := c.Client.RbacV1().Roles(ns).Create(c.Context, role, metav1.CreateOptions{})
if err != nil && !kerrors.IsAlreadyExists(err) {
return nil, err
}

// If the role already exists, retrieve it
if kerrors.IsAlreadyExists(err) {
return c.Client.RbacV1().Roles(ns).Get(c.Context, role.Name, metav1.GetOptions{})
}

return created, nil
}

func (c *CollectGoldpinger) createGoldpingerRoleBinding(ns string) (*rbacv1.RoleBinding, error) {
func (c *CollectGoldpinger) ensureGoldpingerRoleBinding(ns string) (*rbacv1.RoleBinding, error) {
roleBinding := &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: "ts-goldpinger-rolebinding",
Expand All @@ -295,10 +316,20 @@ func (c *CollectGoldpinger) createGoldpingerRoleBinding(ns string) (*rbacv1.Role
},
}

return c.Client.RbacV1().RoleBindings(ns).Create(c.Context, roleBinding, metav1.CreateOptions{})
created, err := c.Client.RbacV1().RoleBindings(ns).Create(c.Context, roleBinding, metav1.CreateOptions{})
if err != nil && !kerrors.IsAlreadyExists(err) {
return nil, err
}

// If the role binding already exists, retrieve it
if kerrors.IsAlreadyExists(err) {
return c.Client.RbacV1().RoleBindings(ns).Get(c.Context, roleBinding.Name, metav1.GetOptions{})
}

return created, nil
}

func (c *CollectGoldpinger) createGoldpingerDaemonSet(ns, svcAccName string) (*appsv1.DaemonSet, error) {
func (c *CollectGoldpinger) ensureGoldpingerDaemonSet(ns, svcAccName string) (*appsv1.DaemonSet, error) {
ds := &appsv1.DaemonSet{}

if c.Collector.Image != "" {
Expand Down Expand Up @@ -411,10 +442,20 @@ func (c *CollectGoldpinger) createGoldpingerDaemonSet(ns, svcAccName string) (*a
},
}

return c.Client.AppsV1().DaemonSets(ns).Create(c.Context, ds, metav1.CreateOptions{})
created, err := c.Client.AppsV1().DaemonSets(ns).Create(c.Context, ds, metav1.CreateOptions{})
if err != nil && !kerrors.IsAlreadyExists(err) {
return nil, err
}

// If the daemonset already exists, retrieve it
if kerrors.IsAlreadyExists(err) {
return c.Client.AppsV1().DaemonSets(ns).Get(c.Context, ds.Name, metav1.GetOptions{})
}

return created, nil
}

func (c *CollectGoldpinger) createGoldpingerService(ns string) (*corev1.Service, error) {
func (c *CollectGoldpinger) ensureGoldpingerService(ns string) (*corev1.Service, error) {
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "ts-goldpinger",
Expand All @@ -435,7 +476,17 @@ func (c *CollectGoldpinger) createGoldpingerService(ns string) (*corev1.Service,
},
}

return c.Client.CoreV1().Services(ns).Create(c.Context, svc, metav1.CreateOptions{})
created, err := c.Client.CoreV1().Services(ns).Create(c.Context, svc, metav1.CreateOptions{})
if err != nil && !kerrors.IsAlreadyExists(err) {
return nil, err
}

// If the service already exists, retrieve it
if kerrors.IsAlreadyExists(err) {
return c.Client.CoreV1().Services(ns).Get(c.Context, svc.Name, metav1.GetOptions{})
}

return created, nil
}

func (c *CollectGoldpinger) getGoldpingerService(ns string) (*corev1.Service, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (
CLUSTER_RESOURCES_CLUSTER_ROLE_BINDINGS = "clusterrolebindings"
CLUSTER_RESOURCES_PRIORITY_CLASS = "priorityclasses"
CLUSTER_RESOURCES_ENDPOINTS = "endpoints"
CLUSTER_RESOURCES_ENDPOINTSICES = "endpointslices"
CLUSTER_RESOURCES_ENDPOINTSLICES = "endpointslices"
CLUSTER_RESOURCES_SERVICE_ACCOUNTS = "serviceaccounts"
CLUSTER_RESOURCES_LEASES = "leases"
CLUSTER_RESOURCES_VOLUME_ATTACHMENTS = "volumeattachments"
Expand Down
24 changes: 12 additions & 12 deletions scripts/update_baselines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ trap "rm -rf $TEMP_DIR" EXIT
echo -e "\n${BLUE}Step 1: Downloading artifacts...${NC}"

# Download artifacts from the run
cd "$TEMP_DIR"
if ! gh run download "$RUN_ID" --name "regression-test-results-${RUN_ID}-1" 2>/dev/null; then
if ! gh run download "$RUN_ID" --name "regression-test-results-${RUN_ID}-1" --dir "$TEMP_DIR" 2>/dev/null; then
# Try without attempt suffix
if ! gh run download "$RUN_ID" 2>/dev/null; then
if ! gh run download "$RUN_ID" --dir "$TEMP_DIR" 2>/dev/null; then
echo -e "${RED}Error: Failed to download artifacts from run ${RUN_ID}${NC}"
gh run download "$RUN_ID" --dir "$TEMP_DIR"
exit 1
fi
fi
Expand All @@ -67,18 +67,18 @@ V1BETA3_BUNDLE=""
V1BETA2_BUNDLE=""
SUPPORTBUNDLE=""

if [ -f "preflight-v1beta3-bundle.tar.gz" ] || [ -f "test/output/preflight-v1beta3-bundle.tar.gz" ]; then
V1BETA3_BUNDLE=$(find . -name "preflight-v1beta3-bundle.tar.gz" | head -1)
if [ -f "$TEMP_DIR/preflight-v1beta3-bundle.tar.gz" ] || [ -f "$TEMP_DIR/test/output/preflight-v1beta3-bundle.tar.gz" ]; then
V1BETA3_BUNDLE=$(find "$TEMP_DIR" -name "preflight-v1beta3-bundle.tar.gz" | head -1)
echo -e "${GREEN}✓${NC} Found v1beta3 preflight bundle"
fi

if [ -f "preflight-v1beta2-bundle.tar.gz" ] || [ -f "test/output/preflight-v1beta2-bundle.tar.gz" ]; then
V1BETA2_BUNDLE=$(find . -name "preflight-v1beta2-bundle.tar.gz" | head -1)
if [ -f "$TEMP_DIR/preflight-v1beta2-bundle.tar.gz" ] || [ -f "$TEMP_DIR/test/output/preflight-v1beta2-bundle.tar.gz" ]; then
V1BETA2_BUNDLE=$(find "$TEMP_DIR" -name "preflight-v1beta2-bundle.tar.gz" | head -1)
echo -e "${GREEN}✓${NC} Found v1beta2 preflight bundle"
fi

if [ -f "supportbundle.tar.gz" ] || [ -f "test/output/supportbundle.tar.gz" ]; then
SUPPORTBUNDLE=$(find . -name "supportbundle.tar.gz" | head -1)
if [ -f "$TEMP_DIR/supportbundle.tar.gz" ] || [ -f "$TEMP_DIR/test/output/supportbundle.tar.gz" ]; then
SUPPORTBUNDLE=$(find "$TEMP_DIR" -name "supportbundle.tar.gz" | head -1)
echo -e "${GREEN}✓${NC} Found support bundle"
fi

Expand Down Expand Up @@ -110,21 +110,21 @@ echo -e "\n${BLUE}Step 3: Updating baselines...${NC}"
# Update v1beta3 baseline
if [ -n "$V1BETA3_BUNDLE" ]; then
mkdir -p test/baselines/preflight-v1beta3
cp "$TEMP_DIR/$V1BETA3_BUNDLE" test/baselines/preflight-v1beta3/baseline.tar.gz
cp "$V1BETA3_BUNDLE" test/baselines/preflight-v1beta3/baseline.tar.gz
echo -e "${GREEN}✓${NC} Updated preflight-v1beta3 baseline"
fi

# Update v1beta2 baseline
if [ -n "$V1BETA2_BUNDLE" ]; then
mkdir -p test/baselines/preflight-v1beta2
cp "$TEMP_DIR/$V1BETA2_BUNDLE" test/baselines/preflight-v1beta2/baseline.tar.gz
cp "$V1BETA2_BUNDLE" test/baselines/preflight-v1beta2/baseline.tar.gz
echo -e "${GREEN}✓${NC} Updated preflight-v1beta2 baseline"
fi

# Update support bundle baseline
if [ -n "$SUPPORTBUNDLE" ]; then
mkdir -p test/baselines/supportbundle
cp "$TEMP_DIR/$SUPPORTBUNDLE" test/baselines/supportbundle/baseline.tar.gz
cp "$SUPPORTBUNDLE" test/baselines/supportbundle/baseline.tar.gz
echo -e "${GREEN}✓${NC} Updated supportbundle baseline"
fi

Expand Down
7 changes: 7 additions & 0 deletions test/baselines/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"updated_at": "2025-11-25T21:54:16Z",
"git_sha": "7caba50d3489c87eb875feedc3ae915b00d187e1",
"workflow_run_id": "19685157847",
"k8s_version": "v1.28.3",
"updated_by": "Ethan Mosbaugh <[email protected]>"
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Accidentally committed baseline metadata file

The test/baselines/metadata.json file contains hardcoded values from a specific test run, including a timestamp, git SHA, workflow run ID, and user email. This file should be generated dynamically by the update_baselines.sh script rather than committed with specific values. The presence of this file suggests it was accidentally included from a local test run.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i am supposed to commit this

Binary file modified test/baselines/preflight-v1beta2/baseline.tar.gz
Binary file not shown.
Binary file modified test/baselines/preflight-v1beta3/baseline.tar.gz
Binary file not shown.
Binary file modified test/baselines/supportbundle/baseline.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion test/e2e/support-bundle/cluster_resources_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestClusterResources(t *testing.T) {
"roles",
"events",
"rolebindings",
"statefulsets-errors.json",
"replicasets",
"jobs",
"serviceaccounts",
"configmaps",
Expand Down
Loading