Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding agent based filtering info #365

Closed
wants to merge 5 commits into from
Closed

Adding agent based filtering info #365

wants to merge 5 commits into from

Conversation

hnykda
Copy link
Contributor

@hnykda hnykda commented Sep 15, 2018

Trying to solve #364 . Mostly taken from test suite and here.

Copy link

@jmccann jmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me. Not sure how accurate it is as I've not done it but looking forward to this info being added so I can try it out more easily. 😉

@hnykda
Copy link
Contributor Author

hnykda commented Sep 15, 2018

Great to hear! Any feedback on testing this is welcome.

@thefab
Copy link

thefab commented Sep 17, 2018

seems to be really clear to me but...

drone-agent:
    image: drone/agent:0.8

    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=drone-server:9000
      - DRONE_SECRET=xxxxxxxxxxxxxxxxxxxxx
      - DRONE_DEBUG=true
      - DRONE_FILTER="repo != 'metwork-framework/mfext'"

And i got in agent logs:

{"time":"2018-09-17T08:56:07Z","level":"error","error":"rpc error: code = Unknown desc = selector: parse error:0: illegal value expression","message":"pipeline done with error"}

Did I miss something ? Or this feature is not available in 0.8 branch ?

@bradrydzewski
Copy link
Member

you should not quote docker environment variables. docker does not unquote them when it parses the yaml

  environment: 
- - DRONE_FILTER="repo != 'metwork-framework/mfext'"
+ - DRONE_FILTER=repo != 'metwork-framework/mfext'

@jmccann
Copy link

jmccann commented Sep 17, 2018

@bradrydzewski brings up a good point ...

Does https://github.com/drone/docs/pull/365/files#diff-9e57d9a3f73e1bb392b686d8a92afad2R39 need to be updated to reflect that?

Also, does

  environment: 
    - DRONE_FILTER=repo != 'metwork-framework/mfext'

"just work"? I'm worried with the spaces and special characters but admit I've not tried it myself

@bradrydzewski
Copy link
Member

bradrydzewski commented Sep 17, 2018

yep, docker does a strings.Split(s, "=", 2) and then uses a system call to the set the environment variable. Quoting or escaping values is not required when invoking the syscalls directly.

@thefab
Copy link

thefab commented Sep 18, 2018

with

environment: 
    - DRONE_FILTER=repo != 'metwork-framework/mfext'

my agent starts ! (thanks) but...

$ docker inspect 37b17a78a9a9 |grep DRONE_FILTER

                "DRONE_FILTER=repo != 'metwork-framework/mfext'",

and

$ docker logs -f 37b17a78a9a9

[...]
{"time":"2018-09-18T07:03:33Z","level":"debug","repo":"metwork-framework/mfext","build":"108","id":"2451","image":"metwork/mfext-centos6-buildimage:integration","stage":"build","message":"log stream opened"}

So, every thing seems to be ok but the agent does not filter !

$ docker images |grep drone/agent
drone/agent                           0.8                 ea280fb03b0a        7 weeks ago         13.7MB

Is it a feature specific to 0.9 version ? (I use the 0.8 branch)

@hnykda
Copy link
Contributor Author

hnykda commented Sep 18, 2018

I removed the quotes and added the info about not-quoting. Not sure which branch this applies to 😬, I believe it should be there since 0.8 already .

@thefab
Copy link

thefab commented Sep 24, 2018

after several days, does not work for me on 0.8 branch for "repo" or "repo-name" filter:

$ # FIRST AGENT
$ docker inspect b648b8d9fe4e |grep FILTER
                "DRONE_FILTER=repo-name != 'mfext'",

$ docker logs b648b8d9fe4e 2>&1 |grep mfext
[...]
{"time":"2018-09-24T11:00:45Z","level":"debug","repo":"metwork-framework/mfext","build":"145","id":"7831","message":"pipeline done"}
=> plenty of build for mfext repo-name (not normal)


$ # SECOND AGENT
$ docker inspect 7ef92464be55 |grep FILTER
                "DRONE_FILTER=repo-name == 'mfext'",

$ docker logs 7ef92464be55
{"time":"2018-09-19T11:57:27Z","level":"debug","message":"request next execution"}
=> no build (not normal)

no more luck with filtering on "repo" (instead of repo-name)

The filtering seems to work a little bit because I have no build on second agent. Maybe I miss something on filtering on repo name ?

@hnykda
Copy link
Contributor Author

hnykda commented Sep 26, 2018

Are you able to test it with e.g. 0.9?

@bradrydzewski
Copy link
Member

the behavior changed to the following in 0.9.* and higher:
https://docs.drone.io/reference/agent/drone-runner-labels/
https://docs.drone.io/config/pipeline/nodes/

since this is now documented in the latest version I'm going to close this issue.

@hnykda
Copy link
Contributor Author

hnykda commented Nov 9, 2018

Great, thanks.

@SmajeNz0
Copy link

SmajeNz0 commented Nov 10, 2018

Hello

https://docs.drone.io/config/pipeline/nodes/

Little typo intsance instead of instance.

BTW thank you for this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants