Skip to content

Commit b685638

Browse files
Copilotnddq
andcommitted
Add GitHub Actions workflow job for retina-shell-win-images and run formatter
Co-authored-by: nddq <[email protected]>
1 parent 3bce1e7 commit b685638

25 files changed

+97
-61
lines changed

.github/workflows/images.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,58 @@ jobs:
213213
fi
214214
env:
215215
IS_MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
216+
217+
retina-shell-win-images:
218+
name: Build Retina Shell Windows Images
219+
runs-on: ubuntu-latest
220+
221+
strategy:
222+
matrix:
223+
platform: ["windows"]
224+
arch: ["amd64"]
225+
year: ["2019", "2022"]
226+
227+
steps:
228+
- name: Checkout code
229+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
230+
231+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
232+
with:
233+
go-version-file: go.mod
234+
- run: go version
235+
236+
- name: Set up QEMU
237+
uses: docker/setup-qemu-action@v3
238+
239+
- name: Az CLI login
240+
uses: azure/login@v2
241+
if: ${{ github.event_name == 'merge_group' }}
242+
with:
243+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
244+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
245+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION }}
246+
247+
- name: Build Images
248+
shell: bash
249+
run: |
250+
set -euo pipefail
251+
echo "TAG=$(make version)" >> $GITHUB_ENV
252+
if [ "$IS_MERGE_GROUP" == "true" ]; then
253+
az acr login -n ${{ vars.ACR_NAME }}
254+
make retina-shell-image-win \
255+
IMAGE_NAMESPACE=${{ github.repository }} \
256+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }} \
257+
IMAGE_REGISTRY=${{ vars.ACR_NAME }} \
258+
WINDOWS_YEARS=${{ matrix.year }} \
259+
BUILDX_ACTION=--push
260+
else
261+
make retina-shell-image-win \
262+
IMAGE_NAMESPACE=${{ github.repository }} \
263+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }} \
264+
WINDOWS_YEARS=${{ matrix.year }}
265+
fi
266+
env:
267+
IS_MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
216268

217269
kubectl-retina-images:
218270
name: Build Kubectl Retina Images
@@ -273,6 +325,7 @@ jobs:
273325
retina-win-images,
274326
operator-images,
275327
retina-shell-images,
328+
retina-shell-win-images,
276329
kubectl-retina-images,
277330
]
278331

cli/cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ type Config struct {
2424
}
2525

