Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Ship release troubleshoot specs #981

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"upstreamContents": {
"appRelease": {
"id": "NyhODuspYvV9pTHlmMt20KAxbMAE8swq",
"sequence": 0,
"sequence": 2971,
"channelId": "iEKGvV-NI-i6uFS89JAbdJCzAXP1b7wr",
"channelName": "integration replicated.app amazon-eks-template",
"channelIcon": "",
Expand Down
2 changes: 1 addition & 1 deletion integration/init_app/basic/expected/.ship/state.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"upstreamContents": {
"appRelease": {
"id": "pAb_dFxe4M4TdvkPWSdgDhgtpDbOcGAM",
"sequence": 0,
"sequence": 4603,
"channelId": "lD4lzjnjwOYzKbNsjK0JlcpzF19PswXz",
"channelName": "integration replicated.app basic",
"channelIcon": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"upstreamContents": {
"appRelease": {
"id": "jDtI-DiraCbkN5euJHmbS3kIFw4N1Iw9",
"sequence": 0,
"sequence": 9091,
"channelId": "_KVsR5SFu9Rj2IR6dxPhuBYcNIKtw6SI",
"channelName": "integration-test-docker",
"channelIcon": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"upstreamContents": {
"appRelease": {
"id": "ZibGNlJOl0RbgXiFKk358iGVL8lFOn26",
"sequence": 0,
"sequence": 9073,
"channelId": "M2JHDvnDhJbrDNRBQ1m-eEDRXbPiSLg9",
"channelName": "integration replicated.app github-template-func",
"channelIcon": "",
Expand Down
2 changes: 1 addition & 1 deletion integration/init_app/helm-github/expected/.ship/state.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"upstreamContents": {
"appRelease": {
"id": "cZB0VTZLBexn0s53sMzVB0Id3VvSPcCZ",
"sequence": 0,
"sequence": 6060,
"channelId": "t_qVrkESBiqOa8ZraseeS38bXy-qgpSe",
"channelName": "integration replicated.app helm-github",
"channelIcon": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"upstreamContents": {
"appRelease": {
"id": "VFOvxrc3Bpu1doy2AtFGoypU6skZvXSZ",
"sequence": 0,
"sequence": 6680,
"channelId": "PH6juE8b84A4zOCO-SVzVNS_OHs-LEl3",
"channelName": "integration replicated.app installation-template-func",
"channelIcon": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ entitlements:
- key: entitlements.replicated.com/type
value: number
utilizations: []
collectSpec: ""
analyzeSpec: ""
type: replicated.app
license:
id: hLHawMDiyQIeFS7kqVFtD2f44LNh8u5Z
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

---
# assets are everything an end customer needs to deploy your application, like
#
# - kubernetes or docker-compose manifests
# - installation scripts
# - modules for ansible/chef/puppet
# - private docker images
# - compiled artifacts and binaries
#
# assets will be templated using customer-supplied
# install info from the "config" section (below)
assets:
v1:
# "inline" can be used to supply assets directly in the spec
- inline:
contents: |
#!/bin/bash
echo "applying kuberentes configs"
kubectl apply -f ./k8s/* -n {{repl ConfigOption "k8s_namespace" }}
dest: ./scripts/install.sh
mode: 0777
# "inline" can be used to supply assets directly in the spec
- inline:
contents: |
#!/bin/bash
set -e
kubectl get namespace {{repl ConfigOption "k8s_namespace" }} | wc -l
echo "? Namespace Created"
dest: ./scripts/test.sh
mode: 0777

# Config defines the configuration options available to your application.
# Values supplied by the end customer will be used during asset generation.
config:
v1:
- name: cluster_info
title: Kubernetes Cluster Info
description: information about your kubernetes cluster
items:
- name: k8s_namespace
title: Namespace to Deploy into
type: text
- name: worker_replicas
title: Number of Workers to Deploy
type: text

# Lifecycle allows you to customize the messaging and workflow for your end customer
# when they are generating assets. Currently the two support lifecycle steps are
#
# - message -- prints a message
# - render -- collects config and generates assets
lifecycle:
v1:
- message:
contents: |
This tool will prepare assets so you can deploy SuperGoodTool-Enterpise
to your existing Kubernetes cluster
- render: {}
- message:
contents: |
SuperGoodTool is ready to deploy to your kubernetes cluster.

If you have kubectl configured locally, you can
run the following command to deploy SuperGoodTool to
your kubernetes cluster:

bash ./scripts/install.sh

To upgrade an existing installation, use

bash ./scripts/upgrade.sh

To uninstall SuperGoodTool, run

bash ./scripts/uninstall.sh
- message:
level: warn
contents: |
A state file has been written to {{repl context "state_file_path" }} -- please store it
somewhere safe, you'll need it if you want to recover or update this installation of SuperGoodTool.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"v1": {
"config": {},
"upstream": "__upstream__",
"contentSHA": "71dd296d8fae1f07f66b05d2e12710eb58bd7725d55093e41b6501b592418b31",
"metadata": {
"applicationType": "replicated.app",
"customerID": "__customerID__",
"installationID": "__installationID__",
"license": {
"assignee": "",
"createdAt": "0001-01-01T00:00:00Z",
"expiresAt": "0001-01-01T00:00:00Z",
"id": "",
"type": ""
},
"releaseNotes": "",
"sequence": 0,
"version": "0.0.1"
},
"releaseName": "stable",
"upstreamContents": {
"appRelease": {
"id": "J6APm7ozSXsvq7DvBpXe0V2Ck3Il7c6K",
"sequence": 2,
"channelId": "c-uuoWhpOVAhShsdYnfoNk-v2kYOEpHq",
"channelName": "Stable",
"channelIcon": "",
"semver": "0.0.1",
"releaseNotes": "",
"spec": "\n---\n# assets are everything an end customer needs to deploy your application, like\n#\n# - kubernetes or docker-compose manifests\n# - installation scripts\n# - modules for ansible/chef/puppet\n# - private docker images\n# - compiled artifacts and binaries\n#\n# assets will be templated using customer-supplied\n# install info from the \"config\" section (below)\nassets:\n v1:\n # \"inline\" can be used to supply assets directly in the spec\n - inline:\n contents: |\n #!/bin/bash\n echo \"applying kuberentes configs\"\n kubectl apply -f ./k8s/* -n {{repl ConfigOption \"k8s_namespace\" }}\n dest: ./scripts/install.sh\n mode: 0777\n # \"inline\" can be used to supply assets directly in the spec\n - inline:\n contents: |\n #!/bin/bash\n set -e\n kubectl get namespace {{repl ConfigOption \"k8s_namespace\" }} | wc -l\n echo \"? Namespace Created\"\n dest: ./scripts/test.sh\n mode: 0777\n\n# Config defines the configuration options available to your application.\n# Values supplied by the end customer will be used during asset generation.\nconfig:\n v1:\n - name: cluster_info\n title: Kubernetes Cluster Info\n description: information about your kubernetes cluster\n items:\n - name: k8s_namespace\n title: Namespace to Deploy into\n type: text\n - name: worker_replicas\n title: Number of Workers to Deploy\n type: text\n\n# Lifecycle allows you to customize the messaging and workflow for your end customer\n# when they are generating assets. Currently the two support lifecycle steps are\n#\n# - message -- prints a message\n# - render -- collects config and generates assets\nlifecycle:\n v1:\n - message:\n contents: |\n This tool will prepare assets so you can deploy SuperGoodTool-Enterpise\n to your existing Kubernetes cluster\n - render: {}\n - message:\n contents: |\n SuperGoodTool is ready to deploy to your kubernetes cluster.\n\n If you have kubectl configured locally, you can\n run the following command to deploy SuperGoodTool to\n your kubernetes cluster:\n\n bash ./scripts/install.sh\n\n To upgrade an existing installation, use\n\n bash ./scripts/upgrade.sh\n\n To uninstall SuperGoodTool, run\n\n bash ./scripts/uninstall.sh\n - message:\n level: warn\n contents: |\n A state file has been written to {{repl context \"state_file_path\" }} -- please store it\n somewhere safe, you'll need it if you want to recover or update this installation of SuperGoodTool.\n ",
"images": [],
"githubContents": [],
"created": "Wed Jun 19 2019 23:57:55 GMT+0000 (UTC)",
"registrySecret": "THIS IS NOT A SECRET",
"entitlements": {},
"collectSpec": "collect:\n v1:\n - docker.info:\n output_dir: /docker/info\n - docker.ps:\n output_dir: /docker/ps\n - docker.container-inspect:\n output_dir: /docker/my-container\n container_list_options:\n All: true\n Filters:\n name:\n - \"my-sweet-container\"\n \n\n - kubernetes.version:\n output_dir: /k8s/version\n - kubernetes.cluster-info:\n output_dir: /k8s/cluster\n \n\n - os.loadavg:\n output_dir: /os/loadavg\n - os.hostname:\n output_dir: /os/hostname\n - os.uptime:\n output_dir: /os/uptime\n - os.run-command:\n output_dir: /os/df\n name: df\n args:\n - -h\n - --total\n - os.run-command:\n output_dir: /os/proc/meminfo\n name: cat\n args:\n - /proc/meminfo\n - os.run-command:\n output_dir: /os/proc/cpuinfo\n name: cat\n args:\n - /proc/cpuinfo\n - os.run-command:\n output_dir: /os/ps\n name: ps\n args:\n - auwwf\n - os.read-file:\n filepath: /etc/os-release\n output_dir: /os/etc/os-release\n - os.read-file:\n filepath: /usr/lib/os-release\n output_dir: /os/usr/lib/os-release\n - os.read-file:\n filepath: /etc/centos-release\n output_dir: /os/etc/centos-release\n \n\n - docker.container-inspect:\n output_dir: /replicated/replicated/inspect\n container_list_options:\n All: true\n Filters:\n name:\n - \"replicated\"\n - \"retraced\"\n - \"premkit\"\n\n - docker.logs:\n output_dir: /replicated/replicated/logs\n container_list_options:\n All: true\n Filters:\n name:\n - \"replicated\"\n - \"retraced\"\n - \"premkit\"\n ",
"analyzeSpec": "analyze:\n v1:\n - name: replicated.api.ok\n labels:\n iconKey: gray_checkmark\n registerVariables:\n - name: replicatedApiIoTimeout\n fileMatch:\n pathRegexps:\n - /replicated\\.log\n - /replicated\\.stderr\n regexpCapture:\n regexp: 'Get https://api\\.replicated\\.com.+ dial tcp .+ i/o timeout'\n index: 0\n scannable: true\n evaluateConditions:\n - condition:\n empty: {}\n variableRef: replicatedApiIoTimeout\n insightOnFalse:\n primary: api.replicated.com i/o timeout\n detail: Cannot access Replicated APIs at api.replicated.com\n severity: error\n labels:\n iconKey: gray_checkmark\n insight:\n primary: Can access api.replicated.com!\n detail: Can access Replicated APIs at api.replicated.com\n severity: info\n"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
echo "applying kuberentes configs"
kubectl apply -f ./k8s/* -n
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e
kubectl get namespace | wc -l
echo "? Namespace Created"
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

---
# assets are everything an end customer needs to deploy your application, like
#
# - kubernetes or docker-compose manifests
# - installation scripts
# - modules for ansible/chef/puppet
# - private docker images
# - compiled artifacts and binaries
#
# assets will be templated using customer-supplied
# install info from the "config" section (below)
assets:
v1:
# "inline" can be used to supply assets directly in the spec
- inline:
contents: |
#!/bin/bash
echo "applying kuberentes configs"
kubectl apply -f ./k8s/* -n {{repl ConfigOption "k8s_namespace" }}
dest: ./scripts/install.sh
mode: 0777
# "inline" can be used to supply assets directly in the spec
- inline:
contents: |
#!/bin/bash
set -e
kubectl get namespace {{repl ConfigOption "k8s_namespace" }} | wc -l
echo "? Namespace Created"
dest: ./scripts/test.sh
mode: 0777

# Config defines the configuration options available to your application.
# Values supplied by the end customer will be used during asset generation.
config:
v1:
- name: cluster_info
title: Kubernetes Cluster Info
description: information about your kubernetes cluster
items:
- name: k8s_namespace
title: Namespace to Deploy into
type: text
- name: worker_replicas
title: Number of Workers to Deploy
type: text

# Lifecycle allows you to customize the messaging and workflow for your end customer
# when they are generating assets. Currently the two support lifecycle steps are
#
# - message -- prints a message
# - render -- collects config and generates assets
lifecycle:
v1:
- message:
contents: |
This tool will prepare assets so you can deploy SuperGoodTool-Enterpise
to your existing Kubernetes cluster
- render: {}
- message:
contents: |
SuperGoodTool is ready to deploy to your kubernetes cluster.

If you have kubectl configured locally, you can
run the following command to deploy SuperGoodTool to
your kubernetes cluster:

bash ./scripts/install.sh

To upgrade an existing installation, use

bash ./scripts/upgrade.sh

To uninstall SuperGoodTool, run

bash ./scripts/uninstall.sh
- message:
level: warn
contents: |
A state file has been written to {{repl context "state_file_path" }} -- please store it
somewhere safe, you'll need it if you want to recover or update this installation of SuperGoodTool.
4 changes: 4 additions & 0 deletions integration/init_app/troubleshoot-ship-release/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
customer_id: "P7ZaX8lzopcELuixPoTbh-UThdinWtgI"
installation_id: "AChUdCBo3capTK3fVHpo2dPGvsmkh31D"
release_version: "0.0.1"
skip_cleanup: false
2 changes: 1 addition & 1 deletion integration/update/app_basic/expected/.ship/state.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"upstreamContents": {
"appRelease": {
"id": "pAb_dFxe4M4TdvkPWSdgDhgtpDbOcGAM",
"sequence": 0,
"sequence": 4603,
"channelId": "lD4lzjnjwOYzKbNsjK0JlcpzF19PswXz",
"channelName": "integration replicated.app basic",
"channelIcon": "",
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ type ReleaseMetadata struct {
GithubContents []GithubContent `json:"githubContents" yaml:"githubContents" hcl:"githubContents" meta:"githubContents"`
ShipAppMetadata ShipAppMetadata `json:"shipAppMetadata" yaml:"shipAppMetadata" hcl:"shipAppMetadata" meta:"shipAppMetadata"`
Entitlements Entitlements `json:"entitlements" yaml:"entitlements" hcl:"entitlements" meta:"entitlements"`
CollectSpec string `json:"collectSpec" yaml:"collectSpec" hcl:"collectSpec" meta:"collectSpec"`
AnalyzeSpec string `json:"analyzeSpec" yaml:"analyzeSpec" hcl:"analyzeSpec" meta:"analyzeSpec"`
Type string `json:"type" yaml:"type" hcl:"type" meta:"type"`
License License `json:"license" yaml:"license" hcl:"license" meta:"license"`
}
Expand Down
66 changes: 15 additions & 51 deletions pkg/specs/replicatedapp/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,7 @@ import (
"github.com/spf13/viper"
)

const GetAppspecQuery = `
query($semver: String) {
shipRelease (semver: $semver) {
id
channelId
channelName
channelIcon
semver
releaseNotes
spec
images {
url
source
appSlug
imageKey
}
githubContents {
repo
path
ref
files {
name
path
sha
size
data
}
}
entitlements {
values {
key
value
labels {
key
value
}
}
meta {
customerID
lastUpdated
}
signature
}
created
registrySecret
}
}`

const GetSlugAppSpecQuery = `
query($appSlug: String!, $licenseID: String, $releaseID: String, $semver: String) {
shipSlugRelease (appSlug: $appSlug, licenseID: $licenseID, releaseID: $releaseID, semver: $semver) {
const ShipRelease = `
id
sequence
channelId
Expand Down Expand Up @@ -117,6 +67,20 @@ query($appSlug: String!, $licenseID: String, $releaseID: String, $semver: String
}
created
registrySecret
collectSpec
analyzeSpec`

const GetAppspecQuery = `
query($semver: String) {
shipRelease (semver: $semver) {
` + ShipRelease + `
}
}`

const GetSlugAppSpecQuery = `
query($appSlug: String!, $licenseID: String, $releaseID: String, $semver: String) {
shipSlugRelease (appSlug: $appSlug, licenseID: $licenseID, releaseID: $releaseID, semver: $semver) {
` + ShipRelease + `
}
}`

Expand Down
4 changes: 4 additions & 0 deletions pkg/state/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ type ShipRelease struct {
Created string `json:"created"` // TODO: this time is not in RFC 3339 format
RegistrySecret string `json:"registrySecret,omitempty"`
Entitlements api.Entitlements `json:"entitlements,omitempty"`
CollectSpec string `json:"collectSpec,omitempty"`
AnalyzeSpec string `json:"analyzeSpec,omitempty"`
}

// ToReleaseMeta linter
Expand All @@ -320,6 +322,8 @@ func (r *ShipRelease) ToReleaseMeta() api.ReleaseMetadata {
Images: r.apiImages(),
GithubContents: r.githubContents(),
Entitlements: r.Entitlements,
CollectSpec: r.CollectSpec,
AnalyzeSpec: r.AnalyzeSpec,
}
}

Expand Down