go-cloud | Go Cloud Development Kit : A library and tools | GCP library
kandi X-RAY | go-cloud Summary
Support
Quality
Security
License
Reuse
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
go-cloud Key Features
go-cloud Examples and Code Snippets
Trending Discussions on go-cloud
Trending Discussions on go-cloud
QUESTION
I am trying to set up Stackdriver debugging using Go. Using the article and this great medium post I came up with this solution.
Key parts, in cloudbuild.yaml
- name: gcr.io/cloud-builders/wget
args: [
"-O",
"go-cloud-debug",
"https://storage.googleapis.com/cloud-debugger/compute-go/go-cloud-debug"
]
...
Dockerfile I have
...
COPY gopath/bin/stackdriver-demo /stackdriver-demo
ADD go-cloud-debug /
ADD source-context.json /
CMD ["/go-cloud-debug","-sourcecontext=./source-context.json", "-appmodule=go-errrep","-appversion=1.0","--","/stackdriver-demo"]
...
However the pods keeps crashing, the container logs show this error:
Error loading program: decoding dwarf section info at offset 0x0: too short
EDIT: Using https://storage.googleapis.com/cloud-debugger/compute-go/go-cloud-debug
may be outdated as I haven't seen it used outside Daz's medium post. The official docs uses the package cloud.google.com/go/cmd/go-cloud-debug-agent
I have update cloudbuild.yaml file to install this package:
- name: 'gcr.io/cloud-builders/go'
args: ["get", "-u", "cloud.google.com/go/cmd/go-cloud-debug-agent"]
env: ['PROJECT_ROOT=github.com/roberson34/stackdriver-demo', 'CGO_ENABLED=0', 'GOOS=linux']
- name: 'gcr.io/cloud-builders/go'
args: ["install", "cloud.google.com/go/cmd/go-cloud-debug-agent"]
env: ['PROJECT_ROOT=github.com/roberson34/stackdriver-demo', 'CGO_ENABLED=0', 'GOOS=linux']
And in the Dockerfile
I can get access to the binary in gopath/bin/go-cloud-debug-agent
When I execute the gopath/bin/go-cloud-debug-agent
with my own program as an argument:
/go-cloud-debug-agent -sourcecontext=./source-context.json -appmodule=go-errrep -appversion=1.0 -- /stackdriver-demo
I get another opaque error:
Error loading program: AttrStmtList not present or not int64 for unit 88
So basically using the cloud-debug
binary from https://storage.googleapis.com/cloud-debugger/compute-go/go-cloud-debug
and cloud-debug-agent
binary from the package cloud.google.com/go/cmd/go-cloud-debug-agent
both don't work and give different errors.
Would appreciate any tips on what I'm doing wrong and how to fix it.
ANSWER
Answered 2019-Apr-03 at 03:12OK :-)
Yes, you should follow the current Stackdriver documentation, e.g. go-cloud-debug-agent
Unfortunately, there are now various issues with my post including a (currently broken) gcr.io/cloud-builders/kubectl
for regions.
I think your issue pertains to your use of golang:alpine
. Alpine uses musl rather than the glibc that you find on most other Linux distro's and so, you really must compile for Alpine to ensure your binaries reference the correct libc.
I'm able to get your solution working primarily by switching your Dockerfile to pull the Cloud Debug Agent while on Alpine and to compile your source on Alpine:
FROM golang:alpine
RUN apk add git
RUN go get -u cloud.google.com/go/cmd/go-cloud-debug-agent
ADD main.go src
RUN CGO_ENABLED=0 go build -gcflags=all='-N -l' src/main.go
ADD source-context.json /
CMD ["bin/go-cloud-debug-agent","-sourcecontext=/source-context.json", "-appmodule=stackdriver-demo","-appversion=1.0","--","main"]
I think that should get you beyond the errors that you documented and you should be able to deploy your container to Kubernetes.
I've made my version of your image publicly available (and will retain it for a few days for you):
gcr.io/dazwilkin-190402-55473323/roberson34@sha256:17cb45f1320e2fe04e0681310506f4c229896429192b0d1c2c8dc20ed54adb0d
You may wish to reference it (by that digest) in your deployment.yaml
NB For Error Reporting to be "interesting", your code needs to generate errors and, with your example, this is going to be challenging (usually a good thing). You may consider adding another errorful handler that always results in errors so that you may test the service.
QUESTION
I'm using container builder to with a cloudbuild.yaml, my problem an old cluster name is being used which doesn't exist. I have tried deleting my service key and creating it again to no avail.
Starting Step #3
Step #3: Already have image (with digest): gcr.io/cloud-builders/kubectl
Step #3: Running: gcloud container clusters get-credentials --project="amx-instance-1" --zone="australia-southeast1-a" "amx-cluster-au9"
Step #3: Fetching cluster endpoint and auth data.
Step #3: ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Required "container.clusters.get" permission(s) for "projects/amx-instance-1/zones/australia-southeast1-a/clusters/amx-cluster-au9". See https://cloud.google.com/kubernetes-engine/docs/troubleshooting#gke_service_account_deleted for more info.
Cluster name amx-cluster-au9
is an old cluster that no longer exist. What is causing this issue and how can I fix it?
edit: cloudbuild.yaml file
steps:
- name: gcr.io/cloud-builders/wget
args: [
"-O",
"go-cloud-debug",
"https://storage.googleapis.com/cloud-debugger/compute-go/go-cloud-debug"
]
- name: 'gcr.io/cloud-builders/go'
args: ["install", "-gcflags=-N", "-gcflags=-l", ".", ]
env: ['PROJECT_ROOT=github.com/amalexpress/amx-server', 'CGO_ENABLED=0', 'GOOS=linux']
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=gcr.io/$PROJECT_ID/amx-img:$SHORT_SHA', '.']
- name: 'gcr.io/cloud-builders/kubectl'
args:
- set
- image
- deployment
- echoserver
- echoserver=gcr.io/$PROJECT_ID/amx-img:$SHORT_SHA
env:
- 'CLOUDSDK_COMPUTE_ZONE=australia-southeast1-a'
- 'CLOUDSDK_CONTAINER_CLUSTER=amx-cluster-au-2'
images: ['gcr.io/$PROJECT_ID/amx-img:$SHORT_SHA']
Basically I don't know why it keeps referencing a cluster that I've deleted and no longer use.
Here are the logs if it might help.
ANSWER
Answered 2019-Feb-21 at 03:56The issue was resolved by deleting the repository in Cloud Source Repository. I have no idea why this fixed the issue. I should note that I deleted the github repo and re-initialised it. Still seems like a bug though as there is no indication of the root cause at all. Furthermore while the above fixed the cluster name issue, I had to follow instructions here to to give proper role access to the cluster:
PROJECT="$(gcloud projects describe \
$(gcloud config get-value core/project -q) --format='get(projectNumber)')"
gcloud projects add-iam-policy-binding $PROJECT \
--member=serviceAccount:$PROJECT@cloudbuild.gserviceaccount.com \
--role=roles/container.developer
QUESTION
I have a list of folders inside a folder in ubuntu. ie. Under /mnt/source/customcode/files/brands/
root@a919794ec280:/mnt/source/customcode/files/brands# ls -la
total 236
drwxrwxrwx 19 1002 root 4096 Jan 3 09:26 .
drwxrwxrwx 8 1002 1003 4096 Dec 27 22:45 ..
drwxrwxr-x 3 1002 1003 4096 Jan 3 09:22 aem
drwxrwxr-x 3 1002 1003 4096 Jan 3 09:22 apple
drwxrwxr-x 3 1002 1003 4096 Jan 3 09:22 cool
drwxr-xr-x 3 1002 root 4096 Jan 3 09:22 doll
drwxr-xr-x 3 1002 root 4096 Jan 3 09:22 ent
drwxr-xr-x 3 1002 root 4096 Jan 3 09:22 f1
drwxr-xr-x 3 1002 root 4096 Jan 3 09:22 google
drwxrwxrwx 3 1002 root 4096 Jan 3 09:22 h1
drwxrwxr-x 3 1002 1003 4096 Jan 3 09:22 iq
drwxr-xr-x 3 1002 root 4096 Jan 3 09:22 king
drwxrwxrwx 3 root root 4096 Jan 3 09:22 link
drwxrwxrwx 3 1002 root 155648 Jan 3 09:22 nobrand
drwxrwxr-x 3 1002 1003 12288 Jan 3 09:22 pepperfry
drwxrwxrwx 2 1002 root 4096 Jan 3 09:22 pepsi
drwxrwxr-x 2 1002 1003 4096 Jan 3 09:22 rock
drwxrwxrwx 2 1002 root 4096 Jan 3 09:22 star9
drwxrwxr-x 2 1002 1003 4096 Jan 3 09:22 vicks
----- 100+ -----
Like above, I have folders like "a1", "cola", "link" and etc. (more then 100 folders)
In side those each folders there will be a folder named "data_aug" and "data_aug" folder do contain files inside.
root@a919794ec280:/mnt/source/customcode/files/brands/apple# ls -la
total 1988
drwxrwxr-x 3 1002 1003 4096 Jan 3 09:22 .
drwxrwxrwx 19 1002 root 4096 Jan 3 09:26 ..
-rw-r--r-- 1 1002 1003 17465 Dec 29 23:28 0DPA0C3.jpg
-rw-r--r-- 1 1002 1003 3836 Dec 31 00:55 130418131111-apple-store-santa-monica.jpg
-rw-r--r-- 1 1002 1003 48616 Dec 31 00:52 15146774227434507677123475441338.jpg
-rw-r--r-- 1 1002 1003 9107 Dec 31 00:52 15146774615326659565665852728294.jpg
-rw-r--r-- 1 1002 1003 28005 Dec 29 23:28 3D-Apple-Logo-Wallpapers.jpg
-rw-r--r-- 1 1002 1003 75855 Dec 29 23:28 3D-Apple-Logo.jpg
-rw-r--r-- 1 1002 1003 27403 Dec 29 23:28 3d_apple_logo___wallpaper_by_techflashdesigns-d4fbc7p.jpg
-rw-r--r-- 1 1002 1003 38420 Dec 29 23:28 AX62GjL.jpg
-rw-r--r-- 1 1002 1003 6025 Dec 29 23:28 Apple-Logo-2016 (1).jpg
-rw-r--r-- 1 1002 1003 929419 Dec 29 23:28 Apple-Logo-Png-Download.png
-rw-r--r-- 1 1002 1003 35742 Dec 29 23:28 apple-logo-2016.jpg
-rw-r--r-- 1 1002 1003 15301 Dec 29 23:28 apple-logo-3d-model-max-obj-fbx-3dm-ige-igs-iges.jpg
-rw-r--r-- 1 1002 1003 42514 Dec 29 23:28 apple-logo-clipart-2.jpeg
-rw-r--r-- 1 1002 1003 152183 Dec 29 23:28 apple-logo-clouds.jpg
-rw-r--r-- 1 1002 1003 6117 Dec 31 00:55 apple1.jpg
-rw-r--r-- 1 1002 1003 349787 Dec 29 23:28 apple_ipad_logo.png
-rw-r--r-- 1 1002 1003 54167 Dec 29 23:28 b5c4d6c9-3.jpg
drwxr-xr-x 2 root root 4096 Jan 3 09:22 data_aug
-rw-r--r-- 1 1002 1003 32918 Dec 29 23:28 large.JPG
-rw-r--r-- 1 1002 1003 48972 Dec 29 23:28 medium.jpg
-rw-r--r-- 1 1002 1003 3609 Dec 29 23:28 th (1).jpeg
-rw-r--r-- 1 1002 1003 30392 Dec 29 23:28 th (2).jpeg
-rw-r--r-- 1 1002 1003 3222 Dec 29 23:28 th.jpeg
-rw-r--r-- 1 1002 1003 22544 Dec 29 23:28 u5TAcBk.jpg
root@a919794ec280:/mnt/source/customcode/files/brands/apple/data_aug# ls -la
total 4356
drwxr-xr-x 2 root root 12288 Jan 3 09:41 .
drwxrwxr-x 3 1002 1003 4096 Jan 3 09:22 ..
-rw-r--r-- 1 root root 10450 Jan 3 09:40 apple_0_1.jpeg
-rw-r--r-- 1 root root 5599 Jan 3 09:40 apple_0_1019.jpeg
-rw-r--r-- 1 root root 3225 Jan 3 09:40 apple_0_1075.jpeg
-rw-r--r-- 1 root root 10283 Jan 3 09:40 apple_0_1100.jpeg
-rw-r--r-- 1 root root 13923 Jan 3 09:41 apple_0_1119.jpeg
Now...
I need a script to be placed in "/mnt/source/customcode/"
Want to run the script from "/mnt/source/customcode/" as my script dependent files are can only be executed from "/mnt/source/customcode/"to achieve bellow.
Delete the folder "data_aug" and the data inside "data_aug" recursively from all the 100 folders.
Then from the "/mnt/source/customcode/" location I should execute a
special script which, it will refer those 100 folders. like example
below.
Code...
python -m scripts.augmentation_keras --image_dir=files/brands/apple --target_dir=files/brands/apple/data_aug --save_prefix=apple
python -m scripts.augmentation_keras --image_dir=files/brands/a1 --target_dir=files/brands/a1/data_aug --save_prefix=a1
like above for all the 100 folders. The number of folders 100 will grow more in future.
How can I do it dynamically instead of writing simple script with hundreds of lines (static deletion and execution)!
Thanks.
ANSWER
Answered 2018-Jan-03 at 07:24Probably something like this:
for d in /home/user/data/*
do
rm -rf $d/content/*
python -m scripts.augmentation_keras --image_dir=$d --
target_dir=$d/content --save_prefix=$(basename $d)
done
QUESTION
currently I'm thinking of the way to load statics into my Ember app. The problem:
I have app branded logo, app name, app title (browser tab label), texts for routes etc. What I'm doing now is the following:
model() {
let defaultHeaderModel = {
logo: '/img/logo-cloud.svg',
brand: {
name: 'CloudCenter',
logo: '/img/logo-cloud.svg'
},
userLinks: [{
text: 'Logout',
route: 'logout'
}],
navigation: [{
text: 'Login',
route: 'login'
}]
};
}
As you can see all of the values are hardcoded. What I'd like to do is to somehow load that "statics" and use them through some variables. For ex: header.logo = resources.logo
. My thoughts:
1) Use environment
- store all of that values in the config.js
and import
it where needed. Cons: not sure if that data belongs to environment
2) ES6 POJO which can be imported to the app.
3) .json
and some staticsService
which will load .json
file and through it I will have access to that values.
Are there any standardized approach to do such things? Or maybe better suggestions?
ANSWER
Answered 2017-May-18 at 05:23You can create service, and have method(loadData) which will return Promise and will be resolved with your JSON data and update property in service. You need to call loadData
in beforeModel hook, after the all the promises resolved only then it will move to model hook.
Refer twiddle basic demonstration
services/my-service.js
import Ember from 'ember';
export default Ember.Service.extend({
defaultHeaderModel:{},
loadData(){
var myServiceDataLoadPromise = Ember.RSVP.Promise.resolve({one:1});
myServiceDataLoadPromise.then(result =>{
this.set('defaultHeaderModel',result);
});
return myServiceDataLoadPromise;
}
});
routes/application.js
inside beforeModel hook, you can load service with data, it can be done any of the route which requires data.
import Ember from 'ember';
export default Ember.Route.extend({
myService: Ember.inject.service(),
beforeModel()
{
return Ember.RSVP.all([this.get('myService').loadData()]);
}
});
controllers/application.js
import Ember from 'ember';
export default Ember.Controller.extend({
myService: Ember.inject.service(),
appName: 'Ember Twiddle'
});
templates/application.hbs
{{myService.defaultHeaderModel.one}}
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install go-cloud
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page