2626
var Retina = &cobra.Command{
27-
Use: "kubectl-retina",
27+
Use: "kubectl-retina",
2828
Short: "A kubectl plugin for Retina",
29-
Long: "A kubectl plugin for Retina\nRetina is an eBPF distributed networking observability tool for Kubernetes.",
29+
Long: "A kubectl plugin for Retina\nRetina is an eBPF distributed networking observability tool for Kubernetes.",
3030
PersistentPreRun: func(*cobra.Command, []string) {
3131
var config Config
3232
file, _ := os.ReadFile(ClientConfigPath)

deploy/testutils/grafana/dashboards/simplify-grafana-overwrite_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
func TestOverwriteDashboards(t *testing.T) {
1212
// get all json's in various generation deploly folders
1313
files, err := filepath.Glob("../../../grafana-dashboards/*.json")
14-
1514
if err != nil {
1615
t.Fatal(err)
1716
}

deploy/testutils/grafana/dashboards/simplify-grafana_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
func TestDashboardsAreSimplified(t *testing.T) {
1313
// get all json's in this folder
1414
files, err := filepath.Glob("../../../grafana-dashboards/*.json")
15-
1615
if err != nil {
1716
t.Fatal(err)
1817
}

operator/cilium-crds/k8s/fakeresource.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import (
88
"github.com/cilium/cilium/pkg/k8s/resource"
99
)
1010

11-
type fakeresource[T k8sRuntime.Object] struct {
12-
}
11+
type fakeresource[T k8sRuntime.Object] struct{}
1312

1413
func (f *fakeresource[T]) Events(ctx context.Context, opts ...resource.EventsOpt) <-chan resource.Event[T] {
1514
return make(<-chan resource.Event[T])

pkg/k8s/watcher_linux.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ func init() {
2323
}
2424
}
2525

26-
var (
27-
logger = logging.DefaultLogger.WithField(logfields.LogSubsys, "k8s-watcher")
28-
)
26+
var logger = logging.DefaultLogger.WithField(logfields.LogSubsys, "k8s-watcher")
2927

3028
func Start(ctx context.Context, k *watchers.K8sWatcher) {
3129
logger.Info("Starting Kubernetes watcher")

pkg/plugin/hnsstats/vfp_counters_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ func getVfpPortCountersRaw(portGUID string) (string, error) {
152152

153153
cmd := exec.Command("cmd", "/c", vfpCmd)
154154
out, err := cmd.Output()
155-
156155
if err != nil {
157156
return "", errors.Wrap(err, "errored while running vfpctrl /get-port-counter")
158157
}

pkg/plugin/linuxutil/types_linux.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"github.com/microsoft/retina/pkg/log"
99
)
1010

11-
const name = "linuxutil"
12-
const defaultLimit = 2000
11+
const (
12+
name = "linuxutil"
13+
defaultLimit = 2000
14+
)
1315

1416
//go:generate go run go.uber.org/mock/[email protected] -source=types_linux.go -destination=linuxutil_mock_generated_linux.go -package=linuxutil
1517
type linuxUtil struct {

pkg/telemetry/telemetry.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func (t *TelemetryClient) heartbeat(ctx context.Context) {
193193
maps.Copy(props, t.profile.GetMemoryUsage())
194194
t.TrackEvent("heartbeat", props)
195195
}
196+
196197
func metricsCardinality(gatherer prometheus.Gatherer) (int, error) {
197198
if gatherer == nil {
198199
return 0, fmt.Errorf("failed to get metrics Gatherer: %w", ErrorNilCombinedGatherer)

shell/manifests.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ func hostNetworkPodForNodeDebug(config Config, debugPodNamespace, nodeName strin
7272
if config.MountHostFilesystem || config.AllowHostFilesystemWrite {
7373
hostPath := "/"
7474
mountPath := "/host"
75-
75+
7676
if config.NodeOS == "windows" {
7777
hostPath = "C:\\"
7878
mountPath = "C:\\host"
7979
}
80-
80+
8181
pod.Spec.Volumes = append(pod.Spec.Volumes, v1.Volume{
8282
Name: "host-filesystem",
8383
VolumeSource: v1.VolumeSource{

shell/manifests_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
v1 "k8s.io/api/core/v1"
99
)
1010

11-
const testRetinaImage = "retina-shell:v0.0.1"
12-
const testRetinaWindowsImage = "retina-shell:v0.0.1-windows-ltsc2022-amd64"
11+
const (
12+
testRetinaImage = "retina-shell:v0.0.1"
13+
testRetinaWindowsImage = "retina-shell:v0.0.1-windows-ltsc2022-amd64"
14+
)
1315

1416
func TestEphemeralContainerForPodDebug(t *testing.T) {
1517
ec := ephemeralContainerForPodDebug(Config{RetinaShellImage: testRetinaImage})
@@ -98,14 +100,14 @@ func TestHostNetworkPodForWindowsNodeDebug(t *testing.T) {
98100
NodeOS: "windows",
99101
}
100102
pod := hostNetworkPodForNodeDebug(config, "kube-system", "win-node0001")
101-
103+
102104
// Verify Windows specific configurations
103105
assert.NotNil(t, pod.Spec.SecurityContext)
104106
assert.NotNil(t, pod.Spec.SecurityContext.WindowsOptions)
105107
assert.NotNil(t, pod.Spec.SecurityContext.WindowsOptions.HostProcess)
106108
assert.True(t, *pod.Spec.SecurityContext.WindowsOptions.HostProcess)
107109
assert.Equal(t, "NT AUTHORITY\\SYSTEM", *pod.Spec.SecurityContext.WindowsOptions.RunAsUserName)
108-
110+
109111
// HostPID should be false for Windows regardless of setting
110112
assert.False(t, pod.Spec.HostPID)
111113
}
@@ -117,11 +119,11 @@ func TestHostNetworkPodForWindowsNodeDebugWithMountHostFilesystem(t *testing.T)
117119
MountHostFilesystem: true,
118120
}
119121
pod := hostNetworkPodForNodeDebug(config, "kube-system", "win-node0001")
120-
122+
121123
assert.Len(t, pod.Spec.Volumes, 1)
122124
assert.Equal(t, "host-filesystem", pod.Spec.Volumes[0].Name)
123125
assert.Equal(t, "C:\\", pod.Spec.Volumes[0].VolumeSource.HostPath.Path)
124-
126+
125127
assert.Len(t, pod.Spec.Containers[0].VolumeMounts, 1)
126128
assert.Equal(t, "host-filesystem", pod.Spec.Containers[0].VolumeMounts[0].Name)
127129
assert.Equal(t, "C:\\host", pod.Spec.Containers[0].VolumeMounts[0].MountPath)
@@ -134,7 +136,7 @@ func TestHostNetworkPodForWindowsNodeWithHostPID(t *testing.T) {
134136
HostPID: true, // Should be ignored for Windows
135137
}
136138
pod := hostNetworkPodForNodeDebug(config, "kube-system", "win-node0001")
137-
139+
138140
// HostPID should be false for Windows regardless of the setting
139141
assert.False(t, pod.Spec.HostPID)
140142
}

shell/validation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ func TestGetNodeOS(t *testing.T) {
103103
assert.Equal(t, tt.wantOS, os)
104104
})
105105
}
106-
}
106+
}

test/e2e/framework/kubernetes/check-pod-status.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func (w *WaitPodsReady) Prevalidate() error {
3737
// Primary step where test logic is executed
3838
// Returning an error will cause the test to fail
3939
func (w *WaitPodsReady) Run() error {
40-
4140
config, err := clientcmd.BuildConfigFromFlags("", w.KubeConfigFilePath)
4241
if err != nil {
4342
return fmt.Errorf("error building kubeconfig: %w", err)
@@ -59,7 +58,6 @@ func (w *WaitPodsReady) Stop() error {
5958
}
6059

6160
func WaitForPodReady(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelSelector string) error {
62-
6361
printIterator := 0
6462
conditionFunc := wait.ConditionWithContextFunc(func(context.Context) (bool, error) {
6563
defer func() {

test/e2e/framework/kubernetes/get-external-crd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func extractFileName(rawURL string) (string, error) {
5555
}
5656

5757
func saveToFile(filename string, data []byte) error {
58-
err := os.WriteFile(filename, data, 0644)
58+
err := os.WriteFile(filename, data, 0o644)
5959
if err != nil {
6060
return fmt.Errorf("failed to write crd.yaml to /crds dir : %w", err)
6161
}

test/e2e/framework/kubernetes/install-retina-helm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (i *InstallHelmChart) Run() error {
6868
return fmt.Errorf("image namespace is not set: %w", errEmpty)
6969
}
7070

71-
//Download necessary CRD's
71+
// Download necessary CRD's
7272
err = downloadExternalCRDs(i.ChartPath)
7373
if err != nil {
7474
return fmt.Errorf("failed to load external crd's: %w", err)

test/e2e/framework/scaletest/add-shared-labels.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func (a *AddSharedLabelsToAllPods) Prevalidate() error {
3535
// Primary step where test logic is executed
3636
// Returning an error will cause the test to fail
3737
func (a *AddSharedLabelsToAllPods) Run() error {
38-
3938
if a.NumSharedLabelsPerPod < 1 {
4039
return nil
4140
}

test/e2e/framework/scaletest/add-unique-labels.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func (a *AddUniqueLabelsToAllPods) Prevalidate() error {
2727
// Primary step where test logic is executed
2828
// Returning an error will cause the test to fail
2929
func (a *AddUniqueLabelsToAllPods) Run() error {
30-
3130
if a.NumUniqueLabelsPerPod < 1 {
3231
return nil
3332
}

test/e2e/framework/scaletest/create-network-policies.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ func (c *CreateNetworkPolicies) Prevalidate() error {
3333
// Primary step where test logic is executed
3434
// Returning an error will cause the test to fail
3535
func (c *CreateNetworkPolicies) Run() error {
36-
3736
config, err := clientcmd.BuildConfigFromFlags("", c.KubeConfigFilePath)
3837
if err != nil {
3938
return fmt.Errorf("error building kubeconfig: %w", err)

test/e2e/framework/scaletest/delete-and-re-add-labels.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ func (d *DeleteAndReAddLabels) addLabels(ctx context.Context, clientset *kuberne
118118
}
119119

120120
func (d *DeleteAndReAddLabels) deleteLabels(ctx context.Context, clientset *kubernetes.Clientset, pods *corev1.PodList, patch string) error {
121-
122121
for _, pod := range pods.Items {
123122
log.Println("Deleting label from Pod", pod.Name)
124123

test/e2e/framework/scaletest/get-publish-metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ func (g *GetAndPublishMetrics) Run() error {
7676
g.errs = new(errgroup.Group)
7777

7878
g.errs.Go(func() error {
79-
8079
t := time.NewTicker(defaultInterval)
8180
defer t.Stop()
8281

@@ -100,7 +99,6 @@ func (g *GetAndPublishMetrics) Run() error {
10099

101100
}
102101
}
103-
104102
})
105103

106104
return nil
@@ -135,7 +133,6 @@ func (g *GetAndPublishMetrics) Prevalidate() error {
135133
}
136134

137135
func (g *GetAndPublishMetrics) getAndPublishMetrics() error {
138-
139136
ctx := context.TODO()
140137

141138
labelSelector := labels.Set(g.Labels).String()
@@ -161,7 +158,6 @@ func (g *GetAndPublishMetrics) getAndPublishMetrics() error {
161158
log.Println("Publishing metrics to AppInsights")
162159
for _, metric := range allMetrics {
163160
g.telemetryClient.TrackEvent("scale-test", metric)
164-
165161
}
166162
}
167163

@@ -192,7 +188,6 @@ func (g *GetAndPublishMetrics) getAndPublishMetrics() error {
192188
type metric map[string]string
193189

194190
func (g *GetAndPublishMetrics) getPodsMetrics(ctx context.Context, labelSelector string) ([]metric, error) {
195-
196191
var pods *v1.PodList
197192

198193
retrier := retry.Retrier{Attempts: defaultRetryAttempts, Delay: defaultRetryDelay}

test/e2e/framework/scaletest/templates/networkpolicy.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@ import (
55
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
66
)
77

8-
var (
9-
NetworkPolicy = netv1.NetworkPolicy{
10-
TypeMeta: metav1.TypeMeta{
11-
Kind: "NetworkPolicy",
12-
APIVersion: "networking.k8s.io/v1",
8+
var NetworkPolicy = netv1.NetworkPolicy{
9+
TypeMeta: metav1.TypeMeta{
10+
Kind: "NetworkPolicy",
11+
APIVersion: "networking.k8s.io/v1",
12+
},
13+
ObjectMeta: metav1.ObjectMeta{
14+
Name: "template-network-policy",
15+
},
16+
Spec: netv1.NetworkPolicySpec{
17+
PolicyTypes: []netv1.PolicyType{
18+
"Ingress",
19+
"Egress",
1320
},
14-
ObjectMeta: metav1.ObjectMeta{
15-
Name: "template-network-policy",
21+
PodSelector: metav1.LabelSelector{
22+
MatchLabels: map[string]string{},
1623
},
17-
Spec: netv1.NetworkPolicySpec{
18-
PolicyTypes: []netv1.PolicyType{
19-
"Ingress",
20-
"Egress",
21-
},
22-
PodSelector: metav1.LabelSelector{
23-
MatchLabels: map[string]string{},
24-
},
25-
},
26-
}
27-
)
24+
},
25+
}

test/e2e/framework/scaletest/validate-options.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func (po *ValidateAndPrintOptions) Prevalidate() error {
3737

3838
// Returning an error will cause the test to fail
3939
func (po *ValidateAndPrintOptions) Run() error {
40-
4140
log.Printf("Starting to scale with folowing options: %+v", po.Options)
4241

4342
return nil

test/e2e/retina_perf_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ import (
1717
"github.com/stretchr/testify/require"
1818
)
1919

20-
var (
21-
// Add flags for the test
22-
// retina-mode: basic, advanced, hubble
23-
retinaMode = flag.String("retina-mode", "basic", "One of basic or advanced")
24-
)
20+
// Add flags for the test
21+
// retina-mode: basic, advanced, hubble
22+
var retinaMode = flag.String("retina-mode", "basic", "One of basic or advanced")
2523

2624
func validateRetinaMode(t *testing.T) {
2725
switch *retinaMode {

test/e2e/scenarios/perf/publish-perf-results.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (v *PublishPerfResults) Run() error {
2929
return nil
3030
}
3131

32-
resultsFile, err := os.OpenFile(v.ResultsFile, os.O_RDONLY, 0644)
32+
resultsFile, err := os.OpenFile(v.ResultsFile, os.O_RDONLY, 0o644)
3333
if err != nil {
3434
return errors.Wrap(err, "failed to open results file")
3535
}

0 commit comments

Comments
 (0)