Merge pull request #12158 from eparis/godeps

Auto commit by PR queue bot
This commit is contained in:
Alex Mohr
2015-08-04 15:57:42 -07:00
45 changed files with 356 additions and 1354 deletions

35
Godeps/Godeps.json generated
View File

@@ -21,7 +21,7 @@
}, },
{ {
"ImportPath": "code.google.com/p/google-api-go-client/compute/v1", "ImportPath": "code.google.com/p/google-api-go-client/compute/v1",
"Comment": "release-96", "Comment": "release-105",
"Rev": "98c78185197025f935947caac56a7b6d022f89d2" "Rev": "98c78185197025f935947caac56a7b6d022f89d2"
}, },
{ {
@@ -31,7 +31,7 @@
}, },
{ {
"ImportPath": "code.google.com/p/google-api-go-client/googleapi", "ImportPath": "code.google.com/p/google-api-go-client/googleapi",
"Comment": "release-96", "Comment": "release-105",
"Rev": "98c78185197025f935947caac56a7b6d022f89d2" "Rev": "98c78185197025f935947caac56a7b6d022f89d2"
}, },
{ {
@@ -195,7 +195,7 @@
}, },
{ {
"ImportPath": "github.com/docker/spdystream", "ImportPath": "github.com/docker/spdystream",
"Rev": "83ae67e694a4ab5cbaee4d3126f25118712b26e6" "Rev": "b2c3287865f3ad6aa22821ddb7b4692b896ac207"
}, },
{ {
"ImportPath": "github.com/elazarl/go-bindata-assetfs", "ImportPath": "github.com/elazarl/go-bindata-assetfs",
@@ -212,7 +212,6 @@
}, },
{ {
"ImportPath": "github.com/fsouza/go-dockerclient", "ImportPath": "github.com/fsouza/go-dockerclient",
"Comment": "0.2.1-532-g2f1ad24",
"Rev": "2f1ad24900b2777139b5becee93eb63a75b00617" "Rev": "2f1ad24900b2777139b5becee93eb63a75b00617"
}, },
{ {
@@ -395,31 +394,31 @@
}, },
{ {
"ImportPath": "github.com/mesos/mesos-go/detector", "ImportPath": "github.com/mesos/mesos-go/detector",
"Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c"
}, },
{ {
"ImportPath": "github.com/mesos/mesos-go/executor", "ImportPath": "github.com/mesos/mesos-go/executor",
"Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c"
}, },
{ {
"ImportPath": "github.com/mesos/mesos-go/mesosproto", "ImportPath": "github.com/mesos/mesos-go/mesosproto",
"Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c"
}, },
{ {
"ImportPath": "github.com/mesos/mesos-go/mesosutil", "ImportPath": "github.com/mesos/mesos-go/mesosutil",
"Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c"
}, },
{ {
"ImportPath": "github.com/mesos/mesos-go/messenger", "ImportPath": "github.com/mesos/mesos-go/messenger",
"Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c"
}, },
{ {
"ImportPath": "github.com/mesos/mesos-go/scheduler", "ImportPath": "github.com/mesos/mesos-go/scheduler",
"Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c"
}, },
{ {
"ImportPath": "github.com/mesos/mesos-go/upid", "ImportPath": "github.com/mesos/mesos-go/upid",
"Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c"
}, },
{ {
"ImportPath": "github.com/miekg/dns", "ImportPath": "github.com/miekg/dns",
@@ -440,7 +439,7 @@
}, },
{ {
"ImportPath": "github.com/onsi/gomega", "ImportPath": "github.com/onsi/gomega",
"Comment": "v1.0-28-g8adf9e1730c5", "Comment": "v1.0-28-g8adf9e1",
"Rev": "8adf9e1730c55cdc590de7d49766cb2acc88d8f2" "Rev": "8adf9e1730c55cdc590de7d49766cb2acc88d8f2"
}, },
{ {
@@ -501,6 +500,7 @@
}, },
{ {
"ImportPath": "github.com/spf13/pflag", "ImportPath": "github.com/spf13/pflag",
"Comment": "v0.0.1-44-gb91b2a9",
"Rev": "b91b2a94780f4e6b4d3b0c12fd9b5f4b05b1aa45" "Rev": "b91b2a94780f4e6b4d3b0c12fd9b5f4b05b1aa45"
}, },
{ {
@@ -509,19 +509,22 @@
}, },
{ {
"ImportPath": "github.com/stretchr/testify/assert", "ImportPath": "github.com/stretchr/testify/assert",
"Comment": "v1.0-17-g089c718",
"Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff"
}, },
{ {
"ImportPath": "github.com/stretchr/testify/mock", "ImportPath": "github.com/stretchr/testify/mock",
"Comment": "v1.0-17-g089c718",
"Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff"
}, },
{ {
"ImportPath": "github.com/stretchr/testify/require", "ImportPath": "github.com/stretchr/testify/require",
"Comment": "v1.0-17-g089c718",
"Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff"
}, },
{ {
"ImportPath": "github.com/syndtr/gocapability/capability", "ImportPath": "github.com/syndtr/gocapability/capability",
"Rev": "3c85049eaeb429febe7788d9c7aac42322a377fe" "Rev": "2c00daeb6c3b45114c80ac44119e7b8801fdd852"
}, },
{ {
"ImportPath": "github.com/ugorji/go/codec", "ImportPath": "github.com/ugorji/go/codec",
@@ -552,11 +555,6 @@
"ImportPath": "golang.org/x/net/html", "ImportPath": "golang.org/x/net/html",
"Rev": "cbcac7bb8415db9b6cb4d1ebab1dc9afbd688b97" "Rev": "cbcac7bb8415db9b6cb4d1ebab1dc9afbd688b97"
}, },
{
"ImportPath": "golang.org/x/net/spdy",
"Comment": "deleted-upstream",
"Rev": "d175081df37eff8cda13f478bc11a0a65b39958b"
},
{ {
"ImportPath": "golang.org/x/net/websocket", "ImportPath": "golang.org/x/net/websocket",
"Rev": "cbcac7bb8415db9b6cb4d1ebab1dc9afbd688b97" "Rev": "cbcac7bb8415db9b6cb4d1ebab1dc9afbd688b97"
@@ -575,6 +573,7 @@
}, },
{ {
"ImportPath": "gopkg.in/natefinch/lumberjack.v2", "ImportPath": "gopkg.in/natefinch/lumberjack.v2",
"Comment": "v1.0-16-g20b71e5",
"Rev": "20b71e5b60d756d3d2f80def009790325acc2b23" "Rev": "20b71e5b60d756d3d2f80def009790325acc2b23"
}, },
{ {

View File

@@ -1,10 +0,0 @@
# This is the official list of authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS files.
# See the latter for an explanation.
# Names should be added to this file as
# Name or Organization <email address>
# The email address is not required for organizations.
# Please keep the list sorted.
Google Inc.

View File

@@ -1,46 +0,0 @@
# This is the official list of people who can contribute
# (and typically have contributed) code to the repository.
# The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
# The submission process automatically checks to make sure
# that people submitting code are listed in this file (by email address).
#
# Names should be added to this file only after verifying that
# the individual or the individual's organization has agreed to
# the appropriate Contributor License Agreement, found here:
#
# http://code.google.com/legal/individual-cla-v1.0.html
# http://code.google.com/legal/corporate-cla-v1.0.html
#
# The agreement for individuals can be filled out on the web.
#
# When adding J Random Contributor's name to this file,
# either J's name or J's organization's name should be
# added to the AUTHORS file, depending on whether the
# individual or corporate CLA was used.
# Names should be added to this file like so:
# Name <email address>
#
# An entry with two email addresses specifies that the
# first address should be used in the submit logs and
# that the second address should be recognized as the
# same person when interacting with Rietveld.
# Please keep the list sorted.
Alain Vongsouvanhalainv <alainv@google.com>
Andrew Gerrand <adg@golang.org>
Brad Fitzpatrick <bradfitz@golang.org>
Francesc Campoy <campoy@golang.org>
Garrick Evans <garrick@google.com>
Glenn Lewis <gmlewis@google.com>
Ivan Krasin <krasin@golang.org>
Jason Hall <jasonhall@google.com>
Johan Euphrosine <proppy@google.com>
Kostik Shtoyk <kostik@google.com>
Nick Craig-Wood <nickcw@gmail.com>
Scott Van Woudenberg <scottvw@google.com>
Takashi Matsuo <tmatsuo@google.com>

View File

@@ -1,27 +0,0 @@
Copyright (c) 2011 Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,9 +0,0 @@
all:
go install code.google.com/p/google-api-go-client/googleapi
go install code.google.com/p/google-api-go-client/google-api-go-generator
$(GOPATH)/bin/google-api-go-generator -cache=false -install -api=*
cached:
go install code.google.com/p/google-api-go-client/googleapi
go install code.google.com/p/google-api-go-client/google-api-go-generator
$(GOPATH)/bin/google-api-go-generator -cache=true -install -api=*

View File

@@ -1,13 +0,0 @@
Discovery Service:
http://code.google.com/apis/discovery/
http://code.google.com/apis/discovery/v1/reference.html
The "type" key:
http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1
The "format" key:
http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23
http://code.google.com/apis/discovery/v1/reference.html#parameter-format-summary
Google JSON format docs:
http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml

View File

@@ -1,10 +0,0 @@
Most of this project is auto-generated.
The notable directories which are not auto-generated:
google-api-go-generator/ -- the generator itself
google-api/ -- shared common code, used by auto-generated code
examples/ -- sample code
When changing the generator, re-compile all APIs and submit the
modified APIs in the same CL as the generator changes itself.

View File

@@ -1,2 +0,0 @@
Moved to:
http://code.google.com/p/google-api-go-client/issues/

View File

@@ -72,4 +72,4 @@ func TestHandlers(t *testing.T) {
// exactly the same as the one that was registered earlier // exactly the same as the one that was registered earlier
handlers[0].ServeHTTP(response, (*http.Request)(nil), nil) handlers[0].ServeHTTP(response, (*http.Request)(nil), nil)
expect(t, response.Code, http.StatusOK) expect(t, response.Code, http.StatusOK)
} }

View File

@@ -49,6 +49,7 @@ var capabilityList = map[string]capability.Cap{
"SETFCAP": capability.CAP_SETFCAP, "SETFCAP": capability.CAP_SETFCAP,
"WAKE_ALARM": capability.CAP_WAKE_ALARM, "WAKE_ALARM": capability.CAP_WAKE_ALARM,
"BLOCK_SUSPEND": capability.CAP_BLOCK_SUSPEND, "BLOCK_SUSPEND": capability.CAP_BLOCK_SUSPEND,
"AUDIT_READ": capability.CAP_AUDIT_READ,
} }
func newCapWhitelist(caps []string) (*whitelist, error) { func newCapWhitelist(caps []string) (*whitelist, error) {

View File

@@ -9,7 +9,7 @@ import (
"sync" "sync"
"time" "time"
"golang.org/x/net/spdy" "github.com/docker/spdystream/spdy"
) )
var ( var (
@@ -593,6 +593,11 @@ func (s *Connection) remoteStreamFinish(stream *Stream) {
// the stream Wait or WaitTimeout function on the stream returned // the stream Wait or WaitTimeout function on the stream returned
// by this function. // by this function.
func (s *Connection) CreateStream(headers http.Header, parent *Stream, fin bool) (*Stream, error) { func (s *Connection) CreateStream(headers http.Header, parent *Stream, fin bool) (*Stream, error) {
// MUST synchronize stream creation (all the way to writing the frame)
// as stream IDs **MUST** increase monotonically.
s.nextIdLock.Lock()
defer s.nextIdLock.Unlock()
streamId := s.getNextStreamId() streamId := s.getNextStreamId()
if streamId == 0 { if streamId == 0 {
return nil, fmt.Errorf("Unable to get new stream id") return nil, fmt.Errorf("Unable to get new stream id")
@@ -833,8 +838,6 @@ func (s *Connection) sendStream(stream *Stream, fin bool) error {
// getNextStreamId returns the next sequential id // getNextStreamId returns the next sequential id
// every call should produce a unique value or an error // every call should produce a unique value or an error
func (s *Connection) getNextStreamId() spdy.StreamId { func (s *Connection) getNextStreamId() spdy.StreamId {
s.nextIdLock.Lock()
defer s.nextIdLock.Unlock()
sid := s.nextStreamId sid := s.nextStreamId
if sid > 0x7fffffff { if sid > 0x7fffffff {
return 0 return 0

View File

@@ -4,7 +4,7 @@ import (
"container/heap" "container/heap"
"sync" "sync"
"golang.org/x/net/spdy" "github.com/docker/spdystream/spdy"
) )
type prioritizedFrame struct { type prioritizedFrame struct {

View File

@@ -5,7 +5,7 @@ import (
"testing" "testing"
"time" "time"
"golang.org/x/net/spdy" "github.com/docker/spdystream/spdy"
) )
func TestPriorityQueueOrdering(t *testing.T) { func TestPriorityQueueOrdering(t *testing.T) {

View File

@@ -4,7 +4,7 @@
// Package spdy implements the SPDY protocol (currently SPDY/3), described in // Package spdy implements the SPDY protocol (currently SPDY/3), described in
// http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3. // http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3.
package spdy // import "golang.org/x/net/spdy" package spdy
import ( import (
"bytes" "bytes"

View File

@@ -9,7 +9,7 @@ import (
"sync" "sync"
"time" "time"
"golang.org/x/net/spdy" "github.com/docker/spdystream/spdy"
) )
var ( var (

View File

@@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations // License for the specific language governing permissions and limitations
// under the License. // under the License.
package internal // import "github.com/garyburd/redigo/internal" package internal
import ( import (
"strings" "strings"

View File

@@ -166,4 +166,4 @@
// if _, err := redis.Scan(reply, &value1, &value2); err != nil { // if _, err := redis.Scan(reply, &value1, &value2); err != nil {
// // handle error // // handle error
// } // }
package redis // import "github.com/garyburd/redigo/redis" package redis

View File

@@ -1,121 +0,0 @@
// +build example-exec
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"flag"
"fmt"
exec "github.com/mesos/mesos-go/executor"
mesos "github.com/mesos/mesos-go/mesosproto"
)
type exampleExecutor struct {
tasksLaunched int
}
func newExampleExecutor() *exampleExecutor {
return &exampleExecutor{tasksLaunched: 0}
}
func (exec *exampleExecutor) Registered(driver exec.ExecutorDriver, execInfo *mesos.ExecutorInfo, fwinfo *mesos.FrameworkInfo, slaveInfo *mesos.SlaveInfo) {
fmt.Println("Registered Executor on slave ", slaveInfo.GetHostname())
}
func (exec *exampleExecutor) Reregistered(driver exec.ExecutorDriver, slaveInfo *mesos.SlaveInfo) {
fmt.Println("Re-registered Executor on slave ", slaveInfo.GetHostname())
}
func (exec *exampleExecutor) Disconnected(exec.ExecutorDriver) {
fmt.Println("Executor disconnected.")
}
func (exec *exampleExecutor) LaunchTask(driver exec.ExecutorDriver, taskInfo *mesos.TaskInfo) {
fmt.Println("Launching task", taskInfo.GetName(), "with command", taskInfo.Command.GetValue())
runStatus := &mesos.TaskStatus{
TaskId: taskInfo.GetTaskId(),
State: mesos.TaskState_TASK_RUNNING.Enum(),
}
_, err := driver.SendStatusUpdate(runStatus)
if err != nil {
fmt.Println("Got error", err)
}
exec.tasksLaunched++
fmt.Println("Total tasks launched ", exec.tasksLaunched)
//
// this is where one would perform the requested task
//
// finish task
fmt.Println("Finishing task", taskInfo.GetName())
finStatus := &mesos.TaskStatus{
TaskId: taskInfo.GetTaskId(),
State: mesos.TaskState_TASK_FINISHED.Enum(),
}
_, err = driver.SendStatusUpdate(finStatus)
if err != nil {
fmt.Println("Got error", err)
}
fmt.Println("Task finished", taskInfo.GetName())
}
func (exec *exampleExecutor) KillTask(exec.ExecutorDriver, *mesos.TaskID) {
fmt.Println("Kill task")
}
func (exec *exampleExecutor) FrameworkMessage(driver exec.ExecutorDriver, msg string) {
fmt.Println("Got framework message: ", msg)
}
func (exec *exampleExecutor) Shutdown(exec.ExecutorDriver) {
fmt.Println("Shutting down the executor")
}
func (exec *exampleExecutor) Error(driver exec.ExecutorDriver, err string) {
fmt.Println("Got error message:", err)
}
// -------------------------- func inits () ----------------- //
func init() {
flag.Parse()
}
func main() {
fmt.Println("Starting Example Executor (Go)")
dconfig := exec.DriverConfig{
Executor: newExampleExecutor(),
}
driver, err := exec.NewMesosExecutorDriver(dconfig)
if err != nil {
fmt.Println("Unable to create a ExecutorDriver ", err.Error())
}
_, err = driver.Start()
if err != nil {
fmt.Println("Got error:", err)
return
}
fmt.Println("Executor process has started and running.")
driver.Join()
}

View File

@@ -1,294 +0,0 @@
// +build example-sched
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"flag"
"fmt"
"io/ioutil"
"net"
"net/http"
"strconv"
"strings"
"github.com/gogo/protobuf/proto"
log "github.com/golang/glog"
"github.com/mesos/mesos-go/auth"
"github.com/mesos/mesos-go/auth/sasl"
"github.com/mesos/mesos-go/auth/sasl/mech"
mesos "github.com/mesos/mesos-go/mesosproto"
util "github.com/mesos/mesos-go/mesosutil"
sched "github.com/mesos/mesos-go/scheduler"
"golang.org/x/net/context"
)
const (
CPUS_PER_TASK = 1
MEM_PER_TASK = 128
defaultArtifactPort = 12345
)
var (
address = flag.String("address", "127.0.0.1", "Binding address for artifact server")
artifactPort = flag.Int("artifactPort", defaultArtifactPort, "Binding port for artifact server")
authProvider = flag.String("mesos_authentication_provider", sasl.ProviderName,
fmt.Sprintf("Authentication provider to use, default is SASL that supports mechanisms: %+v", mech.ListSupported()))
master = flag.String("master", "127.0.0.1:5050", "Master address <ip:port>")
executorPath = flag.String("executor", "./example_executor", "Path to test executor")
taskCount = flag.String("task-count", "5", "Total task count to run.")
mesosAuthPrincipal = flag.String("mesos_authentication_principal", "", "Mesos authentication principal.")
mesosAuthSecretFile = flag.String("mesos_authentication_secret_file", "", "Mesos authentication secret file.")
)
type ExampleScheduler struct {
executor *mesos.ExecutorInfo
tasksLaunched int
tasksFinished int
totalTasks int
}
func newExampleScheduler(exec *mesos.ExecutorInfo) *ExampleScheduler {
total, err := strconv.Atoi(*taskCount)
if err != nil {
total = 5
}
return &ExampleScheduler{
executor: exec,
tasksLaunched: 0,
tasksFinished: 0,
totalTasks: total,
}
}
func (sched *ExampleScheduler) Registered(driver sched.SchedulerDriver, frameworkId *mesos.FrameworkID, masterInfo *mesos.MasterInfo) {
log.Infoln("Framework Registered with Master ", masterInfo)
}
func (sched *ExampleScheduler) Reregistered(driver sched.SchedulerDriver, masterInfo *mesos.MasterInfo) {
log.Infoln("Framework Re-Registered with Master ", masterInfo)
}
func (sched *ExampleScheduler) Disconnected(sched.SchedulerDriver) {}
func (sched *ExampleScheduler) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.Offer) {
for _, offer := range offers {
cpuResources := util.FilterResources(offer.Resources, func(res *mesos.Resource) bool {
return res.GetName() == "cpus"
})
cpus := 0.0
for _, res := range cpuResources {
cpus += res.GetScalar().GetValue()
}
memResources := util.FilterResources(offer.Resources, func(res *mesos.Resource) bool {
return res.GetName() == "mem"
})
mems := 0.0
for _, res := range memResources {
mems += res.GetScalar().GetValue()
}
log.Infoln("Received Offer <", offer.Id.GetValue(), "> with cpus=", cpus, " mem=", mems)
remainingCpus := cpus
remainingMems := mems
var tasks []*mesos.TaskInfo
for sched.tasksLaunched < sched.totalTasks &&
CPUS_PER_TASK <= remainingCpus &&
MEM_PER_TASK <= remainingMems {
sched.tasksLaunched++
taskId := &mesos.TaskID{
Value: proto.String(strconv.Itoa(sched.tasksLaunched)),
}
task := &mesos.TaskInfo{
Name: proto.String("go-task-" + taskId.GetValue()),
TaskId: taskId,
SlaveId: offer.SlaveId,
Executor: sched.executor,
Resources: []*mesos.Resource{
util.NewScalarResource("cpus", CPUS_PER_TASK),
util.NewScalarResource("mem", MEM_PER_TASK),
},
}
log.Infof("Prepared task: %s with offer %s for launch\n", task.GetName(), offer.Id.GetValue())
tasks = append(tasks, task)
remainingCpus -= CPUS_PER_TASK
remainingMems -= MEM_PER_TASK
}
log.Infoln("Launching ", len(tasks), "tasks for offer", offer.Id.GetValue())
driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, &mesos.Filters{RefuseSeconds: proto.Float64(1)})
}
}
func (sched *ExampleScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
log.Infoln("Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String())
if status.GetState() == mesos.TaskState_TASK_FINISHED {
sched.tasksFinished++
}
if sched.tasksFinished >= sched.totalTasks {
log.Infoln("Total tasks completed, stopping framework.")
driver.Stop(false)
}
if status.GetState() == mesos.TaskState_TASK_LOST ||
status.GetState() == mesos.TaskState_TASK_KILLED ||
status.GetState() == mesos.TaskState_TASK_FAILED {
log.Infoln(
"Aborting because task", status.TaskId.GetValue(),
"is in unexpected state", status.State.String(),
"with message", status.GetMessage(),
)
driver.Abort()
}
}
func (sched *ExampleScheduler) OfferRescinded(sched.SchedulerDriver, *mesos.OfferID) {}
func (sched *ExampleScheduler) FrameworkMessage(sched.SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, string) {
}
func (sched *ExampleScheduler) SlaveLost(sched.SchedulerDriver, *mesos.SlaveID) {}
func (sched *ExampleScheduler) ExecutorLost(sched.SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, int) {
}
func (sched *ExampleScheduler) Error(driver sched.SchedulerDriver, err string) {
log.Infoln("Scheduler received error:", err)
}
// ----------------------- func init() ------------------------- //
func init() {
flag.Parse()
log.Infoln("Initializing the Example Scheduler...")
}
// returns (downloadURI, basename(path))
func serveExecutorArtifact(path string) (*string, string) {
serveFile := func(pattern string, filename string) {
http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filename)
})
}
// Create base path (http://foobar:5000/<base>)
pathSplit := strings.Split(path, "/")
var base string
if len(pathSplit) > 0 {
base = pathSplit[len(pathSplit)-1]
} else {
base = path
}
serveFile("/"+base, path)
hostURI := fmt.Sprintf("http://%s:%d/%s", *address, *artifactPort, base)
log.V(2).Infof("Hosting artifact '%s' at '%s'", path, hostURI)
return &hostURI, base
}
func prepareExecutorInfo() *mesos.ExecutorInfo {
executorUris := []*mesos.CommandInfo_URI{}
uri, executorCmd := serveExecutorArtifact(*executorPath)
executorUris = append(executorUris, &mesos.CommandInfo_URI{Value: uri, Executable: proto.Bool(true)})
executorCommand := fmt.Sprintf("./%s", executorCmd)
go http.ListenAndServe(fmt.Sprintf("%s:%d", *address, *artifactPort), nil)
log.V(2).Info("Serving executor artifacts...")
// Create mesos scheduler driver.
return &mesos.ExecutorInfo{
ExecutorId: util.NewExecutorID("default"),
Name: proto.String("Test Executor (Go)"),
Source: proto.String("go_test"),
Command: &mesos.CommandInfo{
Value: proto.String(executorCommand),
Uris: executorUris,
},
}
}
func parseIP(address string) net.IP {
addr, err := net.LookupIP(address)
if err != nil {
log.Fatal(err)
}
if len(addr) < 1 {
log.Fatalf("failed to parse IP from address '%v'", address)
}
return addr[0]
}
// ----------------------- func main() ------------------------- //
func main() {
// build command executor
exec := prepareExecutorInfo()
// the framework
fwinfo := &mesos.FrameworkInfo{
User: proto.String(""), // Mesos-go will fill in user.
Name: proto.String("Test Framework (Go)"),
}
cred := (*mesos.Credential)(nil)
if *mesosAuthPrincipal != "" {
fwinfo.Principal = proto.String(*mesosAuthPrincipal)
secret, err := ioutil.ReadFile(*mesosAuthSecretFile)
if err != nil {
log.Fatal(err)
}
cred = &mesos.Credential{
Principal: proto.String(*mesosAuthPrincipal),
Secret: secret,
}
}
bindingAddress := parseIP(*address)
config := sched.DriverConfig{
Scheduler: newExampleScheduler(exec),
Framework: fwinfo,
Master: *master,
Credential: cred,
BindingAddress: bindingAddress,
WithAuthContext: func(ctx context.Context) context.Context {
ctx = auth.WithLoginProvider(ctx, *authProvider)
ctx = sasl.WithBindingAddress(ctx, bindingAddress)
return ctx
},
}
driver, err := sched.NewMesosSchedulerDriver(config)
if err != nil {
log.Errorln("Unable to create a SchedulerDriver ", err.Error())
}
if stat, err := driver.Run(); err != nil {
log.Infof("Framework stopped with status %s and error: %s\n", stat.String(), err.Error())
}
}

View File

@@ -1,40 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package healthchecker
import (
"time"
"github.com/mesos/mesos-go/upid"
)
// HealthChecker defines the interface of a health checker.
type HealthChecker interface {
// Start will start the health checker, and returns a notification channel.
// if the checker thinks the slave is unhealthy, it will send the timestamp
// via the channel.
Start() <-chan time.Time
// Pause will pause the slave health checker.
Pause()
// Continue will continue the slave health checker with a new slave upid.
Continue(slaveUPID *upid.UPID)
// Stop will stop the health checker. it should be called only once during
// the life span of the checker.
Stop()
}

View File

@@ -1,61 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package healthchecker
import (
"time"
"github.com/mesos/mesos-go/upid"
"github.com/stretchr/testify/mock"
)
type MockedHealthChecker struct {
mock.Mock
ch chan time.Time
}
// NewMockedHealthChecker returns a new mocked health checker.
func NewMockedHealthChecker() *MockedHealthChecker {
return &MockedHealthChecker{ch: make(chan time.Time, 1)}
}
// Start will start the checker and returns the notification channel.
func (m *MockedHealthChecker) Start() <-chan time.Time {
m.Called()
return m.ch
}
// Pause will pause the slave health checker.
func (m *MockedHealthChecker) Pause() {
m.Called()
}
// Continue will continue the slave health checker with a new slave upid.
func (m *MockedHealthChecker) Continue(slaveUPID *upid.UPID) {
m.Called()
}
// Stop will stop the checker.
func (m *MockedHealthChecker) Stop() {
m.Called()
}
func (m *MockedHealthChecker) TriggerUnhealthyEvent() {
m.ch <- time.Now()
}

View File

@@ -1,138 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package healthchecker
import (
"fmt"
"net/http"
"sync"
"time"
log "github.com/golang/glog"
"github.com/mesos/mesos-go/upid"
)
const (
defaultTimeout = time.Second
defaultCheckDuration = time.Second
defaultThreshold = 5
)
// SlaveHealthChecker is for checking the slave's health.
type SlaveHealthChecker struct {
sync.RWMutex
slaveUPID *upid.UPID
client *http.Client
threshold int
checkDuration time.Duration
continuousUnhealthyCount int
stop chan struct{}
ch chan time.Time
paused bool
}
// NewSlaveHealthChecker creates a slave health checker and return a notification channel.
// Each time the checker thinks the slave is unhealthy, it will send a notification through the channel.
func NewSlaveHealthChecker(slaveUPID *upid.UPID, threshold int, checkDuration time.Duration, timeout time.Duration) *SlaveHealthChecker {
checker := &SlaveHealthChecker{
slaveUPID: slaveUPID,
client: &http.Client{Timeout: timeout},
threshold: threshold,
checkDuration: checkDuration,
stop: make(chan struct{}),
ch: make(chan time.Time, 1),
}
if timeout == 0 {
checker.client.Timeout = defaultTimeout
}
if checkDuration == 0 {
checker.checkDuration = defaultCheckDuration
}
if threshold <= 0 {
checker.threshold = defaultThreshold
}
return checker
}
// Start will start the health checker and returns the notification channel.
func (s *SlaveHealthChecker) Start() <-chan time.Time {
go func() {
ticker := time.Tick(s.checkDuration)
for {
select {
case <-ticker:
s.RLock()
if !s.paused {
s.doCheck()
}
s.RUnlock()
case <-s.stop:
return
}
}
}()
return s.ch
}
// Pause will pause the slave health checker.
func (s *SlaveHealthChecker) Pause() {
s.Lock()
defer s.Unlock()
s.paused = true
}
// Continue will continue the slave health checker with a new slave upid.
func (s *SlaveHealthChecker) Continue(slaveUPID *upid.UPID) {
s.Lock()
defer s.Unlock()
s.paused = false
s.slaveUPID = slaveUPID
}
// Stop will stop the slave health checker.
// It should be called only once during the life span of the checker.
func (s *SlaveHealthChecker) Stop() {
close(s.stop)
}
func (s *SlaveHealthChecker) doCheck() {
path := fmt.Sprintf("http://%s:%s/%s/health", s.slaveUPID.Host, s.slaveUPID.Port, s.slaveUPID.ID)
resp, err := s.client.Head(path)
unhealthy := false
if err != nil {
log.Errorf("Failed to request the health path: %v\n", err)
unhealthy = true
} else if resp.StatusCode != http.StatusOK {
log.Errorf("Failed to request the health path: status: %v\n", resp.StatusCode)
unhealthy = true
}
if unhealthy {
s.continuousUnhealthyCount++
if s.continuousUnhealthyCount >= s.threshold {
select {
case s.ch <- time.Now(): // If no one is receiving the channel, then just skip it.
default:
}
s.continuousUnhealthyCount = 0
}
return
}
s.continuousUnhealthyCount = 0
resp.Body.Close()
}

View File

@@ -1,262 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package healthchecker
import (
"fmt"
"net/http"
"net/http/httptest"
"sync"
"sync/atomic"
"testing"
"time"
"github.com/mesos/mesos-go/upid"
"github.com/stretchr/testify/assert"
)
type thresholdMonitor struct {
cnt int32
threshold int32
}
func newThresholdMonitor(threshold int) *thresholdMonitor {
return &thresholdMonitor{threshold: int32(threshold)}
}
// incAndTest returns true if the threshold is reached.
func (t *thresholdMonitor) incAndTest() bool {
if atomic.AddInt32(&t.cnt, 1) >= t.threshold {
return false
}
return true
}
// blockedServer replies only threshold times, after that
// it will block.
type blockedServer struct {
th *thresholdMonitor
ch chan struct{}
}
func newBlockedServer(threshold int) *blockedServer {
return &blockedServer{
th: newThresholdMonitor(threshold),
ch: make(chan struct{}),
}
}
func (s *blockedServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if s.th.incAndTest() {
return
}
<-s.ch
}
func (s *blockedServer) stop() {
close(s.ch)
}
// eofServer will close the connection after it replies for threshold times.
// Thus the health checker will get an EOF error.
type eofServer struct {
th *thresholdMonitor
}
func newEOFServer(threshold int) *eofServer {
return &eofServer{newThresholdMonitor(threshold)}
}
func (s *eofServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if s.th.incAndTest() {
return
}
hj := w.(http.Hijacker)
conn, _, err := hj.Hijack()
if err != nil {
panic("Cannot hijack")
}
conn.Close()
}
// errorStatusCodeServer will reply error status code (e.g. 503) after the
// it replies for threhold time.
type errorStatusCodeServer struct {
th *thresholdMonitor
}
func newErrorStatusServer(threshold int) *errorStatusCodeServer {
return &errorStatusCodeServer{newThresholdMonitor(threshold)}
}
func (s *errorStatusCodeServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if s.th.incAndTest() {
return
}
w.WriteHeader(http.StatusServiceUnavailable)
}
// goodServer always returns status ok.
type goodServer bool
func (s *goodServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {}
// partitionedServer returns status ok at some first requests.
// Then it will block for a while, and then reply again.
type partitionedServer struct {
healthyCnt int32
partitionCnt int32
cnt int32
mutex *sync.Mutex
cond *sync.Cond
}
func newPartitionedServer(healthyCnt, partitionCnt int) *partitionedServer {
mutex := new(sync.Mutex)
cond := sync.NewCond(mutex)
return &partitionedServer{
healthyCnt: int32(healthyCnt),
partitionCnt: int32(partitionCnt),
mutex: mutex,
cond: cond,
}
}
func (s *partitionedServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
cnt := atomic.AddInt32(&s.cnt, 1)
if cnt < s.healthyCnt {
return
}
if cnt < s.healthyCnt+s.partitionCnt {
s.mutex.Lock()
defer s.mutex.Unlock()
s.cond.Wait()
return
}
s.mutex.Lock()
defer s.mutex.Unlock()
s.cond.Broadcast()
}
func TestSlaveHealthCheckerFailedOnBlockedSlave(t *testing.T) {
s := newBlockedServer(5)
ts := httptest.NewUnstartedServer(s)
ts.Start()
defer ts.Close()
upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String()))
assert.NoError(t, err)
checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10)
ch := checker.Start()
defer checker.Stop()
select {
case <-time.After(time.Second):
s.stop()
t.Fatal("timeout")
case <-ch:
s.stop()
assert.True(t, atomic.LoadInt32(&s.th.cnt) > 10)
}
}
func TestSlaveHealthCheckerFailedOnEOFSlave(t *testing.T) {
s := newEOFServer(5)
ts := httptest.NewUnstartedServer(s)
ts.Start()
defer ts.Close()
upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String()))
assert.NoError(t, err)
checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10)
ch := checker.Start()
defer checker.Stop()
select {
case <-time.After(time.Second):
t.Fatal("timeout")
case <-ch:
assert.True(t, atomic.LoadInt32(&s.th.cnt) > 10)
}
}
func TestSlaveHealthCheckerFailedOnErrorStatusSlave(t *testing.T) {
s := newErrorStatusServer(5)
ts := httptest.NewUnstartedServer(s)
ts.Start()
defer ts.Close()
upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String()))
assert.NoError(t, err)
checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10)
ch := checker.Start()
defer checker.Stop()
select {
case <-time.After(time.Second):
t.Fatal("timeout")
case <-ch:
assert.True(t, atomic.LoadInt32(&s.th.cnt) > 10)
}
}
func TestSlaveHealthCheckerSucceed(t *testing.T) {
s := new(goodServer)
ts := httptest.NewUnstartedServer(s)
ts.Start()
defer ts.Close()
upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String()))
assert.NoError(t, err)
checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10)
ch := checker.Start()
defer checker.Stop()
select {
case <-time.After(time.Second):
assert.Equal(t, 0, checker.continuousUnhealthyCount)
case <-ch:
t.Fatal("Shouldn't get unhealthy notification")
}
}
func TestSlaveHealthCheckerPartitonedSlave(t *testing.T) {
s := newPartitionedServer(5, 9)
ts := httptest.NewUnstartedServer(s)
ts.Start()
defer ts.Close()
upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String()))
assert.NoError(t, err)
checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10)
ch := checker.Start()
defer checker.Stop()
select {
case <-time.After(time.Second):
assert.Equal(t, 0, checker.continuousUnhealthyCount)
case <-ch:
t.Fatal("Shouldn't get unhealthy notification")
}
}

