Skip to content

Commit b4ed1b1

Browse files
authored
Use exec collectors instead of http for support bundles (#186)
Replicated SDK support bundle contains additional app and license details.
1 parent 0d2bb9d commit b4ed1b1

File tree

4 files changed

+133
-32
lines changed

4 files changed

+133
-32
lines changed

.github/workflows/main.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,22 @@ jobs:
516516
echo "Did not find replicated pod logs in support bundle"
517517
exit 1
518518
fi
519+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-app-history-stdout.txt; then
520+
echo "Did not find replicated-app-history-stdout.txt in support bundle"
521+
exit 1
522+
fi
523+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-app-updates-stdout.txt; then
524+
echo "Did not find replicated-app-updates-stdout.txt in support bundle"
525+
exit 1
526+
fi
527+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-app-info-stdout.txt; then
528+
echo "Did not find replicated-app-info-stdout.txt in support bundle"
529+
exit 1
530+
fi
531+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-license-info-stdout.txt; then
532+
echo "Did not find replicated-license-info-stdout.txt in support bundle"
533+
exit 1
534+
fi
519535
rm -rf support-bundle-*
520536
521537
- name: Uninstall test-chart via Helm
@@ -573,6 +589,22 @@ jobs:
573589
echo "Did not find replicated pod logs in support bundle"
574590
exit 1
575591
fi
592+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-app-history-stdout.txt; then
593+
echo "Did not find replicated-app-history-stdout.txt in support bundle"
594+
exit 1
595+
fi
596+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-app-updates-stdout.txt; then
597+
echo "Did not find replicated-app-updates-stdout.txt in support bundle"
598+
exit 1
599+
fi
600+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-app-info-stdout.txt; then
601+
echo "Did not find replicated-app-info-stdout.txt in support bundle"
602+
exit 1
603+
fi
604+
if ! ls support-bundle-*/replicated-sdk/*/*/replicated-license-info-stdout.txt; then
605+
echo "Did not find replicated-license-info-stdout.txt in support bundle"
606+
exit 1
607+
fi
576608
rm -rf support-bundle-*
577609
578610
- name: Uninstall test-chart via kubectl

chart/templates/replicated-supportbundle.yaml

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{/*
2-
Renders the Support Bundle secret to be used by replicated
2+
Renders the Support Bundle secret to be used by replicated
33
*/}}
44
---
55
apiVersion: v1
@@ -18,6 +18,50 @@ stringData:
1818
name: {{ include "replicated.supportBundleName" . }}
1919
spec:
2020
collectors:
21+
- exec:
22+
name: replicated-sdk
23+
collectorName: replicated-app-updates
24+
selector:
25+
{{- range $k, $v := (include "replicated.labels" . | fromYaml) }}
26+
- {{ $k }}={{ $v }}
27+
{{- end }}
28+
namespace: {{ include "replicated.namespace" . }}
29+
command: ["curl"]
30+
args: ["-s", "http://{{ include "replicated.serviceName" . }}.{{ include "replicated.namespace" . }}:3000/api/v1/app/updates"]
31+
timeout: 5s
32+
- exec:
33+
name: replicated-sdk
34+
collectorName: replicated-app-history
35+
selector:
36+
{{- range $k, $v := (include "replicated.labels" . | fromYaml) }}
37+
- {{ $k }}={{ $v }}
38+
{{- end }}
39+
namespace: {{ include "replicated.namespace" . }}
40+
command: ["curl"]
41+
args: ["-s", "http://{{ include "replicated.serviceName" . }}.{{ include "replicated.namespace" . }}:3000/api/v1/app/history"]
42+
timeout: 5s
43+
- exec:
44+
name: replicated-sdk
45+
collectorName: replicated-app-info
46+
selector:
47+
{{- range $k, $v := (include "replicated.labels" . | fromYaml) }}
48+
- {{ $k }}={{ $v }}
49+
{{- end }}
50+
namespace: {{ include "replicated.namespace" . }}
51+
command: ["curl"]
52+
args: ["-s", "http://{{ include "replicated.serviceName" . }}.{{ include "replicated.namespace" . }}:3000/api/v1/app/info"]
53+
timeout: 5s
54+
- exec:
55+
name: replicated-sdk
56+
collectorName: replicated-license-info
57+
selector:
58+
{{- range $k, $v := (include "replicated.labels" . | fromYaml) }}
59+
- {{ $k }}={{ $v }}
60+
{{- end }}
61+
namespace: {{ include "replicated.namespace" . }}
62+
command: ["curl"]
63+
args: ["-s", "http://{{ include "replicated.serviceName" . }}.{{ include "replicated.namespace" . }}:3000/api/v1/license/info"]
64+
timeout: 5s
2165
- logs:
2266
collectorName: replicated-logs
2367
selector:
@@ -26,20 +70,6 @@ stringData:
2670
{{- end }}
2771
namespace: {{ include "replicated.namespace" . | quote }}
2872
name: replicated/logs
29-
- http:
30-
collectorName: replicated-app-info
31-
get:
32-
url: http://{{ include "replicated.serviceName" . }}.{{ include "replicated.namespace" . }}:3000/api/v1/app/info
33-
headers:
34-
User-Agent: "troubleshoot.sh/support-bundle"
35-
timeout: 5s
36-
- http:
37-
collectorName: replicated-license-info
38-
get:
39-
url: http://{{ include "replicated.serviceName" . }}.{{ include "replicated.namespace" . }}:3000/api/v1/license/info
40-
headers:
41-
User-Agent: "troubleshoot.sh/support-bundle"
42-
timeout: 5s
4373
- secret:
4474
namespace: {{ include "replicated.namespace" . | quote }}
4575
name: replicated-instance-report

pkg/handlers/app.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ import (
3131
)
3232

3333
type GetCurrentAppInfoResponse struct {
34-
AppSlug string `json:"appSlug"`
35-
AppName string `json:"appName"`
36-
AppStatus appstatetypes.State `json:"appStatus"`
37-
HelmChartURL string `json:"helmChartURL,omitempty"`
38-
CurrentRelease AppRelease `json:"currentRelease"`
34+
InstanceID string `json:"instanceID"`
35+
AppSlug string `json:"appSlug"`
36+
AppName string `json:"appName"`
37+
AppStatus appstatetypes.State `json:"appStatus"`
38+
HelmChartURL string `json:"helmChartURL,omitempty"`
39+
CurrentRelease AppRelease `json:"currentRelease"`
40+
ChannelID string `json:"channelID"`
41+
ChannelName string `json:"channelName"`
42+
ChannelSequence int64 `json:"channelSequence"`
43+
ReleaseSequence int64 `json:"releaseSequence"`
3944
}
4045

4146
type GetAppHistoryResponse struct {
@@ -79,8 +84,13 @@ func GetCurrentAppInfo(w http.ResponseWriter, r *http.Request) {
7984

8085
if isIntegrationModeEnabled {
8186
response := GetCurrentAppInfoResponse{
82-
AppSlug: store.GetStore().GetAppSlug(),
83-
AppName: store.GetStore().GetAppName(),
87+
InstanceID: store.GetStore().GetAppID(),
88+
AppSlug: store.GetStore().GetAppSlug(),
89+
AppName: store.GetStore().GetAppName(),
90+
ChannelID: store.GetStore().GetChannelID(),
91+
ChannelName: store.GetStore().GetChannelName(),
92+
ChannelSequence: store.GetStore().GetChannelSequence(),
93+
ReleaseSequence: store.GetStore().GetReleaseSequence(),
8494
}
8595

8696
mockData, err := integration.GetMockData(r.Context(), clientset, store.GetStore().GetNamespace())
@@ -102,6 +112,7 @@ func GetCurrentAppInfo(w http.ResponseWriter, r *http.Request) {
102112
}
103113

104114
response := GetCurrentAppInfoResponse{
115+
InstanceID: store.GetStore().GetAppID(),
105116
AppSlug: store.GetStore().GetAppSlug(),
106117
AppName: store.GetStore().GetAppName(),
107118
AppStatus: store.GetStore().GetAppStatus().State,
@@ -111,6 +122,10 @@ func GetCurrentAppInfo(w http.ResponseWriter, r *http.Request) {
111122
CreatedAt: store.GetStore().GetReleaseCreatedAt(),
112123
ReleaseNotes: store.GetStore().GetReleaseNotes(),
113124
},
125+
ChannelID: store.GetStore().GetChannelID(),
126+
ChannelName: store.GetStore().GetChannelName(),
127+
ChannelSequence: store.GetStore().GetChannelSequence(),
128+
ReleaseSequence: store.GetStore().GetReleaseSequence(),
114129
}
115130

116131
if helm.IsHelmManaged() {

pkg/handlers/license.go

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ import (
1515
)
1616

1717
type LicenseInfo struct {
18-
LicenseID string `json:"licenseID"`
19-
ChannelName string `json:"channelName"`
20-
CustomerName string `json:"customerName"`
21-
CustomerEmail string `json:"customerEmail"`
22-
LicenseType string `json:"licenseType"`
18+
LicenseID string `json:"licenseID"`
19+
AppSlug string `json:"appSlug"`
20+
ChannelName string `json:"channelName"`
21+
CustomerName string `json:"customerName"`
22+
CustomerEmail string `json:"customerEmail"`
23+
LicenseType string `json:"licenseType"`
24+
ChannelID string `json:"channelID"`
25+
LicenseSequence int64 `json:"licenseSequence"`
26+
IsAirgapSupported bool `json:"isAirgapSupported"`
27+
IsGitOpsSupported bool `json:"isGitOpsSupported"`
28+
IsIdentityServiceSupported bool `json:"isIdentityServiceSupported"`
29+
IsGeoaxisSupported bool `json:"isGeoaxisSupported"`
30+
IsSnapshotSupported bool `json:"isSnapshotSupported"`
31+
IsSupportBundleUploadSupported bool `json:"isSupportBundleUploadSupported"`
32+
IsSemverRequired bool `json:"isSemverRequired"`
33+
Endpoint string `json:"endpoint"`
34+
Entitlements map[string]kotsv1beta1.EntitlementField `json:"entitlements"`
2335
}
2436

2537
func GetLicenseInfo(w http.ResponseWriter, r *http.Request) {
@@ -97,10 +109,22 @@ func GetLicenseField(w http.ResponseWriter, r *http.Request) {
97109

98110
func licenseInfoFromLicense(license *kotsv1beta1.License) LicenseInfo {
99111
return LicenseInfo{
100-
LicenseID: license.Spec.LicenseID,
101-
ChannelName: license.Spec.ChannelName,
102-
CustomerName: license.Spec.CustomerName,
103-
CustomerEmail: license.Spec.CustomerEmail,
104-
LicenseType: license.Spec.LicenseType,
112+
LicenseID: license.Spec.LicenseID,
113+
AppSlug: license.Spec.AppSlug,
114+
ChannelName: license.Spec.ChannelName,
115+
CustomerName: license.Spec.CustomerName,
116+
CustomerEmail: license.Spec.CustomerEmail,
117+
LicenseType: license.Spec.LicenseType,
118+
ChannelID: license.Spec.ChannelID,
119+
LicenseSequence: license.Spec.LicenseSequence,
120+
IsAirgapSupported: license.Spec.IsAirgapSupported,
121+
IsGitOpsSupported: license.Spec.IsGitOpsSupported,
122+
IsIdentityServiceSupported: license.Spec.IsIdentityServiceSupported,
123+
IsGeoaxisSupported: license.Spec.IsGeoaxisSupported,
124+
IsSnapshotSupported: license.Spec.IsSnapshotSupported,
125+
IsSupportBundleUploadSupported: license.Spec.IsSupportBundleUploadSupported,
126+
IsSemverRequired: license.Spec.IsSemverRequired,
127+
Endpoint: license.Spec.Endpoint,
128+
Entitlements: license.Spec.Entitlements,
105129
}
106130
}

0 commit comments

Comments
 (0)