View File

@@ -1,3 +0,0 @@
// This package was previously the home of the native bindings. Please use the
// native branch if you need to build against the native bindings.
package mesos

View File

@@ -1,135 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//Collection of resources for teting mesos artifacts.
package testutil
import (
"bytes"
"fmt"
"github.com/gogo/protobuf/proto"
log "github.com/golang/glog"
"github.com/mesos/mesos-go/upid"
"github.com/stretchr/testify/assert"
"io"
"net"
"net/http"
"net/http/httptest"
"os"
"reflect"
"testing"
)
//MockMesosHttpProcess represents a remote http process: master or slave.
type MockMesosHttpServer struct {
PID *upid.UPID
Addr string
server *httptest.Server
t *testing.T
when map[string]http.HandlerFunc
}
type When interface {
Do(http.HandlerFunc)
}
type WhenFunc func(http.HandlerFunc)
func (w WhenFunc) Do(f http.HandlerFunc) {
w(f)
}
func (m *MockMesosHttpServer) On(uri string) When {
log.V(2).Infof("when %v do something special", uri)
return WhenFunc(func(f http.HandlerFunc) {
log.V(2).Infof("registered callback for %v", uri)
m.when[uri] = f
})
}
func NewMockMasterHttpServer(t *testing.T, handler func(rsp http.ResponseWriter, req *http.Request)) *MockMesosHttpServer {
var server *httptest.Server
when := make(map[string]http.HandlerFunc)
stateHandler := func(rsp http.ResponseWriter, req *http.Request) {
if "/state.json" == req.RequestURI {
state := fmt.Sprintf(`{ "leader": "master@%v" }`, server.Listener.Addr())
log.V(1).Infof("returning JSON %v", state)
io.WriteString(rsp, state)
} else if f, found := when[req.RequestURI]; found {
f(rsp, req)
} else {
handler(rsp, req)
}
}
server = httptest.NewServer(http.HandlerFunc(stateHandler))
assert.NotNil(t, server)
addr := server.Listener.Addr().String()
pid, err := upid.Parse("master@" + addr)
assert.NoError(t, err)
assert.NotNil(t, pid)
log.Infoln("Created test Master http server with PID", pid.String())
return &MockMesosHttpServer{PID: pid, Addr: addr, server: server, t: t, when: when}
}
func NewMockSlaveHttpServer(t *testing.T, handler func(rsp http.ResponseWriter, req *http.Request)) *MockMesosHttpServer {
server := httptest.NewServer(http.HandlerFunc(handler))
assert.NotNil(t, server)
addr := server.Listener.Addr().String()
pid, err := upid.Parse("slave(1)@" + addr)
assert.NoError(t, err)
assert.NotNil(t, pid)
assert.NoError(t, os.Setenv("MESOS_SLAVE_PID", pid.String()))
assert.NoError(t, os.Setenv("MESOS_SLAVE_ID", "test-slave-001"))
log.Infoln("Created test Slave http server with PID", pid.String())
return &MockMesosHttpServer{PID: pid, Addr: addr, server: server, t: t}
}
func (s *MockMesosHttpServer) Close() {
s.server.Close()
}
//MockMesosClient Http client to communicate with mesos processes (master,sched,exec)
type MockMesosClient struct {
pid *upid.UPID
t *testing.T
}
func NewMockMesosClient(t *testing.T, pid *upid.UPID) *MockMesosClient {
return &MockMesosClient{t: t, pid: pid}
}
// sendMessage Mocks sending event messages to a processes such as master, sched or exec.
func (c *MockMesosClient) SendMessage(targetPid *upid.UPID, message proto.Message) {
if c.t == nil {
panic("MockMesosClient needs a testing context.")
}
messageName := reflect.TypeOf(message).Elem().Name()
data, err := proto.Marshal(message)
assert.NoError(c.t, err)
hostport := net.JoinHostPort(targetPid.Host, targetPid.Port)
targetURL := fmt.Sprintf("http://%s/%s/mesos.internal.%s", hostport, targetPid.ID, messageName)
log.Infoln("MockMesosClient Sending message to", targetURL)
req, err := http.NewRequest("POST", targetURL, bytes.NewReader(data))
assert.NoError(c.t, err)
req.Header.Add("Libprocess-From", c.pid.String())
req.Header.Add("Content-Type", "application/x-protobuf")
resp, err := http.DefaultClient.Do(req)
assert.NoError(c.t, err)
assert.Equal(c.t, http.StatusAccepted, resp.StatusCode)
}

View File

@@ -5,7 +5,7 @@
// //
// At this time, it does not try to ensure that generated anchor names // At this time, it does not try to ensure that generated anchor names
// are unique, that responsibility falls on the caller. // are unique, that responsibility falls on the caller.
package sanitized_anchor_name // import "github.com/shurcooL/sanitized_anchor_name" package sanitized_anchor_name
import "unicode" import "unicode"

View File

@@ -1,22 +0,0 @@
Copyright (c) 2013 skratchdot
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -60,7 +60,8 @@ type Capabilities interface {
Apply(kind CapType) error Apply(kind CapType) error
} }
// NewPid create new initialized Capabilities object for given pid. // NewPid create new initialized Capabilities object for given pid when it
// is nonzero, or for the current pid if pid is 0
func NewPid(pid int) (Capabilities, error) { func NewPid(pid int) (Capabilities, error) {
return newPid(pid) return newPid(pid)
} }

View File

@@ -24,12 +24,46 @@ const (
linuxCapVer3 = 0x20080522 linuxCapVer3 = 0x20080522
) )
var capVers uint32 var (
capVers uint32
capLastCap Cap
)
func init() { func init() {
var hdr capHeader var hdr capHeader
capget(&hdr, nil) capget(&hdr, nil)
capVers = hdr.version capVers = hdr.version
if initLastCap() == nil {
CAP_LAST_CAP = capLastCap
if capLastCap > 31 {
capUpperMask = (uint32(1) << (uint(capLastCap) - 31)) - 1
} else {
capUpperMask = 0
}
}
}
func initLastCap() error {
if capLastCap != 0 {
return nil
}
f, err := os.Open("/proc/sys/kernel/cap_last_cap")
if err != nil {
return err
}
defer f.Close()
var b []byte = make([]byte, 11)
_, err = f.Read(b)
if err != nil {
return err
}
fmt.Sscanf(string(b), "%d", &capLastCap)
return nil
} }
func mkStringCap(c Capabilities, which CapType) (ret string) { func mkStringCap(c Capabilities, which CapType) (ret string) {
@@ -351,7 +385,15 @@ func (c *capsV3) Load() (err error) {
return return
} }
f, err := os.Open(fmt.Sprintf("/proc/%d/status", c.hdr.pid)) var status_path string
if c.hdr.pid == 0 {
status_path = fmt.Sprintf("/proc/self/status")
} else {
status_path = fmt.Sprintf("/proc/%d/status", c.hdr.pid)
}
f, err := os.Open(status_path)
if err != nil { if err != nil {
return return
} }

View File

@@ -34,110 +34,30 @@ const (
BOUNDS = BOUNDING BOUNDS = BOUNDING
) )
//go:generate go run enumgen/gen.go
type Cap int type Cap int
func (c Cap) String() string { // POSIX-draft defined capabilities.
switch c {
case CAP_CHOWN:
return "chown"
case CAP_DAC_OVERRIDE:
return "dac_override"
case CAP_DAC_READ_SEARCH:
return "dac_read_search"
case CAP_FOWNER:
return "fowner"
case CAP_FSETID:
return "fsetid"
case CAP_KILL:
return "kill"
case CAP_SETGID:
return "setgid"
case CAP_SETUID:
return "setuid"
case CAP_SETPCAP:
return "setpcap"
case CAP_LINUX_IMMUTABLE:
return "linux_immutable"
case CAP_NET_BIND_SERVICE:
return "net_bind_service"
case CAP_NET_BROADCAST:
return "net_broadcast"
case CAP_NET_ADMIN:
return "net_admin"
case CAP_NET_RAW:
return "net_raw"
case CAP_IPC_LOCK:
return "ipc_lock"
case CAP_IPC_OWNER:
return "ipc_owner"
case CAP_SYS_MODULE:
return "sys_module"
case CAP_SYS_RAWIO:
return "sys_rawio"
case CAP_SYS_CHROOT:
return "sys_chroot"
case CAP_SYS_PTRACE:
return "sys_ptrace"
case CAP_SYS_PACCT:
return "sys_psacct"
case CAP_SYS_ADMIN:
return "sys_admin"
case CAP_SYS_BOOT:
return "sys_boot"
case CAP_SYS_NICE:
return "sys_nice"
case CAP_SYS_RESOURCE:
return "sys_resource"
case CAP_SYS_TIME:
return "sys_time"
case CAP_SYS_TTY_CONFIG:
return "sys_tty_config"
case CAP_MKNOD:
return "mknod"
case CAP_LEASE:
return "lease"
case CAP_AUDIT_WRITE:
return "audit_write"
case CAP_AUDIT_CONTROL:
return "audit_control"
case CAP_SETFCAP:
return "setfcap"
case CAP_MAC_OVERRIDE:
return "mac_override"
case CAP_MAC_ADMIN:
return "mac_admin"
case CAP_SYSLOG:
return "syslog"
case CAP_WAKE_ALARM:
return "wake_alarm"
case CAP_BLOCK_SUSPEND:
return "block_suspend"
}
return "unknown"
}
const ( const (
// POSIX-draft defined capabilities.
// In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this // In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this
// overrides the restriction of changing file ownership and group // overrides the restriction of changing file ownership and group
// ownership. // ownership.
CAP_CHOWN Cap = 0 CAP_CHOWN = Cap(0)
// Override all DAC access, including ACL execute access if // Override all DAC access, including ACL execute access if
// [_POSIX_ACL] is defined. Excluding DAC access covered by // [_POSIX_ACL] is defined. Excluding DAC access covered by
// CAP_LINUX_IMMUTABLE. // CAP_LINUX_IMMUTABLE.
CAP_DAC_OVERRIDE Cap = 1 CAP_DAC_OVERRIDE = Cap(1)
// Overrides all DAC restrictions regarding read and search on files // Overrides all DAC restrictions regarding read and search on files
// and directories, including ACL restrictions if [_POSIX_ACL] is // and directories, including ACL restrictions if [_POSIX_ACL] is
// defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. // defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.
CAP_DAC_READ_SEARCH Cap = 2 CAP_DAC_READ_SEARCH = Cap(2)
// Overrides all restrictions about allowed operations on files, where // Overrides all restrictions about allowed operations on files, where
// file owner ID must be equal to the user ID, except where CAP_FSETID // file owner ID must be equal to the user ID, except where CAP_FSETID
// is applicable. It doesn't override MAC and DAC restrictions. // is applicable. It doesn't override MAC and DAC restrictions.
CAP_FOWNER Cap = 3 CAP_FOWNER = Cap(3)
// Overrides the following restrictions that the effective user ID // Overrides the following restrictions that the effective user ID
// shall match the file owner ID when setting the S_ISUID and S_ISGID // shall match the file owner ID when setting the S_ISUID and S_ISGID
@@ -145,21 +65,21 @@ const (
// supplementary group IDs) shall match the file owner ID when setting // supplementary group IDs) shall match the file owner ID when setting
// the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are // the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are
// cleared on successful return from chown(2) (not implemented). // cleared on successful return from chown(2) (not implemented).
CAP_FSETID Cap = 4 CAP_FSETID = Cap(4)
// Overrides the restriction that the real or effective user ID of a // Overrides the restriction that the real or effective user ID of a
// process sending a signal must match the real or effective user ID // process sending a signal must match the real or effective user ID
// of the process receiving the signal. // of the process receiving the signal.
CAP_KILL Cap = 5 CAP_KILL = Cap(5)
// Allows setgid(2) manipulation // Allows setgid(2) manipulation
// Allows setgroups(2) // Allows setgroups(2)
// Allows forged gids on socket credentials passing. // Allows forged gids on socket credentials passing.
CAP_SETGID Cap = 6 CAP_SETGID = Cap(6)
// Allows set*uid(2) manipulation (including fsuid). // Allows set*uid(2) manipulation (including fsuid).
// Allows forged pids on socket credentials passing. // Allows forged pids on socket credentials passing.
CAP_SETUID Cap = 7 CAP_SETUID = Cap(7)
// Linux-specific capabilities // Linux-specific capabilities
@@ -171,17 +91,17 @@ const (
// to the current process' inheritable set // to the current process' inheritable set
// Allow taking bits out of capability bounding set // Allow taking bits out of capability bounding set
// Allow modification of the securebits for a process // Allow modification of the securebits for a process
CAP_SETPCAP Cap = 8 CAP_SETPCAP = Cap(8)
// Allow modification of S_IMMUTABLE and S_APPEND file attributes // Allow modification of S_IMMUTABLE and S_APPEND file attributes
CAP_LINUX_IMMUTABLE Cap = 9 CAP_LINUX_IMMUTABLE = Cap(9)
// Allows binding to TCP/UDP sockets below 1024 // Allows binding to TCP/UDP sockets below 1024
// Allows binding to ATM VCIs below 32 // Allows binding to ATM VCIs below 32
CAP_NET_BIND_SERVICE Cap = 10 CAP_NET_BIND_SERVICE = Cap(10)
// Allow broadcasting, listen to multicast // Allow broadcasting, listen to multicast
CAP_NET_BROADCAST Cap = 11 CAP_NET_BROADCAST = Cap(11)
// Allow interface configuration // Allow interface configuration
// Allow administration of IP firewall, masquerading and accounting // Allow administration of IP firewall, masquerading and accounting
@@ -196,36 +116,36 @@ const (
// Allow multicasting // Allow multicasting
// Allow read/write of device-specific registers // Allow read/write of device-specific registers
// Allow activation of ATM control sockets // Allow activation of ATM control sockets
CAP_NET_ADMIN Cap = 12 CAP_NET_ADMIN = Cap(12)
// Allow use of RAW sockets // Allow use of RAW sockets
// Allow use of PACKET sockets // Allow use of PACKET sockets
// Allow binding to any address for transparent proxying (also via NET_ADMIN) // Allow binding to any address for transparent proxying (also via NET_ADMIN)
CAP_NET_RAW Cap = 13 CAP_NET_RAW = Cap(13)
// Allow locking of shared memory segments // Allow locking of shared memory segments
// Allow mlock and mlockall (which doesn't really have anything to do // Allow mlock and mlockall (which doesn't really have anything to do
// with IPC) // with IPC)
CAP_IPC_LOCK Cap = 14 CAP_IPC_LOCK = Cap(14)
// Override IPC ownership checks // Override IPC ownership checks
CAP_IPC_OWNER Cap = 15 CAP_IPC_OWNER = Cap(15)
// Insert and remove kernel modules - modify kernel without limit // Insert and remove kernel modules - modify kernel without limit
CAP_SYS_MODULE Cap = 16 CAP_SYS_MODULE = Cap(16)
// Allow ioperm/iopl access // Allow ioperm/iopl access
// Allow sending USB messages to any device via /proc/bus/usb // Allow sending USB messages to any device via /proc/bus/usb
CAP_SYS_RAWIO Cap = 17 CAP_SYS_RAWIO = Cap(17)
// Allow use of chroot() // Allow use of chroot()
CAP_SYS_CHROOT Cap = 18 CAP_SYS_CHROOT = Cap(18)
// Allow ptrace() of any process // Allow ptrace() of any process
CAP_SYS_PTRACE Cap = 19 CAP_SYS_PTRACE = Cap(19)
// Allow configuration of process accounting // Allow configuration of process accounting
CAP_SYS_PACCT Cap = 20 CAP_SYS_PACCT = Cap(20)
// Allow configuration of the secure attention key // Allow configuration of the secure attention key
// Allow administration of the random device // Allow administration of the random device
@@ -263,10 +183,10 @@ const (
// arbitrary SCSI commands // arbitrary SCSI commands
// Allow setting encryption key on loopback filesystem // Allow setting encryption key on loopback filesystem
// Allow setting zone reclaim policy // Allow setting zone reclaim policy
CAP_SYS_ADMIN Cap = 21 CAP_SYS_ADMIN = Cap(21)
// Allow use of reboot() // Allow use of reboot()
CAP_SYS_BOOT Cap = 22 CAP_SYS_BOOT = Cap(22)
// Allow raising priority and setting priority on other (different // Allow raising priority and setting priority on other (different
// UID) processes // UID) processes
@@ -274,7 +194,7 @@ const (
// processes and setting the scheduling algorithm used by another // processes and setting the scheduling algorithm used by another
// process. // process.
// Allow setting cpu affinity on other processes // Allow setting cpu affinity on other processes
CAP_SYS_NICE Cap = 23 CAP_SYS_NICE = Cap(23)
// Override resource limits. Set resource limits. // Override resource limits. Set resource limits.
// Override quota limits. // Override quota limits.
@@ -287,33 +207,33 @@ const (
// Allow more than 64hz interrupts from the real-time clock // Allow more than 64hz interrupts from the real-time clock
// Override max number of consoles on console allocation // Override max number of consoles on console allocation
// Override max number of keymaps // Override max number of keymaps
CAP_SYS_RESOURCE Cap = 24 CAP_SYS_RESOURCE = Cap(24)
// Allow manipulation of system clock // Allow manipulation of system clock
// Allow irix_stime on mips // Allow irix_stime on mips
// Allow setting the real-time clock // Allow setting the real-time clock
CAP_SYS_TIME Cap = 25 CAP_SYS_TIME = Cap(25)
// Allow configuration of tty devices // Allow configuration of tty devices
// Allow vhangup() of tty // Allow vhangup() of tty
CAP_SYS_TTY_CONFIG Cap = 26 CAP_SYS_TTY_CONFIG = Cap(26)
// Allow the privileged aspects of mknod() // Allow the privileged aspects of mknod()
CAP_MKNOD Cap = 27 CAP_MKNOD = Cap(27)
// Allow taking of leases on files // Allow taking of leases on files
CAP_LEASE Cap = 28 CAP_LEASE = Cap(28)
CAP_AUDIT_WRITE Cap = 29 CAP_AUDIT_WRITE = Cap(29)
CAP_AUDIT_CONTROL Cap = 30 CAP_AUDIT_CONTROL = Cap(30)
CAP_SETFCAP Cap = 31 CAP_SETFCAP = Cap(31)
// Override MAC access. // Override MAC access.
// The base kernel enforces no MAC policy. // The base kernel enforces no MAC policy.
// An LSM may enforce a MAC policy, and if it does and it chooses // An LSM may enforce a MAC policy, and if it does and it chooses
// to implement capability based overrides of that policy, this is // to implement capability based overrides of that policy, this is
// the capability it should use to do so. // the capability it should use to do so.
CAP_MAC_OVERRIDE Cap = 32 CAP_MAC_OVERRIDE = Cap(32)
// Allow MAC configuration or state changes. // Allow MAC configuration or state changes.
// The base kernel requires no MAC configuration. // The base kernel requires no MAC configuration.
@@ -321,18 +241,24 @@ const (
// to implement capability based checks on modifications to that // to implement capability based checks on modifications to that
// policy or the data required to maintain it, this is the // policy or the data required to maintain it, this is the
// capability it should use to do so. // capability it should use to do so.
CAP_MAC_ADMIN Cap = 33 CAP_MAC_ADMIN = Cap(33)
// Allow configuring the kernel's syslog (printk behaviour) // Allow configuring the kernel's syslog (printk behaviour)
CAP_SYSLOG Cap = 34 CAP_SYSLOG = Cap(34)
// Allow triggering something that will wake the system // Allow triggering something that will wake the system
CAP_WAKE_ALARM Cap = 35 CAP_WAKE_ALARM = Cap(35)
// Allow preventing system suspends // Allow preventing system suspends
CAP_BLOCK_SUSPEND Cap = 36 CAP_BLOCK_SUSPEND = Cap(36)
CAP_LAST_CAP = CAP_BLOCK_SUSPEND // Allow reading audit messages from the kernel
CAP_AUDIT_READ = Cap(37)
) )
const capUpperMask = (uint32(1) << (uint(CAP_LAST_CAP) - 31)) - 1 var (
// Highest valid capability of the running kernel.
CAP_LAST_CAP = Cap(63)
capUpperMask = ^uint32(0)
)

View File

@@ -0,0 +1,129 @@
// generated file; DO NOT EDIT - use go generate in directory with source
package capability
func (c Cap) String() string {
switch c {
case CAP_CHOWN:
return "chown"
case CAP_DAC_OVERRIDE:
return "dac_override"
case CAP_DAC_READ_SEARCH:
return "dac_read_search"
case CAP_FOWNER:
return "fowner"
case CAP_FSETID:
return "fsetid"
case CAP_KILL:
return "kill"
case CAP_SETGID:
return "setgid"
case CAP_SETUID:
return "setuid"
case CAP_SETPCAP:
return "setpcap"
case CAP_LINUX_IMMUTABLE:
return "linux_immutable"
case CAP_NET_BIND_SERVICE:
return "net_bind_service"
case CAP_NET_BROADCAST:
return "net_broadcast"
case CAP_NET_ADMIN:
return "net_admin"
case CAP_NET_RAW:
return "net_raw"
case CAP_IPC_LOCK:
return "ipc_lock"
case CAP_IPC_OWNER:
return "ipc_owner"
case CAP_SYS_MODULE:
return "sys_module"
case CAP_SYS_RAWIO:
return "sys_rawio"
case CAP_SYS_CHROOT:
return "sys_chroot"
case CAP_SYS_PTRACE:
return "sys_ptrace"
case CAP_SYS_PACCT:
return "sys_pacct"
case CAP_SYS_ADMIN:
return "sys_admin"
case CAP_SYS_BOOT:
return "sys_boot"
case CAP_SYS_NICE:
return "sys_nice"
case CAP_SYS_RESOURCE:
return "sys_resource"
case CAP_SYS_TIME:
return "sys_time"
case CAP_SYS_TTY_CONFIG:
return "sys_tty_config"
case CAP_MKNOD:
return "mknod"
case CAP_LEASE:
return "lease"
case CAP_AUDIT_WRITE:
return "audit_write"
case CAP_AUDIT_CONTROL:
return "audit_control"
case CAP_SETFCAP:
return "setfcap"
case CAP_MAC_OVERRIDE:
return "mac_override"
case CAP_MAC_ADMIN:
return "mac_admin"
case CAP_SYSLOG:
return "syslog"
case CAP_WAKE_ALARM:
return "wake_alarm"
case CAP_BLOCK_SUSPEND:
return "block_suspend"
case CAP_AUDIT_READ:
return "audit_read"
}
return "unknown"
}
// List returns list of all supported capabilities
func List() []Cap {
return []Cap{
CAP_CHOWN,
CAP_DAC_OVERRIDE,
CAP_DAC_READ_SEARCH,
CAP_FOWNER,
CAP_FSETID,
CAP_KILL,
CAP_SETGID,
CAP_SETUID,
CAP_SETPCAP,
CAP_LINUX_IMMUTABLE,
CAP_NET_BIND_SERVICE,
CAP_NET_BROADCAST,
CAP_NET_ADMIN,
CAP_NET_RAW,
CAP_IPC_LOCK,
CAP_IPC_OWNER,
CAP_SYS_MODULE,
CAP_SYS_RAWIO,
CAP_SYS_CHROOT,
CAP_SYS_PTRACE,
CAP_SYS_PACCT,
CAP_SYS_ADMIN,
CAP_SYS_BOOT,
CAP_SYS_NICE,
CAP_SYS_RESOURCE,
CAP_SYS_TIME,
CAP_SYS_TTY_CONFIG,
CAP_MKNOD,
CAP_LEASE,
CAP_AUDIT_WRITE,
CAP_AUDIT_CONTROL,
CAP_SETFCAP,
CAP_MAC_OVERRIDE,
CAP_MAC_ADMIN,
CAP_SYSLOG,
CAP_WAKE_ALARM,
CAP_BLOCK_SUSPEND,
CAP_AUDIT_READ,
}
}

View File

@@ -0,0 +1,92 @@
package main
import (
"bytes"
"fmt"
"go/ast"
"go/format"
"go/parser"
"go/token"
"io/ioutil"
"log"
"os"
"strings"
)
const fileName = "enum.go"
const genName = "enum_gen.go"
type generator struct {
buf bytes.Buffer
caps []string
}
func (g *generator) writeHeader() {
g.buf.WriteString("// generated file; DO NOT EDIT - use go generate in directory with source\n")
g.buf.WriteString("\n")
g.buf.WriteString("package capability")
}
func (g *generator) writeStringFunc() {
g.buf.WriteString("\n")
g.buf.WriteString("func (c Cap) String() string {\n")
g.buf.WriteString("switch c {\n")
for _, cap := range g.caps {
fmt.Fprintf(&g.buf, "case %s:\n", cap)
fmt.Fprintf(&g.buf, "return \"%s\"\n", strings.ToLower(cap[4:]))
}
g.buf.WriteString("}\n")
g.buf.WriteString("return \"unknown\"\n")
g.buf.WriteString("}\n")
}
func (g *generator) writeListFunc() {
g.buf.WriteString("\n")
g.buf.WriteString("// List returns list of all supported capabilities\n")
g.buf.WriteString("func List() []Cap {\n")
g.buf.WriteString("return []Cap{\n")
for _, cap := range g.caps {
fmt.Fprintf(&g.buf, "%s,\n", cap)
}
g.buf.WriteString("}\n")
g.buf.WriteString("}\n")
}
func main() {
fs := token.NewFileSet()
parsedFile, err := parser.ParseFile(fs, fileName, nil, 0)
if err != nil {
log.Fatal(err)
}
var caps []string
for _, decl := range parsedFile.Decls {
decl, ok := decl.(*ast.GenDecl)
if !ok || decl.Tok != token.CONST {
continue
}
for _, spec := range decl.Specs {
vspec := spec.(*ast.ValueSpec)
name := vspec.Names[0].Name
if strings.HasPrefix(name, "CAP_") {
caps = append(caps, name)
}
}
}
g := &generator{caps: caps}
g.writeHeader()
g.writeStringFunc()
g.writeListFunc()
src, err := format.Source(g.buf.Bytes())
if err != nil {
fmt.Println("generated invalid Go code")
fmt.Println(g.buf.String())
log.Fatal(err)
}
fi, err := os.Stat(fileName)
if err != nil {
log.Fatal(err)
}
if err := ioutil.WriteFile(genName, src, fi.Mode().Perm()); err != nil {
log.Fatal(err)
}
}

View File

@@ -86,6 +86,10 @@ func getVfsCap(path string, dest *vfscapData) (err error) {
} }
r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_vfsXattrName)), uintptr(unsafe.Pointer(dest)), vfscapDataSizeV2, 0, 0) r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_vfsXattrName)), uintptr(unsafe.Pointer(dest)), vfscapDataSizeV2, 0, 0)
if e1 != 0 { if e1 != 0 {
if e1 == syscall.ENODATA {
dest.version = 2
return
}
err = e1 err = e1
} }
switch dest.magic & vfsCapVerMask { switch dest.magic & vfsCapVerMask {
@@ -128,8 +132,6 @@ func setVfsCap(path string, data *vfscapData) (err error) {
data.magic = vfsCapVer2 data.magic = vfsCapVer2
if data.effective[0] != 0 || data.effective[1] != 0 { if data.effective[0] != 0 || data.effective[1] != 0 {
data.magic |= vfsCapFlageffective data.magic |= vfsCapFlageffective
data.data[0].permitted |= data.effective[0]
data.data[1].permitted |= data.effective[1]
} }
size = vfscapDataSizeV2 size = vfscapDataSizeV2
} else { } else {

View File

@@ -24,7 +24,7 @@ Example:
} }
*/ */
package inotify // import "golang.org/x/exp/inotify" package inotify
import ( import (
"errors" "errors"

View File

@@ -34,7 +34,7 @@
// //
// See http://blog.golang.org/context for example code for a server that uses // See http://blog.golang.org/context for example code for a server that uses
// Contexts. // Contexts.
package context // import "golang.org/x/net/context" package context
import ( import (
"errors" "errors"

View File

@@ -15,7 +15,7 @@
// whether atom.H1 < atom.H2 may also change. The codes are not guaranteed to // whether atom.H1 < atom.H2 may also change. The codes are not guaranteed to
// be dense. The only guarantees are that e.g. looking up "div" will yield // be dense. The only guarantees are that e.g. looking up "div" will yield
// atom.Div, calling atom.Div.String will return "div", and atom.Div != 0. // atom.Div, calling atom.Div.String will return "div", and atom.Div != 0.
package atom // import "golang.org/x/net/html/atom" package atom
// Atom is an integer code for a string. The zero value maps to "". // Atom is an integer code for a string. The zero value maps to "".
type Atom uint32 type Atom uint32

View File

@@ -6,7 +6,7 @@
// //
// The mapping from encoding labels to encodings is defined at // The mapping from encoding labels to encodings is defined at
// http://encoding.spec.whatwg.org. // http://encoding.spec.whatwg.org.
package charset // import "golang.org/x/net/html/charset" package charset
import ( import (
"bytes" "bytes"

View File

@@ -93,7 +93,7 @@ The relevant specifications include:
http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html and http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html and
http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
*/ */
package html // import "golang.org/x/net/html" package html
// The tokenization algorithm implemented by this package is not a line-by-line // The tokenization algorithm implemented by this package is not a line-by-line
// transliteration of the relatively verbose state-machine in the WHATWG // transliteration of the relatively verbose state-machine in the WHATWG

View File

@@ -4,7 +4,7 @@
// Package websocket implements a client and server for the WebSocket protocol // Package websocket implements a client and server for the WebSocket protocol
// as specified in RFC 6455. // as specified in RFC 6455.
package websocket // import "golang.org/x/net/websocket" package websocket
import ( import (
"bufio" "bufio"